* 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
This commit is contained in:
Don Allingham 2006-09-12 03:41:09 +00:00
parent c639895996
commit 2d8868063d
2 changed files with 18 additions and 15 deletions

View File

@ -1,9 +1,13 @@
2006-09-11 Don Allingham <don@gramps-project.org> 2006-09-11 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadXML.py: use os.path.isabs
* src/GrampsDb/_ReadXML.py: don't assume that os.path.sep is the * 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 first element of an absolute path. Many not be true on some legacy
operating systems. operating systems.
2006-09-10 Don Allingham <don@gramps-project.org> 2006-09-10 Don Allingham <don@gramps-project.org>
* 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 * src/DisplayTabls/_PersonEmbedList.py: enable dnd with people for
associations associations

View File

@ -175,15 +175,15 @@ def importData(database, filename, callback=None,cl=0,use_trans=False):
for m_id in database.get_media_object_handles(): for m_id in database.get_media_object_handles():
mobject = database.get_object_from_handle(m_id) mobject = database.get_object_from_handle(m_id)
drive,oldfile = os.path.splitdrive(mobject.get_path()) oldfile = mobject.get_path()
if not drive and oldfile and oldfile[0] != os.path.sep: if oldfile and os.path.isabs(oldfile):
if first: if first:
os.mkdir(img_dir) os.mkdir(img_dir)
first = 0 first = 0
newfile = "%s%s%s" % (img_dir,os.path.sep,oldfile) newfile = os.path.join(img_dir,oldfile)
try: try:
oldfilename = "%s%s%s" % (basefile,os.path.sep,oldfile) oldfilename = os.path.join(basefile,oldfile)
shutil.copyfile(oldfilename,newfile) shutil.copyfile(oldfilename,newfile)
try: try:
shutil.copystat(oldfilename,newfile) shutil.copystat(oldfilename,newfile)
@ -1000,11 +1000,11 @@ class GrampsParser(UpdateCallback):
def start_file(self,attrs): def start_file(self,attrs):
self.object.mime = attrs['mime'] self.object.mime = attrs['mime']
self.object.desc = attrs['description'] self.object.desc = attrs['description']
drive,src = os.path.splitdrive(attrs["src"]) src = attrs["src"]
if src: if src:
if not drive and src[0] != os.path.sep: if os.path.isabs(src):
fullpath = os.path.abspath(self.filename) 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 self.object.path = src
def start_childof(self,attrs): def start_childof(self,attrs):
@ -1179,11 +1179,10 @@ class GrampsParser(UpdateCallback):
# the old format of <object src="blah"...> # the old format of <object src="blah"...>
self.object.mime = attrs.get('mime','') self.object.mime = attrs.get('mime','')
self.object.desc = attrs.get('description','') self.object.desc = attrs.get('description','')
drive,src = os.path.splitdrive(attrs.get("src",'')) src = attrs.get("src",'')
if src: if src and os.path.isabs(src):
if not drive and src[0] != os.path.sep:
fullpath = os.path.abspath(self.filename) 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 self.object.path = src
def start_repo(self,attrs): def start_repo(self,attrs):
@ -1226,9 +1225,9 @@ class GrampsParser(UpdateCallback):
elif key == "priv": elif key == "priv":
self.pref.set_privacy(int(attrs[key])) self.pref.set_privacy(int(attrs[key]))
elif key == "src": elif key == "src":
drive,src = os.path.splitdrive(attrs["src"]) src = attrs["src"]
if not drive and src[0] != os.path.sep: if os.path.isabs(src):
self.photo.set_path("%s%s%s"%(self.base,os.path.sep,src)) self.photo.set_path(os.path.join(self.base,src))
else: else:
self.photo.set_path(src) self.photo.set_path(src)
else: else: