From 1846c513cfc6ab3dd05cd318a826a36f9fa9357f Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Wed, 18 Nov 2009 22:45:54 +0000 Subject: [PATCH] 2799: in GEDCOM export, changed timestamp for every single record is 31 DEC 1969 svn: r13630 --- src/GrampsDbUtils/_GedcomParse.py | 22 +++++++++++++++------- src/gen/lib/primaryobj.py | 11 +++++++++++ src/gen/proxy/living.py | 3 +-- src/gen/proxy/private.py | 7 +++++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/GrampsDbUtils/_GedcomParse.py b/src/GrampsDbUtils/_GedcomParse.py index 3a9b4abe8..3cc2314f7 100644 --- a/src/GrampsDbUtils/_GedcomParse.py +++ b/src/GrampsDbUtils/_GedcomParse.py @@ -3490,7 +3490,7 @@ class GedcomParser(UpdateCallback): @type state: CurrentState """ state.repo_ref.set_call_number(line.data) - self.__skip_subordinate_levels(state.level+1) + #self.__skip_subordinate_levels(state.level+1) def __repo_ref_medi(self, line, state): name = line.data @@ -4167,20 +4167,28 @@ class GedcomParser(UpdateCallback): elif line.token == TOKEN_TIME: tstr = line.data elif line.token == TOKEN_DATE: - dstr = line.data + #GedcomLex converted already to Date object + dobj = line.data elif line.token == TOKEN_NOTE: self.__skip_subordinate_levels(level+1) else: self.__not_recognized(line, level+1) # Attempt to convert the values to a valid change time - if tstr: + if dobj: + dstr = "%s %s %s" % (dobj.get_day(), dobj.get_month(), + dobj.get_year()) try: - if dstr: - tstruct = time.strptime("%s %s" % (dstr, tstr), - "%d %b %Y %H:%M:%S") + if tstr: + try: + tstruct = time.strptime("%s %s" % (dstr, tstr), + "%d %m %Y %H:%M:%S") + except ValueError: + #seconds is optional in GEDCOM + tstruct = time.strptime("%s %s" % (dstr, tstr), + "%d %m %Y %H:%M") else: - tstruct = time.strptime(tstr, "%d %b %Y") + tstruct = time.strptime(dstr, "%d %m %Y") val = time.mktime(tstruct) obj.change = val except ValueError: diff --git a/src/gen/lib/primaryobj.py b/src/gen/lib/primaryobj.py index 83117ebaf..0849a8886 100644 --- a/src/gen/lib/primaryobj.py +++ b/src/gen/lib/primaryobj.py @@ -106,6 +106,17 @@ class BasicPrimaryObject(BaseObject, PrivacyBase): """ return self.change + def set_change_time(self, change): + """ + Modify the time that the data was last changed. + + The value must be in the format returned by the time.time() command. + + @param change: new time + @type change: int in format as time.time() command + """ + self.change = change + def get_change_display(self): """ Return the string representation of the last change time. diff --git a/src/gen/proxy/living.py b/src/gen/proxy/living.py index bc16d4f90..1ac44dcbd 100644 --- a/src/gen/proxy/living.py +++ b/src/gen/proxy/living.py @@ -265,10 +265,9 @@ class LivingProxyDb(ProxyDbBase): new_person.set_gender(person.get_gender()) new_person.set_gramps_id(person.get_gramps_id()) new_person.set_handle(person.get_handle()) + new_person.set_change_time(person.get_change_time()) new_person.set_family_handle_list(person.get_family_handle_list()) new_person.set_parent_family_handle_list( person.get_parent_family_handle_list() ) return new_person - - diff --git a/src/gen/proxy/private.py b/src/gen/proxy/private.py index 5184727f8..8197f3867 100644 --- a/src/gen/proxy/private.py +++ b/src/gen/proxy/private.py @@ -728,6 +728,7 @@ def sanitize_person(db, person): new_person.set_gender(person.get_gender()) new_person.set_gramps_id(person.get_gramps_id()) new_person.set_handle(person.get_handle()) + new_person.set_change_time(person.get_change_time()) # copy names if not private name = person.get_primary_name() @@ -818,6 +819,7 @@ def sanitize_source(db, source): new_source.set_abbreviation(source.get_abbreviation()) new_source.set_gramps_id(source.get_gramps_id()) new_source.set_handle(source.get_handle()) + new_source.set_change_time(source.get_change_time()) new_source.set_marker(source.get_marker()) new_source.set_data_map(source.get_data_map()) @@ -854,6 +856,7 @@ def sanitize_media(db, media): new_media.set_description(media.get_description()) new_media.set_gramps_id(media.get_gramps_id()) new_media.set_handle(media.get_handle()) + new_media.set_change_time(media.get_change_time()) new_media.set_date_object(media.get_date_object()) new_media.set_marker(media.get_marker()) @@ -882,6 +885,7 @@ def sanitize_place(db, place): new_place.set_title(place.get_title()) new_place.set_gramps_id(place.get_gramps_id()) new_place.set_handle(place.get_handle()) + new_place.set_change_time(place.get_change_time()) new_place.set_longitude(place.get_longitude()) new_place.set_latitude(place.get_latitude()) new_place.set_main_location(place.get_main_location()) @@ -917,6 +921,7 @@ def sanitize_event(db, event): new_event.set_handle(event.get_handle()) new_event.set_date_object(event.get_date_object()) new_event.set_marker(event.get_marker()) + new_event.set_change_time(event.get_change_time()) copy_source_ref_list(db, event, new_event) copy_notes(db, event, new_event) @@ -950,6 +955,7 @@ def sanitize_family(db, family): new_family.set_handle(family.get_handle()) new_family.set_marker(family.get_marker()) new_family.set_relationship(family.get_relationship()) + new_family.set_change_time(family.get_change_time()) # Copy the father handle. father_handle = family.get_father_handle() @@ -1017,6 +1023,7 @@ def sanitize_repository(db, repository): new_repository.set_name(repository.get_name()) new_repository.set_gramps_id(repository.get_gramps_id()) new_repository.set_handle(repository.get_handle()) + new_repository.set_change_time(repository.get_change_time()) new_repository.set_marker(repository.get_marker()) copy_notes(db, repository, new_repository)