From 2ed5ca6390f2c02350ccf87bb3197cd5acc426a1 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 6 May 2003 04:48:51 +0000 Subject: [PATCH] More Import cleanups svn: r1498 --- gramps2/src/ReadXML.py | 13 +++++++------ gramps2/src/plugins/ReadNative.py | 2 +- gramps2/src/plugins/ReadPkg.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index 50ed9ba33..1a775106a 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -114,17 +114,18 @@ def importData(database, filename, callback): xml_file.close() # Rename media files if they were conflicting with existing ones - #print parser.MediaFileMap ObjectMap = parser.db.getObjectMap() for OldMediaID in parser.MediaFileMap.keys(): NewMediaID = parser.MediaFileMap[OldMediaID] - oldfile = ObjectMap[NewMediaID].getPath() - oldpath = os.path.dirname(oldfile) - (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) - ObjectMap[NewMediaID].setLocal(1) - if NewMediaID != OldMediaID: + if NewMediaID != OldMediaID: + oldfile = ObjectMap[NewMediaID].getPath() + oldpath = os.path.dirname(oldfile) + (junk,oldext) = os.path.splitext(os.path.basename(oldfile)) + oldfile = os.path.join( basefile, OldMediaID + oldext ) newfile = os.path.join( basefile, NewMediaID + oldext ) os.rename(oldfile,newfile) + ObjectMap[NewMediaID].setPath(os.path.join(oldpath,NewMediaID+oldext)) + ObjectMap[NewMediaID].setLocal(1) return 1 diff --git a/gramps2/src/plugins/ReadNative.py b/gramps2/src/plugins/ReadNative.py index f93a14043..849adf304 100644 --- a/gramps2/src/plugins/ReadNative.py +++ b/gramps2/src/plugins/ReadNative.py @@ -123,7 +123,7 @@ class ReadNative: for filename in files: oldfile = os.path.join(tmpdir_path,filename) newfile = os.path.join(dbdir_path,filename) - if filename != const.xmlFile: + if filename not in [const.xmlFile,const.xmlFile+'.bak']: shutil.copy2( oldfile, newfile ) os.remove( oldfile ) diff --git a/gramps2/src/plugins/ReadPkg.py b/gramps2/src/plugins/ReadPkg.py index cefc089cc..576c64127 100644 --- a/gramps2/src/plugins/ReadPkg.py +++ b/gramps2/src/plugins/ReadPkg.py @@ -123,7 +123,7 @@ class ReadPkg: for filename in files: oldfile = os.path.join(tmpdir_path,filename) newfile = os.path.join(dbdir_path,filename) - if filename != const.xmlFile: + if filename not in [const.xmlFile,const.xmlFile+'.bak']: shutil.copy2( oldfile, newfile ) os.remove( oldfile )