* src/ArgHandler.py (parse_args): Switch from 'tgz' to 'gpkg'
for Gramps package; (handle_args): Use separate dir for all import-produced files; (cl_export): Convert media objects export to the database interface. * src/ReadXML.py (importData): Copy all local (with respect to the old XML way) media object files into <database>.images dir (created if did not previously exist). Change objects' paths accordingly; (GrampsParser.start_object): Do not modify path in the parser. This way we know that the objects are local. * src/RelLib.py (get_event_keys): Add method to GrampsDB class. * src/plugins/WritePkg.py (PackageWriter.export): Convert missing media handling to the database interface. svn: r3227
This commit is contained in:
@ -142,6 +142,32 @@ def importData(database, filename, callback,cl=0):
|
||||
|
||||
xml_file.close()
|
||||
|
||||
# copy all local images into <database>.images directory
|
||||
db_dir = os.path.abspath(os.path.dirname(database.get_save_path()))
|
||||
db_base = os.path.basename(database.get_save_path())
|
||||
img_dir = "%s/%s.images" % (db_dir,db_base)
|
||||
first = not os.path.exists(img_dir)
|
||||
|
||||
for m_id in database.get_object_keys():
|
||||
mobject = database.try_to_find_object_from_id(m_id)
|
||||
oldfile = mobject.get_path()
|
||||
if oldfile[0] != '/':
|
||||
if first:
|
||||
os.mkdir(img_dir)
|
||||
first = 0
|
||||
newfile = "%s/%s" % (img_dir,oldfile)
|
||||
try:
|
||||
oldfilename = "%s/%s" % (basefile,oldfile)
|
||||
shutil.copyfile(oldfilename,newfile)
|
||||
try:
|
||||
shutil.copystat(oldfilename,newfile)
|
||||
except:
|
||||
pass
|
||||
mobject.set_path(newfile)
|
||||
database.commit_media_object(mobject,None)
|
||||
except:
|
||||
pass
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# def remove_clicked():
|
||||
# # File is lost => remove all references and the object itself
|
||||
@ -690,10 +716,7 @@ class GrampsParser:
|
||||
self.object.set_description(attrs['description'])
|
||||
src = attrs["src"]
|
||||
if src:
|
||||
if src[0] != '/':
|
||||
self.object.set_path("%s/%s" % (self.base,src))
|
||||
else:
|
||||
self.object.set_path(src)
|
||||
self.object.set_path(src)
|
||||
|
||||
def stop_people(self,*tag):
|
||||
pass
|
||||
@ -1090,7 +1113,7 @@ class GrampsParser:
|
||||
self.tlist = []
|
||||
|
||||
try:
|
||||
f,self.func = self.func_map[tag]
|
||||
f,self.func = self.func_map[tag]
|
||||
if f:
|
||||
f(attrs)
|
||||
except KeyError:
|
||||
|
Reference in New Issue
Block a user