From 4d82a70eaaee235c0daa3a1c478796fe1764eddf Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Sat, 14 Sep 2013 15:44:04 +0000 Subject: [PATCH] provide sensible defautls for all Date.set params svn: r23126 --- gramps/gen/lib/date.py | 24 ++++++++++++++++++++---- gramps/gen/lib/test/date_test.py | 4 ++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index 0f41f1645..cfda23a57 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -1493,30 +1493,46 @@ class Date(object): day = max(d, 1) return (year, month, day) - def set(self, quality, modifier, calendar, value, text=None, - newyear=0): + def set(self, quality=None, modifier=None, calendar=None, + value=None, + text=None, newyear=0): """ Set the date to the specified value. Parameters are:: quality - The date quality for the date (see get_quality - for more information) + for more information). + Defaults to the previous value for the date. modified - The date modifier for the date (see get_modifier for more information) + Defaults to the previous value for the date. calendar - The calendar associated with the date (see get_calendar for more information). + Defaults to the previous value for the date. value - A tuple representing the date information. For a non-compound date, the format is (DD, MM, YY, slash) and for a compound date the tuple stores data as (DD, MM, YY, slash1, DD, MM, YY, slash2) + Defaults to the previous value for the date. text - A text string holding either the verbatim user input or a comment relating to the date. + Defaults to the previous value for the date. newyear - The newyear code, or tuple representing (month, day) - of newyear day. + of newyear day. + Defaults to 0. The sort value is recalculated. """ + + if quality is None: + quality = self.quality + if modifier is None: + modifier = self.modifier + if calendar is None: + calendar = self.calendar + if value is None: + value = self.value if modifier in (Date.MOD_NONE, Date.MOD_BEFORE, Date.MOD_AFTER, Date.MOD_ABOUT) and len(value) < 4: diff --git a/gramps/gen/lib/test/date_test.py b/gramps/gen/lib/test/date_test.py index d29a23e8b..e0c4d0511 100644 --- a/gramps/gen/lib/test/date_test.py +++ b/gramps/gen/lib/test/date_test.py @@ -430,9 +430,9 @@ class Test_set2(BaseDateTest): """ def setUp(self): self.date = d = Date() - d.set(Date.QUAL_NONE, Date.MOD_RANGE, Date.CAL_GREGORIAN, + d.set(modifier=Date.MOD_RANGE, #d m y sl--d m y sl - (1, 1, 2000, 0, 1, 1, 2010, 0)) + value=(1, 1, 2000, 0, 1, 1, 2010, 0)) def testStartStopSanity(self): start,stop = self.date.get_start_stop_range()