svn: r7309

This commit is contained in:
Don Allingham 2006-09-11 03:07:17 +00:00
parent 0b6095fdc8
commit 61b9f23c9e
3 changed files with 14 additions and 14 deletions

View File

@ -742,7 +742,7 @@ class GedcomParser(UpdateCallback):
def find_file(self,fullname,altpath): def find_file(self,fullname,altpath):
tries = [] tries = []
fullname = fullname.replace('\\','/') fullname = fullname.replace('\\',os.path.sep)
tries.append(fullname) tries.append(fullname)
if os.path.isfile(fullname): if os.path.isfile(fullname):
@ -987,7 +987,7 @@ class GedcomParser(UpdateCallback):
(ok,path) = self.find_file(matches[2], self.dir_path) (ok,path) = self.find_file(matches[2], self.dir_path)
if not ok: if not ok:
self.warn(_("Could not import %s") % filename) self.warn(_("Could not import %s") % filename)
path = filename.replace('\\','/') path = filename.replace('\\',os.path.sep)
def func_obje_ignore(self, matches, media, level): def func_obje_ignore(self, matches, media, level):
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
@ -2663,7 +2663,7 @@ class GedcomParser(UpdateCallback):
(ok,path) = self.find_file(filename,self.dir_path) (ok,path) = self.find_file(filename,self.dir_path)
if not ok: if not ok:
self.warn(_("Could not import %s") % filename) self.warn(_("Could not import %s") % filename)
path = filename.replace('\\','/') path = filename.replace('\\',os.path.sep)
photo_handle = self.media_map.get(path) photo_handle = self.media_map.get(path)
if photo_handle == None: if photo_handle == None:
photo = RelLib.MediaObject() photo = RelLib.MediaObject()

View File

@ -170,20 +170,20 @@ def importData(database, filename, callback=None,cl=0,use_trans=False):
# copy all local images into <database>.images directory # copy all local images into <database>.images directory
db_dir = os.path.abspath(os.path.dirname(database.get_save_path())) db_dir = os.path.abspath(os.path.dirname(database.get_save_path()))
db_base = os.path.basename(database.get_save_path()) db_base = os.path.basename(database.get_save_path())
img_dir = "%s/%s.images" % (db_dir,db_base) img_dir = "%s%s%s.images" % (db_dir,os.path.sep,db_base)
first = not os.path.exists(img_dir) first = not os.path.exists(img_dir)
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)
oldfile = mobject.get_path() oldfile = mobject.get_path()
if oldfile and oldfile[0] != '/': if oldfile and oldfile[0] != '//':
if first: if first:
os.mkdir(img_dir) os.mkdir(img_dir)
first = 0 first = 0
newfile = "%s/%s" % (img_dir,oldfile) newfile = "%s%s%s" % (img_dir,os.path.sep,oldfile)
try: try:
oldfilename = "%s/%s" % (basefile,oldfile) oldfilename = "%s%s%s" % (basefile,os.path.sep,oldfile)
shutil.copyfile(oldfilename,newfile) shutil.copyfile(oldfilename,newfile)
try: try:
shutil.copystat(oldfilename,newfile) shutil.copystat(oldfilename,newfile)
@ -1002,9 +1002,9 @@ class GrampsParser(UpdateCallback):
self.object.desc = attrs['description'] self.object.desc = attrs['description']
src = attrs["src"] src = attrs["src"]
if src: if src:
if src[0] != '/': if src[0] != os.path.sep:
fullpath = os.path.abspath(self.filename) fullpath = os.path.abspath(self.filename)
src = os.path.dirname(fullpath) + '/' + src src = os.path.dirname(fullpath) + os.path.sep + src
self.object.path = src self.object.path = src
def start_childof(self,attrs): def start_childof(self,attrs):
@ -1181,9 +1181,9 @@ class GrampsParser(UpdateCallback):
self.object.desc = attrs.get('description','') self.object.desc = attrs.get('description','')
src = attrs.get("src",'') src = attrs.get("src",'')
if src: if src:
if src[0] != '/': if src[0] != os.path.sep:
fullpath = os.path.abspath(self.filename) fullpath = os.path.abspath(self.filename)
src = os.path.dirname(fullpath) + '/' + src src = os.path.dirname(fullpath) + os.path.sep + src
self.object.path = src self.object.path = src
def start_repo(self,attrs): def start_repo(self,attrs):
@ -1227,8 +1227,8 @@ class GrampsParser(UpdateCallback):
self.pref.set_privacy(int(attrs[key])) self.pref.set_privacy(int(attrs[key]))
elif key == "src": elif key == "src":
src = attrs["src"] src = attrs["src"]
if src[0] != '/': if src[0] != os.path.sep:
self.photo.set_path("%s/%s" % (self.base,src)) self.photo.set_path("%s%s%s"%(self.base,os.path.sep,src))
else: else:
self.photo.set_path(src) self.photo.set_path(src)
else: else:

View File

@ -792,7 +792,7 @@ class ViewManager:
self.state.db.set_save_path(filename) self.state.db.set_save_path(filename)
# Update window title # Update window title
if filename[-1] == '/': if filename[-1] == os.path.sep:
filename = filename[:-1] filename = filename[:-1]
name = os.path.basename(filename) name = os.path.basename(filename)
if self.state.db.readonly: if self.state.db.readonly: