From 2d8868063d1a33d1056e787788f3552b78b2d492 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 12 Sep 2006 03:41:09 +0000 Subject: [PATCH] * src/GrampsDb/_ReadXML.py: use os.path.isabs * src/ViewManager.py: path seperator fixes * src/GrampsDb/_ReadGedcom.py: path seperator fixes * src/GrampsDb/_ReadXML.py: path seperator fixes svn: r7314 --- ChangeLog | 4 ++++ src/GrampsDb/_ReadXML.py | 29 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d73bc666b..1cd90fe14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,13 @@ 2006-09-11 Don Allingham + * src/GrampsDb/_ReadXML.py: use os.path.isabs * src/GrampsDb/_ReadXML.py: don't assume that os.path.sep is the first element of an absolute path. Many not be true on some legacy operating systems. 2006-09-10 Don Allingham + * src/ViewManager.py: path seperator fixes + * src/GrampsDb/_ReadGedcom.py: path seperator fixes + * src/GrampsDb/_ReadXML.py: path seperator fixes * src/DisplayTabls/_PersonEmbedList.py: enable dnd with people for associations diff --git a/src/GrampsDb/_ReadXML.py b/src/GrampsDb/_ReadXML.py index 96571dada..8288b2d5e 100644 --- a/src/GrampsDb/_ReadXML.py +++ b/src/GrampsDb/_ReadXML.py @@ -175,15 +175,15 @@ def importData(database, filename, callback=None,cl=0,use_trans=False): for m_id in database.get_media_object_handles(): mobject = database.get_object_from_handle(m_id) - drive,oldfile = os.path.splitdrive(mobject.get_path()) - if not drive and oldfile and oldfile[0] != os.path.sep: + oldfile = mobject.get_path() + if oldfile and os.path.isabs(oldfile): if first: os.mkdir(img_dir) first = 0 - newfile = "%s%s%s" % (img_dir,os.path.sep,oldfile) + newfile = os.path.join(img_dir,oldfile) try: - oldfilename = "%s%s%s" % (basefile,os.path.sep,oldfile) + oldfilename = os.path.join(basefile,oldfile) shutil.copyfile(oldfilename,newfile) try: shutil.copystat(oldfilename,newfile) @@ -1000,11 +1000,11 @@ class GrampsParser(UpdateCallback): def start_file(self,attrs): self.object.mime = attrs['mime'] self.object.desc = attrs['description'] - drive,src = os.path.splitdrive(attrs["src"]) + src = attrs["src"] if src: - if not drive and src[0] != os.path.sep: + if os.path.isabs(src): fullpath = os.path.abspath(self.filename) - src = os.path.dirname(fullpath) + os.path.sep + src + src = os.path.join(os.path.dirname(fullpath),src) self.object.path = src def start_childof(self,attrs): @@ -1179,11 +1179,10 @@ class GrampsParser(UpdateCallback): # the old format of self.object.mime = attrs.get('mime','') self.object.desc = attrs.get('description','') - drive,src = os.path.splitdrive(attrs.get("src",'')) - if src: - if not drive and src[0] != os.path.sep: - fullpath = os.path.abspath(self.filename) - src = os.path.dirname(fullpath) + os.path.sep + src + src = attrs.get("src",'') + if src and os.path.isabs(src): + fullpath = os.path.abspath(self.filename) + src = os.path.join(os.path.dirname(fullpath),src) self.object.path = src def start_repo(self,attrs): @@ -1226,9 +1225,9 @@ class GrampsParser(UpdateCallback): elif key == "priv": self.pref.set_privacy(int(attrs[key])) elif key == "src": - drive,src = os.path.splitdrive(attrs["src"]) - if not drive and src[0] != os.path.sep: - self.photo.set_path("%s%s%s"%(self.base,os.path.sep,src)) + src = attrs["src"] + if os.path.isabs(src): + self.photo.set_path(os.path.join(self.base,src)) else: self.photo.set_path(src) else: