From 01fc3372560940fd3ba42605e67e886e471affcb Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sat, 28 Feb 2004 19:34:29 +0000 Subject: [PATCH] * src/GrampsParser.py (start_childof): Call add_parent_family_id() with three arguments, instead of a tuple. * src/ReadXML.py: Comment out renaming lost media objects for now. * src/RelLib.py (find_place_no_conflicts, find_family_no_conflicts): Use str(idVal). svn: r2926 --- gramps2/ChangeLog | 7 ++++ gramps2/src/GrampsParser.py | 2 +- gramps2/src/ReadXML.py | 76 ++++++++++++++++++------------------- gramps2/src/RelLib.py | 24 ++++++------ 4 files changed, 58 insertions(+), 51 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5e1a626a3..a6ce2a010 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2004-02-28 Alex Roitman + * src/GrampsParser.py (start_childof): Call add_parent_family_id() + with three arguments, instead of a tuple. + * src/ReadXML.py: Comment out renaming lost media objects for now. + * src/RelLib.py (find_place_no_conflicts, + find_family_no_conflicts): Use str(idVal). + 2004-02-28 Don Allingham * src/gramps_main.py: switch to DB as default, remove save option * src/RelLib.py: setup DB environment better diff --git a/gramps2/src/GrampsParser.py b/gramps2/src/GrampsParser.py index 0eb1b9d10..a8bd3f62d 100644 --- a/gramps2/src/GrampsParser.py +++ b/gramps2/src/GrampsParser.py @@ -946,7 +946,7 @@ class GrampsImportParser(GrampsParser): frel = attrs["frel"] else: frel = "Birth" - self.person.add_parent_family_id((family.get_id(),mrel,frel)) + self.person.add_parent_family_id(family.get_id(),mrel,frel) def start_parentin(self,attrs): self.person.add_family_id(attrs["ref"]) diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index 9bb138932..d4c2677be 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -203,44 +203,44 @@ def importData(database, filename, callback,cl=0): #------------------------------------------------------------------------- - # Rename media files if they were conflicting with existing ones - ObjectMap = database.get_object_map() - newpath = database.get_save_path() - for OldMediaID in parser.MediaFileMap.keys(): - NewMediaID = parser.MediaFileMap[OldMediaID] - oldfile = ObjectMap[NewMediaID].get_path() - (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) - oldfile = os.path.join(basefile,OldMediaID+oldext) - newfile = os.path.join(newpath,NewMediaID+oldext) - ObjectMap[NewMediaID].set_path(newfile) - ObjectMap[NewMediaID].setLocal(1) - try: - shutil.copyfile(oldfile,newfile) - try: - shutil.copystat(oldfile,newfile) - except: - pass - except: - if cl: - print "Warning: media file %s was not found," \ - % os.path.basename(oldfile), "so it was ignored." - else: - # File is lost => ask what to do (if we were not told yet) - if missmedia_action == 0: - mmd = MissingMediaDialog(_("Media object could not be found"), - _("%(file_name)s is referenced in the database, but no longer exists. " - "The file may have been deleted or moved to a different location. " - "You may choose to either remove the reference from the database, " - "keep the reference to the missing file, or select a new file." - ) % { 'file_name' : oldfile }, - remove_clicked, leave_clicked, select_clicked) - missmedia_action = mmd.default_action - elif missmedia_action == 1: - remove_clicked() - elif missmedia_action == 2: - leave_clicked() - elif missmedia_action == 3: - select_clicked() +# # Rename media files if they were conflicting with existing ones +# ObjectMap = database.get_object_map() +# newpath = database.get_save_path() +# for OldMediaID in parser.MediaFileMap.keys(): +# NewMediaID = parser.MediaFileMap[OldMediaID] +# oldfile = ObjectMap[NewMediaID].get_path() +# (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) +# oldfile = os.path.join(basefile,OldMediaID+oldext) +# newfile = os.path.join(newpath,NewMediaID+oldext) +# ObjectMap[NewMediaID].set_path(newfile) +# ObjectMap[NewMediaID].setLocal(1) +# try: +# shutil.copyfile(oldfile,newfile) +# try: +# shutil.copystat(oldfile,newfile) +# except: +# pass +# except: +# if cl: +# print "Warning: media file %s was not found," \ +# % os.path.basename(oldfile), "so it was ignored." +# else: +# # File is lost => ask what to do (if we were not told yet) +# if missmedia_action == 0: +# mmd = MissingMediaDialog(_("Media object could not be found"), +# _("%(file_name)s is referenced in the database, but no longer exists. " +# "The file may have been deleted or moved to a different location. " +# "You may choose to either remove the reference from the database, " +# "keep the reference to the missing file, or select a new file." +# ) % { 'file_name' : oldfile }, +# remove_clicked, leave_clicked, select_clicked) +# missmedia_action = mmd.default_action +# elif missmedia_action == 1: +# remove_clicked() +# elif missmedia_action == 2: +# leave_clicked() +# elif missmedia_action == 3: +# select_clicked() del parser return 1 diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 0e4ceaf5f..a1472d0ad 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -2899,17 +2899,17 @@ class GrampsDB: idVal - external ID number map - map build by findPlace of external to gramp's IDs""" - if map.has_key(idVal): + if map.has_key(str(idVal)): place = Place() - data = self.place_map[map[idVal]] + data = self.place_map[map[str(idVal)]] place.unserialize(data) else: place = Place() - if self.place_map.has_key(idVal): - map[idVal] = self.add_place(place) + if self.place_map.has_key(str(idVal)): + map[str(idVal)] = self.add_place(place) else: - place.set_id(idVal) - map[idVal] = self.add_place_as(place) + place.set_id(str(idVal)) + map[str(idVal)] = self.add_place_as(place) self.place_map.put(str(idVal),place.serialize()) return place @@ -3082,7 +3082,7 @@ class GrampsDB: person = Person() if map.has_key(idVal): - person.serialize(self.person_map.get(str(map[idVal]))) + person.unserialize(self.person_map.get(str(map[idVal]))) else: if self.person_map.get(str(idVal)): map[idVal] = self.add_person(person) @@ -3100,15 +3100,15 @@ class GrampsDB: idVal - external ID number map - map build by findFamily of external to gramp's IDs""" - if map.has_key(idVal): + if map.has_key(str(idVal)): family = Family() - family.unserialize(self.family_map.get(str(map[idVal]))) + family.unserialize(self.family_map.get(str(map[str(idVal)]))) else: - if self.family_map.has_key(idVal): + if self.family_map.has_key(str(idVal)): family = self.new_family() else: - family = self.new_family_no_map(idVal) - map[idVal] = family.get_id() + family = self.new_family_no_map(str(idVal)) + map[str(idVal)] = family.get_id() return family def find_source_no_conflicts(self,idVal,map):