More Import cleanups
svn: r1498
This commit is contained in:
parent
a1374f76dc
commit
98bd0706eb
@ -114,17 +114,18 @@ def importData(database, filename, callback):
|
|||||||
xml_file.close()
|
xml_file.close()
|
||||||
|
|
||||||
# Rename media files if they were conflicting with existing ones
|
# Rename media files if they were conflicting with existing ones
|
||||||
#print parser.MediaFileMap
|
|
||||||
ObjectMap = parser.db.getObjectMap()
|
ObjectMap = parser.db.getObjectMap()
|
||||||
for OldMediaID in parser.MediaFileMap.keys():
|
for OldMediaID in parser.MediaFileMap.keys():
|
||||||
NewMediaID = parser.MediaFileMap[OldMediaID]
|
NewMediaID = parser.MediaFileMap[OldMediaID]
|
||||||
oldfile = ObjectMap[NewMediaID].getPath()
|
if NewMediaID != OldMediaID:
|
||||||
oldpath = os.path.dirname(oldfile)
|
oldfile = ObjectMap[NewMediaID].getPath()
|
||||||
(junk,oldext) = os.path.splitext(os.path.basename(oldfile))
|
oldpath = os.path.dirname(oldfile)
|
||||||
ObjectMap[NewMediaID].setLocal(1)
|
(junk,oldext) = os.path.splitext(os.path.basename(oldfile))
|
||||||
if NewMediaID != OldMediaID:
|
oldfile = os.path.join( basefile, OldMediaID + oldext )
|
||||||
newfile = os.path.join( basefile, NewMediaID + oldext )
|
newfile = os.path.join( basefile, NewMediaID + oldext )
|
||||||
os.rename(oldfile,newfile)
|
os.rename(oldfile,newfile)
|
||||||
|
ObjectMap[NewMediaID].setPath(os.path.join(oldpath,NewMediaID+oldext))
|
||||||
|
ObjectMap[NewMediaID].setLocal(1)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class ReadNative:
|
|||||||
for filename in files:
|
for filename in files:
|
||||||
oldfile = os.path.join(tmpdir_path,filename)
|
oldfile = os.path.join(tmpdir_path,filename)
|
||||||
newfile = os.path.join(dbdir_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 )
|
shutil.copy2( oldfile, newfile )
|
||||||
|
|
||||||
os.remove( oldfile )
|
os.remove( oldfile )
|
||||||
|
@ -123,7 +123,7 @@ class ReadPkg:
|
|||||||
for filename in files:
|
for filename in files:
|
||||||
oldfile = os.path.join(tmpdir_path,filename)
|
oldfile = os.path.join(tmpdir_path,filename)
|
||||||
newfile = os.path.join(dbdir_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 )
|
shutil.copy2( oldfile, newfile )
|
||||||
|
|
||||||
os.remove( oldfile )
|
os.remove( oldfile )
|
||||||
|
Loading…
Reference in New Issue
Block a user