From 69bc0f70b780a7951ef12358f8b049fb2801690c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 10 Oct 2005 22:00:29 +0000 Subject: [PATCH] * src/Date.py: set default modifier properly, fix compare and sortval assignment * src/RelLib.py: fix source reference date comparison svn: r5299 --- gramps2/ChangeLog | 5 +++++ gramps2/src/Date.py | 25 ++++++++++++++++--------- gramps2/src/RelLib.py | 9 +++------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 214bb74e6..7935ce38e 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-10-10 Don Allingham + * src/Date.py: set default modifier properly, fix compare and sortval + assignment + * src/RelLib.py: fix source reference date comparison + 2005-10-09 Julio Sanchez * src/WriteGedcom.py: fixed error caused by incomplete migration to handle-based storage API diff --git a/gramps2/src/Date.py b/gramps2/src/Date.py index 04ad5e534..91bcc957c 100644 --- a/gramps2/src/Date.py +++ b/gramps2/src/Date.py @@ -122,7 +122,7 @@ class Date: self.sortval = source.sortval else: self.calendar = CAL_GREGORIAN - self.modifier = MOD_TEXTONLY + self.modifier = MOD_NONE self.quality = QUAL_NONE self.dateval = EMPTY self.text = u"" @@ -157,12 +157,13 @@ class Date: at the sorting value, and ignores the modifiers/comments. """ if self.modifier == other.modifier and self.modifier == MOD_TEXTONLY: - return self.text == other.text - return (self.calendar == other.calendar and - self.modifier == other.modifier and - self.quality == other.quality and - self.dateval == other.dateval and - self.sortval == other.sortval) + value = self.text == other.text + else: + value = (self.calendar == other.calendar and + self.modifier == other.modifier and + self.quality == other.quality and + self.dateval == other.dateval) + return value def __str__(self): """ @@ -455,7 +456,10 @@ class Date: year = max(value[_POS_YR],1) month = max(value[_POS_MON],1) day = max(value[_POS_DAY],1) - self.sortval = _calendar_convert[calendar](year,month,day) + if year == 0 and month == 0 and day == 0: + self.sortval = 0 + else: + self.sortval = _calendar_convert[calendar](year,month,day) if text: self.text = text @@ -463,7 +467,10 @@ class Date: year = max(self.dateval[_POS_YR],1) month = max(self.dateval[_POS_MON],1) day = max(self.dateval[_POS_DAY],1) - self.sortval = _calendar_convert[self.calendar](year,month,day) + if year == 0 and month == 0 and day == 0: + self.sortval = 0 + else: + self.sortval = _calendar_convert[self.calendar](year,month,day) def convert_calendar(self,calendar): """ diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 6d4f47d6e..17eedfa56 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -2242,6 +2242,7 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): """ if other == None: other = Event (None) + if (self.name != other.name or ((self.place or other.place) and (self.place != other.place)) or self.description != other.description or self.cause != other.cause or @@ -2262,6 +2263,7 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase): if (witness_list and not other_list) or \ (other_list and not witness_list): return False + if witness_list and other_list: another_list = other_list[:] for a in witness_list: @@ -3983,12 +3985,7 @@ class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase): if self.ref and other.ref: if self.page != other.page: return False - if (self.date and other.date and \ - not self.date.is_equal(other.date)) \ - or ((not self.date) and other.date and \ - not other.date.is_empty()) \ - or ((not other.date) and self.date and \ - not self.date.is_empty()): + if not self.get_date_object().is_equal(other.get_date_object()): return False if self.get_text() != other.get_text(): return False