Fix Export Web Family Tree for errors on file write (#525)
Fixes #10364
This commit is contained in:
parent
e8489bf53c
commit
286289aaf7
@ -48,6 +48,9 @@ log = logging.getLogger(".WriteFtree")
|
|||||||
from gramps.gen.utils.alive import probably_alive
|
from gramps.gen.utils.alive import probably_alive
|
||||||
from gramps.gui.plug.export import WriterOptionBox
|
from gramps.gui.plug.export import WriterOptionBox
|
||||||
from gramps.gui.glade import Glade
|
from gramps.gui.glade import Glade
|
||||||
|
from gramps.gui.dialog import ErrorDialog
|
||||||
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
|
_ = glocale.translation.gettext
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -121,8 +124,16 @@ class FtreeWriter(object):
|
|||||||
id_map[key] = n
|
id_map[key] = n
|
||||||
id_name[key] = get_name(pn, sn, count)
|
id_name[key] = get_name(pn, sn, count)
|
||||||
|
|
||||||
f = open(self.filename,"w")
|
try:
|
||||||
|
with open(self.filename, "w", encoding='utf_8') as file:
|
||||||
|
return self._export_data(file, id_name, id_map)
|
||||||
|
except IOError as msg:
|
||||||
|
msg2 = _("Could not create %s") % self.filename
|
||||||
|
# cannot set parent below because gramps42 doesn't have it...
|
||||||
|
ErrorDialog(msg2, str(msg))
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _export_data(self, file, id_name, id_map):
|
||||||
for key in self.plist:
|
for key in self.plist:
|
||||||
self.update()
|
self.update()
|
||||||
p = self.db.get_person_from_handle(key)
|
p = self.db.get_person_from_handle(key)
|
||||||
@ -171,10 +182,9 @@ class FtreeWriter(object):
|
|||||||
else:
|
else:
|
||||||
dates = ""
|
dates = ""
|
||||||
|
|
||||||
f.write('%s;%s;%s;%s;%s;%s\n' % (name, father, mother, email, web,
|
file.write('%s;%s;%s;%s;%s;%s\n' %
|
||||||
dates))
|
(name, father, mother, email, web, dates))
|
||||||
|
|
||||||
f.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def fdate(val):
|
def fdate(val):
|
||||||
|
Loading…
Reference in New Issue
Block a user