Merge pull request #124 from sam-m888/MissedWithOpen
Missed 'open' statements
This commit is contained in:
commit
cec4bd7a15
@ -265,9 +265,8 @@ class CLIManager(object):
|
|||||||
# Attempt to figure out the database title
|
# Attempt to figure out the database title
|
||||||
path = os.path.join(filename, "name.txt")
|
path = os.path.join(filename, "name.txt")
|
||||||
try:
|
try:
|
||||||
ifile = open(path)
|
with open(path) as ifile:
|
||||||
title = ifile.readline().strip()
|
title = ifile.readline().strip()
|
||||||
ifile.close()
|
|
||||||
except:
|
except:
|
||||||
title = filename
|
title = filename
|
||||||
|
|
||||||
|
@ -2027,9 +2027,8 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
"""
|
"""
|
||||||
filepath = os.path.join(self._directory, "name.txt")
|
filepath = os.path.join(self._directory, "name.txt")
|
||||||
try:
|
try:
|
||||||
name_file = open(filepath, "r")
|
with open(filepath, "r") as name_file:
|
||||||
name = name_file.readline().strip()
|
name = name_file.readline().strip()
|
||||||
name_file.close()
|
|
||||||
except (OSError, IOError) as msg:
|
except (OSError, IOError) as msg:
|
||||||
LOG.error(str(msg))
|
LOG.error(str(msg))
|
||||||
name = None
|
name = None
|
||||||
@ -2131,9 +2130,8 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
|||||||
if self._directory:
|
if self._directory:
|
||||||
filepath = os.path.join(self._directory, "bdbversion.txt")
|
filepath = os.path.join(self._directory, "bdbversion.txt")
|
||||||
try:
|
try:
|
||||||
name_file = open(filepath, "r", encoding='utf-8')
|
with open(filepath, "r", encoding='utf-8') as name_file:
|
||||||
version = name_file.readline().strip()
|
version = name_file.readline().strip()
|
||||||
name_file.close()
|
|
||||||
except (OSError, IOError) as msg:
|
except (OSError, IOError) as msg:
|
||||||
self.__log_error()
|
self.__log_error()
|
||||||
version = "(0, 0, 0)"
|
version = "(0, 0, 0)"
|
||||||
|
@ -118,28 +118,27 @@ class FilterList(object):
|
|||||||
return l.replace('"', '"')
|
return l.replace('"', '"')
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
f = open(self.file, 'w', encoding='utf8')
|
with open(self.file, 'w', encoding='utf8') as f:
|
||||||
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
|
||||||
f.write('<filters>\n')
|
f.write('<filters>\n')
|
||||||
for namespace in self.filter_namespaces:
|
for namespace in self.filter_namespaces:
|
||||||
f.write('<object type="%s">\n' % namespace)
|
f.write('<object type="%s">\n' % namespace)
|
||||||
filter_list = self.filter_namespaces[namespace]
|
filter_list = self.filter_namespaces[namespace]
|
||||||
for the_filter in filter_list:
|
for the_filter in filter_list:
|
||||||
f.write(' <filter name="%s"' %self.fix(the_filter.get_name()))
|
f.write(' <filter name="%s"' %self.fix(the_filter.get_name()))
|
||||||
f.write(' function="%s"' % the_filter.get_logical_op())
|
f.write(' function="%s"' % the_filter.get_logical_op())
|
||||||
if the_filter.invert:
|
if the_filter.invert:
|
||||||
f.write(' invert="1"')
|
f.write(' invert="1"')
|
||||||
comment = the_filter.get_comment()
|
comment = the_filter.get_comment()
|
||||||
if comment:
|
if comment:
|
||||||
f.write(' comment="%s"' % self.fix(comment))
|
f.write(' comment="%s"' % self.fix(comment))
|
||||||
f.write('>\n')
|
f.write('>\n')
|
||||||
for rule in the_filter.get_rules():
|
for rule in the_filter.get_rules():
|
||||||
f.write(' <rule class="%s" use_regex="%s">\n'
|
f.write(' <rule class="%s" use_regex="%s">\n'
|
||||||
% (rule.__class__.__name__, rule.use_regex))
|
% (rule.__class__.__name__, rule.use_regex))
|
||||||
for value in list(rule.values()):
|
for value in list(rule.values()):
|
||||||
f.write(' <arg value="%s"/>\n' % self.fix(value))
|
f.write(' <arg value="%s"/>\n' % self.fix(value))
|
||||||
f.write(' </rule>\n')
|
f.write(' </rule>\n')
|
||||||
f.write(' </filter>\n')
|
f.write(' </filter>\n')
|
||||||
f.write('</object>\n')
|
f.write('</object>\n')
|
||||||
f.write('</filters>\n')
|
f.write('</filters>\n')
|
||||||
f.close()
|
|
||||||
|
@ -1130,14 +1130,13 @@ class PluginRegister(object):
|
|||||||
lenpd = len(self.__plugindata)
|
lenpd = len(self.__plugindata)
|
||||||
full_filename = os.path.join(dir, filename)
|
full_filename = os.path.join(dir, filename)
|
||||||
try:
|
try:
|
||||||
fd = open(full_filename, "r", encoding='utf-8')
|
with open(full_filename, "r", encoding='utf-8') as fd:
|
||||||
|
stream = fd.read()
|
||||||
except Exception as msg:
|
except Exception as msg:
|
||||||
print(_('ERROR: Failed reading plugin registration %(filename)s') % \
|
print(_('ERROR: Failed reading plugin registration %(filename)s') % \
|
||||||
{'filename' : filename})
|
{'filename' : filename})
|
||||||
print(msg)
|
print(msg)
|
||||||
continue
|
continue
|
||||||
stream = fd.read()
|
|
||||||
fd.close()
|
|
||||||
if os.path.exists(os.path.join(os.path.dirname(full_filename),
|
if os.path.exists(os.path.join(os.path.dirname(full_filename),
|
||||||
'locale')):
|
'locale')):
|
||||||
try:
|
try:
|
||||||
|
@ -527,9 +527,8 @@ class BookList(object):
|
|||||||
try:
|
try:
|
||||||
p = make_parser()
|
p = make_parser()
|
||||||
p.setContentHandler(BookParser(self, self.dbase))
|
p.setContentHandler(BookParser(self, self.dbase))
|
||||||
the_file = open(self.file)
|
with open(self.file) as the_file:
|
||||||
p.parse(the_file)
|
p.parse(the_file)
|
||||||
the_file.close()
|
|
||||||
except (IOError, OSError, ValueError, SAXParseException, KeyError,
|
except (IOError, OSError, ValueError, SAXParseException, KeyError,
|
||||||
AttributeError):
|
AttributeError):
|
||||||
pass
|
pass
|
||||||
|
@ -83,9 +83,8 @@ class PageSizeParser(handler.ContentHandler):
|
|||||||
try:
|
try:
|
||||||
parser = make_parser()
|
parser = make_parser()
|
||||||
parser.setContentHandler(PageSizeParser(paper_sizes))
|
parser.setContentHandler(PageSizeParser(paper_sizes))
|
||||||
the_file = open(PAPERSIZE)
|
with open(PAPERSIZE) as the_file:
|
||||||
parser.parse(the_file)
|
parser.parse(the_file)
|
||||||
the_file.close()
|
|
||||||
paper_sizes.append(PaperSize("Custom Size", -1, -1)) # always in English
|
paper_sizes.append(PaperSize("Custom Size", -1, -1)) # always in English
|
||||||
except (IOError, OSError, SAXParseException):
|
except (IOError, OSError, SAXParseException):
|
||||||
paper_sizes = [
|
paper_sizes = [
|
||||||
|
@ -333,35 +333,33 @@ class ConfigManager(object):
|
|||||||
if exp.errno != errno.EEXIST:
|
if exp.errno != errno.EEXIST:
|
||||||
raise
|
raise
|
||||||
try:
|
try:
|
||||||
key_file = open(filename, "w", encoding="utf-8")
|
with open(filename, "w", encoding="utf-8") as key_file:
|
||||||
|
key_file.write(";; Gramps key file\n")
|
||||||
|
key_file.write((";; Automatically created at %s" %
|
||||||
|
time.strftime("%Y/%m/%d %H:%M:%S")) + "\n\n")
|
||||||
|
sections = sorted(self.data)
|
||||||
|
for section in sections:
|
||||||
|
key_file.write(("[%s]\n") % section)
|
||||||
|
keys = sorted(self.data[section])
|
||||||
|
for key in keys:
|
||||||
|
value = self.data[section][key]
|
||||||
|
# If it has a default:
|
||||||
|
if self.has_default("%s.%s" % (section, key)):
|
||||||
|
if value == self.get_default("%s.%s" % (section, key)):
|
||||||
|
default = ";;"
|
||||||
|
else:
|
||||||
|
default = ""
|
||||||
|
if isinstance(value, int):
|
||||||
|
value = int(value)
|
||||||
|
key_file.write(("%s%s=%s\n")% (default,
|
||||||
|
key,
|
||||||
|
repr(value)))
|
||||||
|
key_file.write("\n")
|
||||||
|
# else, no filename given; nothing to save so do nothing quietly
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
logging.warn("Failed to open %s because %s",
|
logging.warn("Failed to open %s because %s",
|
||||||
filename, str(err))
|
filename, str(err))
|
||||||
return;
|
return
|
||||||
|
|
||||||
key_file.write(";; Gramps key file\n")
|
|
||||||
key_file.write((";; Automatically created at %s" %
|
|
||||||
time.strftime("%Y/%m/%d %H:%M:%S")) + "\n\n")
|
|
||||||
sections = sorted(self.data)
|
|
||||||
for section in sections:
|
|
||||||
key_file.write(("[%s]\n") % section)
|
|
||||||
keys = sorted(self.data[section])
|
|
||||||
for key in keys:
|
|
||||||
value = self.data[section][key]
|
|
||||||
# If it has a default:
|
|
||||||
if self.has_default("%s.%s" % (section, key)):
|
|
||||||
if value == self.get_default("%s.%s" % (section, key)):
|
|
||||||
default = ";;"
|
|
||||||
else:
|
|
||||||
default = ""
|
|
||||||
if isinstance(value, int):
|
|
||||||
value = int(value)
|
|
||||||
key_file.write(("%s%s=%s\n")% (default,
|
|
||||||
key,
|
|
||||||
repr(value)))
|
|
||||||
key_file.write("\n")
|
|
||||||
key_file.close()
|
|
||||||
# else, no filename given; nothing to save so do nothing quietly
|
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
"""
|
"""
|
||||||
|
@ -102,9 +102,8 @@ class GrampsAboutDialog(Gtk.AboutDialog):
|
|||||||
self.set_artists(artists.split('\n'))
|
self.set_artists(artists.split('\n'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ifile = open(LICENSE_FILE, "r")
|
with open(LICENSE_FILE, "r") as ifile:
|
||||||
self.set_license(ifile.read().replace('\x0c', ''))
|
self.set_license(ifile.read().replace('\x0c', ''))
|
||||||
ifile.close()
|
|
||||||
except IOError:
|
except IOError:
|
||||||
self.set_license("License file is missing")
|
self.set_license("License file is missing")
|
||||||
|
|
||||||
@ -222,9 +221,8 @@ def _get_authors():
|
|||||||
parser = make_parser()
|
parser = make_parser()
|
||||||
parser.setContentHandler(AuthorParser(authors, contributors))
|
parser.setContentHandler(AuthorParser(authors, contributors))
|
||||||
|
|
||||||
authors_file = open(AUTHORS_FILE, encoding='utf-8')
|
with open(AUTHORS_FILE, encoding='utf-8') as authors_file:
|
||||||
parser.parse(authors_file)
|
parser.parse(authors_file)
|
||||||
authors_file.close()
|
|
||||||
|
|
||||||
authors_text = [authors, contributors]
|
authors_text = [authors, contributors]
|
||||||
|
|
||||||
|
@ -691,9 +691,8 @@ class DbManager(CLIDbManager):
|
|||||||
node = self.model.get_iter(path)
|
node = self.model.get_iter(path)
|
||||||
filename = self.model.get_value(node, FILE_COL)
|
filename = self.model.get_value(node, FILE_COL)
|
||||||
try:
|
try:
|
||||||
name_file = open(filename, "r")
|
with open(filename, "r") as name_file:
|
||||||
file_name_to_delete=name_file.read()
|
file_name_to_delete=name_file.read()
|
||||||
name_file.close()
|
|
||||||
remove_filename(file_name_to_delete)
|
remove_filename(file_name_to_delete)
|
||||||
directory = self.data_to_delete[1]
|
directory = self.data_to_delete[1]
|
||||||
for (top, dirs, files) in os.walk(directory):
|
for (top, dirs, files) in os.walk(directory):
|
||||||
|
@ -218,50 +218,49 @@ class GrampletBar(Gtk.Notebook):
|
|||||||
"""
|
"""
|
||||||
filename = self.configfile
|
filename = self.configfile
|
||||||
try:
|
try:
|
||||||
fp = open(filename, "w", encoding='utf-8')
|
with open(filename, "w", encoding='utf-8') as fp:
|
||||||
|
fp.write(";; Gramplet bar configuration file" + NL)
|
||||||
|
fp.write((";; Automatically created at %s" %
|
||||||
|
time.strftime("%Y/%m/%d %H:%M:%S")) + NL + NL)
|
||||||
|
fp.write("[Bar Options]" + NL)
|
||||||
|
fp.write(("visible=%s" + NL) % self.get_property('visible'))
|
||||||
|
fp.write(("page=%d" + NL) % self.get_current_page())
|
||||||
|
fp.write(NL)
|
||||||
|
|
||||||
|
if self.empty:
|
||||||
|
gramplet_list = []
|
||||||
|
else:
|
||||||
|
gramplet_list = [self.get_nth_page(page_num)
|
||||||
|
for page_num in range(self.get_n_pages())]
|
||||||
|
|
||||||
|
for page_num, gramplet in enumerate(gramplet_list):
|
||||||
|
opts = get_gramplet_options_by_name(gramplet.gname)
|
||||||
|
if opts is not None:
|
||||||
|
base_opts = opts.copy()
|
||||||
|
for key in base_opts:
|
||||||
|
if key in gramplet.__dict__:
|
||||||
|
base_opts[key] = gramplet.__dict__[key]
|
||||||
|
fp.write(("[%s]" + NL) % gramplet.gname)
|
||||||
|
for key in base_opts:
|
||||||
|
if key in ["content", "title", "tname", "row", "column",
|
||||||
|
"page", "version", "gramps"]: # don't save
|
||||||
|
continue
|
||||||
|
elif key == "data":
|
||||||
|
if not isinstance(base_opts["data"], (list, tuple)):
|
||||||
|
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
||||||
|
else:
|
||||||
|
cnt = 0
|
||||||
|
for item in base_opts["data"]:
|
||||||
|
fp.write(("data[%d]=%s" + NL) % (cnt, item))
|
||||||
|
cnt += 1
|
||||||
|
else:
|
||||||
|
fp.write(("%s=%s" + NL)% (key, base_opts[key]))
|
||||||
|
fp.write(("page=%d" + NL) % page_num)
|
||||||
|
fp.write(NL)
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
LOG.warning("Failed writing '%s'; gramplets not saved" % filename)
|
LOG.warning("Failed writing '%s'; gramplets not saved" % filename)
|
||||||
return
|
return
|
||||||
fp.write(";; Gramplet bar configuration file" + NL)
|
|
||||||
fp.write((";; Automatically created at %s" %
|
|
||||||
time.strftime("%Y/%m/%d %H:%M:%S")) + NL + NL)
|
|
||||||
fp.write("[Bar Options]" + NL)
|
|
||||||
fp.write(("visible=%s" + NL) % self.get_property('visible'))
|
|
||||||
fp.write(("page=%d" + NL) % self.get_current_page())
|
|
||||||
fp.write(NL)
|
|
||||||
|
|
||||||
if self.empty:
|
|
||||||
gramplet_list = []
|
|
||||||
else:
|
|
||||||
gramplet_list = [self.get_nth_page(page_num)
|
|
||||||
for page_num in range(self.get_n_pages())]
|
|
||||||
|
|
||||||
for page_num, gramplet in enumerate(gramplet_list):
|
|
||||||
opts = get_gramplet_options_by_name(gramplet.gname)
|
|
||||||
if opts is not None:
|
|
||||||
base_opts = opts.copy()
|
|
||||||
for key in base_opts:
|
|
||||||
if key in gramplet.__dict__:
|
|
||||||
base_opts[key] = gramplet.__dict__[key]
|
|
||||||
fp.write(("[%s]" + NL) % gramplet.gname)
|
|
||||||
for key in base_opts:
|
|
||||||
if key in ["content", "title", "tname", "row", "column",
|
|
||||||
"page", "version", "gramps"]: # don't save
|
|
||||||
continue
|
|
||||||
elif key == "data":
|
|
||||||
if not isinstance(base_opts["data"], (list, tuple)):
|
|
||||||
fp.write(("data[0]=%s" + NL) % base_opts["data"])
|
|
||||||
else:
|
|
||||||
cnt = 0
|
|
||||||
for item in base_opts["data"]:
|
|
||||||
fp.write(("data[%d]=%s" + NL) % (cnt, item))
|
|
||||||
cnt += 1
|
|
||||||
else:
|
|
||||||
fp.write(("%s=%s" + NL)% (key, base_opts[key]))
|
|
||||||
fp.write(("page=%d" + NL) % page_num)
|
|
||||||
fp.write(NL)
|
|
||||||
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
def set_active(self):
|
def set_active(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1187,82 +1187,81 @@ class GrampletPane(Gtk.ScrolledWindow):
|
|||||||
return # something is the matter
|
return # something is the matter
|
||||||
filename = self.configfile
|
filename = self.configfile
|
||||||
try:
|
try:
|
||||||
fp = open(filename, "w", encoding='utf-8')
|
with open(filename, "w", encoding='utf-8') as fp:
|
||||||
|
fp.write(";; Gramps gramplets file\n")
|
||||||
|
fp.write(";; Automatically created at %s" %
|
||||||
|
time.strftime("%Y/%m/%d %H:%M:%S\n\n"))
|
||||||
|
fp.write("[Gramplet View Options]\n")
|
||||||
|
fp.write("column_count=%d\n" % self.column_count)
|
||||||
|
fp.write("pane_position=%d\n" % self.pane_position)
|
||||||
|
fp.write("pane_orientation=%s\n\n" % self.pane_orientation)
|
||||||
|
# showing gramplets:
|
||||||
|
for col in range(self.column_count):
|
||||||
|
row = 0
|
||||||
|
for gframe in self.columns[col]:
|
||||||
|
gramplet = self.frame_map[str(gframe)]
|
||||||
|
opts = get_gramplet_options_by_name(gramplet.gname)
|
||||||
|
if opts is not None:
|
||||||
|
base_opts = opts.copy()
|
||||||
|
for key in base_opts:
|
||||||
|
if key in gramplet.__dict__:
|
||||||
|
base_opts[key] = gramplet.__dict__[key]
|
||||||
|
fp.write("[%s]\n" % gramplet.gname)
|
||||||
|
for key in base_opts:
|
||||||
|
if key == "content": continue
|
||||||
|
elif key == "title":
|
||||||
|
if gramplet.title_override:
|
||||||
|
fp.write("title=%s\n" % base_opts[key])
|
||||||
|
elif key == "tname": continue
|
||||||
|
elif key == "column": continue
|
||||||
|
elif key == "row": continue
|
||||||
|
elif key == "version": continue # code, don't save
|
||||||
|
elif key == "gramps": continue # code, don't save
|
||||||
|
elif key == "data":
|
||||||
|
if not isinstance(base_opts["data"], (list, tuple)):
|
||||||
|
fp.write("data[0]=%s\n" % base_opts["data"])
|
||||||
|
else:
|
||||||
|
cnt = 0
|
||||||
|
for item in base_opts["data"]:
|
||||||
|
fp.write("data[%d]=%s\n" % (cnt, item))
|
||||||
|
cnt += 1
|
||||||
|
else:
|
||||||
|
fp.write("%s=%s\n"% (key, base_opts[key]))
|
||||||
|
fp.write("column=%d\n" % col)
|
||||||
|
fp.write("row=%d\n\n" % row)
|
||||||
|
row += 1
|
||||||
|
for gramplet in self.detached_gramplets:
|
||||||
|
opts = get_gramplet_options_by_name(gramplet.gname)
|
||||||
|
if opts is not None:
|
||||||
|
base_opts = opts.copy()
|
||||||
|
for key in base_opts:
|
||||||
|
if key in gramplet.__dict__:
|
||||||
|
base_opts[key] = gramplet.__dict__[key]
|
||||||
|
fp.write("[%s]\n" % gramplet.title)
|
||||||
|
for key in base_opts:
|
||||||
|
if key == "content": continue
|
||||||
|
elif key == "title":
|
||||||
|
if "title_override" in base_opts:
|
||||||
|
base_opts["title"] = base_opts["title_override"]
|
||||||
|
fp.write("title=%s\n" % base_opts[key])
|
||||||
|
elif key == "tname": continue
|
||||||
|
elif key == "version": continue # code, don't save
|
||||||
|
elif key == "gramps": continue # code, don't save
|
||||||
|
elif key == "data":
|
||||||
|
if not isinstance(base_opts["data"], (list, tuple)):
|
||||||
|
fp.write("data[0]=%s\n" % base_opts["data"])
|
||||||
|
else:
|
||||||
|
cnt = 0
|
||||||
|
for item in base_opts["data"]:
|
||||||
|
fp.write("data[%d]=%s\n" % (cnt, item))
|
||||||
|
cnt += 1
|
||||||
|
else:
|
||||||
|
fp.write("%s=%s\n\n" % (key, base_opts[key]))
|
||||||
|
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
LOG.warn("Failed to open %s because $s; gramplets not saved",
|
LOG.warn("Failed to open %s because $s; gramplets not saved",
|
||||||
filename, str(err))
|
filename, str(err))
|
||||||
return
|
return
|
||||||
fp.write(";; Gramps gramplets file\n")
|
|
||||||
fp.write(";; Automatically created at %s" %
|
|
||||||
time.strftime("%Y/%m/%d %H:%M:%S\n\n"))
|
|
||||||
fp.write("[Gramplet View Options]\n")
|
|
||||||
fp.write("column_count=%d\n" % self.column_count)
|
|
||||||
fp.write("pane_position=%d\n" % self.pane_position)
|
|
||||||
fp.write("pane_orientation=%s\n\n" % self.pane_orientation)
|
|
||||||
# showing gramplets:
|
|
||||||
for col in range(self.column_count):
|
|
||||||
row = 0
|
|
||||||
for gframe in self.columns[col]:
|
|
||||||
gramplet = self.frame_map[str(gframe)]
|
|
||||||
opts = get_gramplet_options_by_name(gramplet.gname)
|
|
||||||
if opts is not None:
|
|
||||||
base_opts = opts.copy()
|
|
||||||
for key in base_opts:
|
|
||||||
if key in gramplet.__dict__:
|
|
||||||
base_opts[key] = gramplet.__dict__[key]
|
|
||||||
fp.write("[%s]\n" % gramplet.gname)
|
|
||||||
for key in base_opts:
|
|
||||||
if key == "content": continue
|
|
||||||
elif key == "title":
|
|
||||||
if gramplet.title_override:
|
|
||||||
fp.write("title=%s\n" % base_opts[key])
|
|
||||||
elif key == "tname": continue
|
|
||||||
elif key == "column": continue
|
|
||||||
elif key == "row": continue
|
|
||||||
elif key == "version": continue # code, don't save
|
|
||||||
elif key == "gramps": continue # code, don't save
|
|
||||||
elif key == "data":
|
|
||||||
if not isinstance(base_opts["data"], (list, tuple)):
|
|
||||||
fp.write("data[0]=%s\n" % base_opts["data"])
|
|
||||||
else:
|
|
||||||
cnt = 0
|
|
||||||
for item in base_opts["data"]:
|
|
||||||
fp.write("data[%d]=%s\n" % (cnt, item))
|
|
||||||
cnt += 1
|
|
||||||
else:
|
|
||||||
fp.write("%s=%s\n"% (key, base_opts[key]))
|
|
||||||
fp.write("column=%d\n" % col)
|
|
||||||
fp.write("row=%d\n\n" % row)
|
|
||||||
row += 1
|
|
||||||
for gramplet in self.detached_gramplets:
|
|
||||||
opts = get_gramplet_options_by_name(gramplet.gname)
|
|
||||||
if opts is not None:
|
|
||||||
base_opts = opts.copy()
|
|
||||||
for key in base_opts:
|
|
||||||
if key in gramplet.__dict__:
|
|
||||||
base_opts[key] = gramplet.__dict__[key]
|
|
||||||
fp.write("[%s]\n" % gramplet.title)
|
|
||||||
for key in base_opts:
|
|
||||||
if key == "content": continue
|
|
||||||
elif key == "title":
|
|
||||||
if "title_override" in base_opts:
|
|
||||||
base_opts["title"] = base_opts["title_override"]
|
|
||||||
fp.write("title=%s\n" % base_opts[key])
|
|
||||||
elif key == "tname": continue
|
|
||||||
elif key == "version": continue # code, don't save
|
|
||||||
elif key == "gramps": continue # code, don't save
|
|
||||||
elif key == "data":
|
|
||||||
if not isinstance(base_opts["data"], (list, tuple)):
|
|
||||||
fp.write("data[0]=%s\n" % base_opts["data"])
|
|
||||||
else:
|
|
||||||
cnt = 0
|
|
||||||
for item in base_opts["data"]:
|
|
||||||
fp.write("data[%d]=%s\n" % (cnt, item))
|
|
||||||
cnt += 1
|
|
||||||
else:
|
|
||||||
fp.write("%s=%s\n\n" % (key, base_opts[key]))
|
|
||||||
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
def drop_widget(self, source, context, x, y, timedata):
|
def drop_widget(self, source, context, x, y, timedata):
|
||||||
"""
|
"""
|
||||||
|
@ -2040,9 +2040,8 @@ class DbBsddbRead(DbReadBase, Callback):
|
|||||||
"""
|
"""
|
||||||
filepath = os.path.join(self.path, "name.txt")
|
filepath = os.path.join(self.path, "name.txt")
|
||||||
try:
|
try:
|
||||||
name_file = open(filepath, "r", encoding='utf-8')
|
with open(filepath, "r", encoding='utf-8') as name_file:
|
||||||
name = name_file.readline().strip()
|
name = name_file.readline().strip()
|
||||||
name_file.close()
|
|
||||||
except (OSError, IOError) as msg:
|
except (OSError, IOError) as msg:
|
||||||
self.__log_error()
|
self.__log_error()
|
||||||
name = None
|
name = None
|
||||||
@ -2051,9 +2050,8 @@ class DbBsddbRead(DbReadBase, Callback):
|
|||||||
def get_version(self):
|
def get_version(self):
|
||||||
filepath = os.path.join(self.path, "bdbversion.txt")
|
filepath = os.path.join(self.path, "bdbversion.txt")
|
||||||
try:
|
try:
|
||||||
name_file = open(filepath, "r", encoding='utf-8')
|
with open(filepath, "r", encoding='utf-8') as name_file:
|
||||||
version = name_file.readline().strip()
|
version = name_file.readline().strip()
|
||||||
name_file.close()
|
|
||||||
except (OSError, IOError) as msg:
|
except (OSError, IOError) as msg:
|
||||||
self.__log_error()
|
self.__log_error()
|
||||||
version = "(0, 0, 0)"
|
version = "(0, 0, 0)"
|
||||||
|
@ -16,8 +16,8 @@ def get_dbdir_summary(dirpath, name):
|
|||||||
|
|
||||||
bdbversion_file = os.path.join(dirpath, BDBVERSFN)
|
bdbversion_file = os.path.join(dirpath, BDBVERSFN)
|
||||||
if os.path.isfile(bdbversion_file):
|
if os.path.isfile(bdbversion_file):
|
||||||
vers_file = open(bdbversion_file)
|
with open(bdbversion_file) as vers_file:
|
||||||
bsddb_version = vers_file.readline().strip()
|
bsddb_version = vers_file.readline().strip()
|
||||||
else:
|
else:
|
||||||
return "Unknown", "Unknown", "Unknown"
|
return "Unknown", "Unknown", "Unknown"
|
||||||
|
|
||||||
|
@ -458,8 +458,8 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
|
|
||||||
def __log_error(self):
|
def __log_error(self):
|
||||||
mypath = os.path.join(self.get_save_path(),DBRECOVFN)
|
mypath = os.path.join(self.get_save_path(),DBRECOVFN)
|
||||||
ofile = open(mypath, "w")
|
with open(mypath, "w") as ofile:
|
||||||
ofile.close()
|
pass
|
||||||
try:
|
try:
|
||||||
clear_lock_file(self.get_save_path())
|
clear_lock_file(self.get_save_path())
|
||||||
except:
|
except:
|
||||||
@ -2537,9 +2537,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
|||||||
schema_version = self.metadata.get(b'version', default=None)
|
schema_version = self.metadata.get(b'version', default=None)
|
||||||
bdbversion_file = os.path.join(self.path, BDBVERSFN)
|
bdbversion_file = os.path.join(self.path, BDBVERSFN)
|
||||||
if os.path.isfile(bdbversion_file):
|
if os.path.isfile(bdbversion_file):
|
||||||
vers_file = open(bdbversion_file)
|
with open(bdbversion_file) as vers_file:
|
||||||
bsddb_version = vers_file.readline().strip()
|
bsddb_version = vers_file.readline().strip()
|
||||||
bsddb_version = ".".join([str(v) for v in safe_eval(bsddb_version)])
|
bsddb_version = ".".join([str(v) for v in safe_eval(bsddb_version)])
|
||||||
else:
|
else:
|
||||||
bsddb_version = _("Unknown")
|
bsddb_version = _("Unknown")
|
||||||
return {
|
return {
|
||||||
@ -2591,15 +2591,14 @@ def do_export(database):
|
|||||||
try:
|
try:
|
||||||
for (base, tbl) in build_tbl_map(database):
|
for (base, tbl) in build_tbl_map(database):
|
||||||
backup_name = mk_tmp_name(database, base)
|
backup_name = mk_tmp_name(database, base)
|
||||||
backup_table = open(backup_name, 'wb')
|
with open(backup_name, 'wb') as backup_table:
|
||||||
|
|
||||||
cursor = tbl.cursor()
|
cursor = tbl.cursor()
|
||||||
data = cursor.first()
|
data = cursor.first()
|
||||||
while data:
|
while data:
|
||||||
pickle.dump(data, backup_table, 2)
|
pickle.dump(data, backup_table, 2)
|
||||||
data = cursor.next()
|
data = cursor.next()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
backup_table.close()
|
|
||||||
except (IOError,OSError):
|
except (IOError,OSError):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -2620,8 +2619,8 @@ def do_restore(database):
|
|||||||
"""
|
"""
|
||||||
for (base, tbl) in build_tbl_map(database):
|
for (base, tbl) in build_tbl_map(database):
|
||||||
backup_name = mk_backup_name(database, base)
|
backup_name = mk_backup_name(database, base)
|
||||||
backup_table = open(backup_name, 'rb')
|
with open(backup_name, 'rb') as backup_table:
|
||||||
load_tbl_txn(database, backup_table, tbl)
|
load_tbl_txn(database, backup_table, tbl)
|
||||||
|
|
||||||
database.rebuild_secondary()
|
database.rebuild_secondary()
|
||||||
|
|
||||||
@ -2678,29 +2677,28 @@ def clear_lock_file(name):
|
|||||||
def write_lock_file(name):
|
def write_lock_file(name):
|
||||||
if not os.path.isdir(name):
|
if not os.path.isdir(name):
|
||||||
os.mkdir(name)
|
os.mkdir(name)
|
||||||
f = open(os.path.join(name, DBLOCKFN), "w", encoding='utf8')
|
with open(os.path.join(name, DBLOCKFN), "w", encoding='utf8') as f:
|
||||||
if win():
|
if win():
|
||||||
user = get_env_var('USERNAME')
|
user = get_env_var('USERNAME')
|
||||||
host = get_env_var('USERDOMAIN')
|
host = get_env_var('USERDOMAIN')
|
||||||
if host is None:
|
if host is None:
|
||||||
host = ""
|
host = ""
|
||||||
else:
|
else:
|
||||||
host = os.uname()[1]
|
host = os.uname()[1]
|
||||||
# An ugly workaround for os.getlogin() issue with Konsole
|
# An ugly workaround for os.getlogin() issue with Konsole
|
||||||
try:
|
try:
|
||||||
user = os.getlogin()
|
user = os.getlogin()
|
||||||
except:
|
except:
|
||||||
# not win, so don't need get_env_var.
|
# not win, so don't need get_env_var.
|
||||||
# under cron getlogin() throws and there is no USER.
|
# under cron getlogin() throws and there is no USER.
|
||||||
user = os.environ.get('USER', 'noUSER')
|
user = os.environ.get('USER', 'noUSER')
|
||||||
if host:
|
if host:
|
||||||
text = "%s@%s" % (user, host)
|
text = "%s@%s" % (user, host)
|
||||||
else:
|
else:
|
||||||
text = user
|
text = user
|
||||||
# Save only the username and host, so the massage can be
|
# Save only the username and host, so the massage can be
|
||||||
# printed with correct locale in DbManager.py when a lock is found
|
# printed with correct locale in DbManager.py when a lock is found
|
||||||
f.write(text)
|
f.write(text)
|
||||||
f.close()
|
|
||||||
|
|
||||||
def upgrade_researcher(owner_data):
|
def upgrade_researcher(owner_data):
|
||||||
"""
|
"""
|
||||||
|
@ -1214,9 +1214,8 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
|
|||||||
|
|
||||||
for image in self.media_list:
|
for image in self.media_list:
|
||||||
try:
|
try:
|
||||||
ifile = open(image[0], mode='rb')
|
with open(image[0], mode='rb') as ifile:
|
||||||
self._add_zip(zfile, "Pictures/%s" % image[1], ifile.read(), t)
|
self._add_zip(zfile, "Pictures/%s" % image[1], ifile.read(), t)
|
||||||
ifile.close()
|
|
||||||
except:
|
except:
|
||||||
errmsg = "%s\n%s" % (_("Could not open %s") % image[0],
|
errmsg = "%s\n%s" % (_("Could not open %s") % image[0],
|
||||||
msg)
|
msg)
|
||||||
|
@ -121,61 +121,60 @@ 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")
|
with open(self.filename,"w") as f:
|
||||||
|
|
||||||
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)
|
||||||
name = id_name[key]
|
name = id_name[key]
|
||||||
father = mother = email = web = ""
|
father = mother = email = web = ""
|
||||||
|
|
||||||
family_handle = p.get_main_parents_family_handle()
|
family_handle = p.get_main_parents_family_handle()
|
||||||
if family_handle:
|
if family_handle:
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
if family.get_father_handle() and \
|
if family.get_father_handle() and \
|
||||||
family.get_father_handle() in id_map:
|
family.get_father_handle() in id_map:
|
||||||
father = id_map[family.get_father_handle()]
|
father = id_map[family.get_father_handle()]
|
||||||
if family.get_mother_handle() and \
|
if family.get_mother_handle() and \
|
||||||
family.get_mother_handle() in id_map:
|
family.get_mother_handle() in id_map:
|
||||||
mother = id_map[family.get_mother_handle()]
|
mother = id_map[family.get_mother_handle()]
|
||||||
|
|
||||||
#
|
#
|
||||||
# Calculate Date
|
# Calculate Date
|
||||||
#
|
#
|
||||||
birth_ref = p.get_birth_ref()
|
birth_ref = p.get_birth_ref()
|
||||||
death_ref = p.get_death_ref()
|
death_ref = p.get_death_ref()
|
||||||
if birth_ref:
|
if birth_ref:
|
||||||
birth_event = self.db.get_event_from_handle(birth_ref.ref)
|
birth_event = self.db.get_event_from_handle(birth_ref.ref)
|
||||||
birth = birth_event.get_date_object()
|
birth = birth_event.get_date_object()
|
||||||
else:
|
|
||||||
birth = None
|
|
||||||
if death_ref:
|
|
||||||
death_event = self.db.get_event_from_handle(death_ref.ref)
|
|
||||||
death = death_event.get_date_object()
|
|
||||||
else:
|
|
||||||
death = None
|
|
||||||
|
|
||||||
#if self.restrict:
|
|
||||||
# alive = probably_alive(p, self.db)
|
|
||||||
#else:
|
|
||||||
# alive = 0
|
|
||||||
|
|
||||||
if birth:
|
|
||||||
if death:
|
|
||||||
dates = "%s-%s" % (fdate(birth), fdate(death))
|
|
||||||
else:
|
else:
|
||||||
dates = fdate(birth)
|
birth = None
|
||||||
else:
|
if death_ref:
|
||||||
if death:
|
death_event = self.db.get_event_from_handle(death_ref.ref)
|
||||||
dates = fdate(death)
|
death = death_event.get_date_object()
|
||||||
else:
|
else:
|
||||||
dates = ""
|
death = None
|
||||||
|
|
||||||
f.write('%s;%s;%s;%s;%s;%s\n' % (name, father, mother, email, web,
|
#if self.restrict:
|
||||||
dates))
|
# alive = probably_alive(p, self.db)
|
||||||
|
#else:
|
||||||
|
# alive = 0
|
||||||
|
|
||||||
f.close()
|
if birth:
|
||||||
return True
|
if death:
|
||||||
|
dates = "%s-%s" % (fdate(birth), fdate(death))
|
||||||
|
else:
|
||||||
|
dates = fdate(birth)
|
||||||
|
else:
|
||||||
|
if death:
|
||||||
|
dates = fdate(death)
|
||||||
|
else:
|
||||||
|
dates = ""
|
||||||
|
|
||||||
|
f.write('%s;%s;%s;%s;%s;%s\n' % (name, father, mother, email, web,
|
||||||
|
dates))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def fdate(val):
|
def fdate(val):
|
||||||
if val.get_year_valid():
|
if val.get_year_valid():
|
||||||
|
@ -238,17 +238,17 @@ class GedcomWriter(UpdateCallback):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
self.dirname = os.path.dirname (filename)
|
self.dirname = os.path.dirname (filename)
|
||||||
self.gedcom_file = open(filename, "w", encoding='utf-8')
|
with open(filename, "w", encoding='utf-8') as self.gedcom_file:
|
||||||
self._header(filename)
|
self._header(filename)
|
||||||
self._submitter()
|
self._submitter()
|
||||||
self._individuals()
|
self._individuals()
|
||||||
self._families()
|
self._families()
|
||||||
self._sources()
|
self._sources()
|
||||||
self._repos()
|
self._repos()
|
||||||
self._notes()
|
self._notes()
|
||||||
|
|
||||||
|
self._writeln(0, "TRLR")
|
||||||
|
|
||||||
self._writeln(0, "TRLR")
|
|
||||||
self.gedcom_file.close()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _writeln(self, level, token, textlines="", limit=72):
|
def _writeln(self, level, token, textlines="", limit=72):
|
||||||
|
@ -90,7 +90,20 @@ class GeneWebWriter(object):
|
|||||||
|
|
||||||
self.dirname = os.path.dirname (self.filename)
|
self.dirname = os.path.dirname (self.filename)
|
||||||
try:
|
try:
|
||||||
self.g = open(self.filename, "wb")
|
with open(self.filename, "wb") as self.g:
|
||||||
|
self.flist = [x for x in self.db.iter_family_handles()]
|
||||||
|
if len(self.flist) < 1:
|
||||||
|
self.user.notify_error(_("No families matched by selected filter"))
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.count = 0
|
||||||
|
self.oldval = 0
|
||||||
|
self.total = len(self.flist)
|
||||||
|
for key in self.flist:
|
||||||
|
self.write_family(key)
|
||||||
|
self.writeln("")
|
||||||
|
|
||||||
|
return True
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
msg2 = _("Could not create %s") % self.filename
|
msg2 = _("Could not create %s") % self.filename
|
||||||
self.user.notify_error(msg2, str(msg))
|
self.user.notify_error(msg2, str(msg))
|
||||||
@ -99,21 +112,6 @@ class GeneWebWriter(object):
|
|||||||
self.user.notify_error(_("Could not create %s") % self.filename)
|
self.user.notify_error(_("Could not create %s") % self.filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.flist = [x for x in self.db.iter_family_handles()]
|
|
||||||
if len(self.flist) < 1:
|
|
||||||
self.user.notify_error(_("No families matched by selected filter"))
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.count = 0
|
|
||||||
self.oldval = 0
|
|
||||||
self.total = len(self.flist)
|
|
||||||
for key in self.flist:
|
|
||||||
self.write_family(key)
|
|
||||||
self.writeln("")
|
|
||||||
|
|
||||||
self.g.close()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def write_family(self, family_handle):
|
def write_family(self, family_handle):
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
if family:
|
if family:
|
||||||
|
@ -96,7 +96,25 @@ class CalendarWriter(object):
|
|||||||
|
|
||||||
self.dirname = os.path.dirname (filename)
|
self.dirname = os.path.dirname (filename)
|
||||||
try:
|
try:
|
||||||
self.g = open(filename,"w")
|
with open(filename,"w") as self.g:
|
||||||
|
self.writeln("BEGIN:VCALENDAR")
|
||||||
|
self.writeln("PRODID:-//GNU//Gramps//EN")
|
||||||
|
self.writeln("VERSION:1.0")
|
||||||
|
|
||||||
|
self.total = (len([x for x in self.db.iter_person_handles()]) +
|
||||||
|
len([x for x in self.db.iter_family_handles()]))
|
||||||
|
for key in self.db.iter_person_handles():
|
||||||
|
self.write_person(key)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
for key in self.db.iter_family_handles():
|
||||||
|
self.write_family(key)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
self.writeln("")
|
||||||
|
self.writeln("END:VCALENDAR")
|
||||||
|
|
||||||
|
return True
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
msg2 = _("Could not create %s") % filename
|
msg2 = _("Could not create %s") % filename
|
||||||
self.user.notify_error(msg2, str(msg))
|
self.user.notify_error(msg2, str(msg))
|
||||||
@ -105,26 +123,6 @@ class CalendarWriter(object):
|
|||||||
self.user.notify_error(_("Could not create %s") % filename)
|
self.user.notify_error(_("Could not create %s") % filename)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.writeln("BEGIN:VCALENDAR")
|
|
||||||
self.writeln("PRODID:-//GNU//Gramps//EN")
|
|
||||||
self.writeln("VERSION:1.0")
|
|
||||||
|
|
||||||
self.total = (len([x for x in self.db.iter_person_handles()]) +
|
|
||||||
len([x for x in self.db.iter_family_handles()]))
|
|
||||||
for key in self.db.iter_person_handles():
|
|
||||||
self.write_person(key)
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
for key in self.db.iter_family_handles():
|
|
||||||
self.write_family(key)
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
self.writeln("")
|
|
||||||
self.writeln("END:VCALENDAR")
|
|
||||||
|
|
||||||
self.g.close()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def write_family(self, family_handle):
|
def write_family(self, family_handle):
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
if family:
|
if family:
|
||||||
|
@ -67,28 +67,27 @@ def importData(database, filename, user):
|
|||||||
database.__class__.__bases__
|
database.__class__.__bases__
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ifile = open(filename, "rb")
|
with open(filename, "rb") as ifile:
|
||||||
|
ansel = False
|
||||||
|
gramps = False
|
||||||
|
for index in range(50):
|
||||||
|
# Treat the file as though it is UTF-8 since this is the more modern
|
||||||
|
# option; and anyway it doesn't really matter as we are only trying to
|
||||||
|
# detect a CHAR or SOUR line which is only 7-bit ASCII anyway, and we
|
||||||
|
# ignore anything that can't be translated.
|
||||||
|
line = ifile.readline()
|
||||||
|
line = line.decode(encoding='utf-8', errors='replace')
|
||||||
|
line = line.split()
|
||||||
|
if len(line) == 0:
|
||||||
|
break
|
||||||
|
if len(line) > 2 and line[1][0:4] == 'CHAR' and line[2] == "ANSEL":
|
||||||
|
ansel = True
|
||||||
|
if len(line) > 2 and line[1][0:4] == 'SOUR' and line[2] == "GRAMPS":
|
||||||
|
gramps = True
|
||||||
|
|
||||||
except IOError:
|
except IOError:
|
||||||
return
|
return
|
||||||
|
|
||||||
ansel = False
|
|
||||||
gramps = False
|
|
||||||
for index in range(50):
|
|
||||||
# Treat the file as though it is UTF-8 since this is the more modern
|
|
||||||
# option; and anyway it doesn't really matter as we are only trying to
|
|
||||||
# detect a CHAR or SOUR line which is only 7-bit ASCII anyway, and we
|
|
||||||
# ignore anything that can't be translated.
|
|
||||||
line = ifile.readline()
|
|
||||||
line = line.decode(encoding='utf-8', errors='replace')
|
|
||||||
line = line.split()
|
|
||||||
if len(line) == 0:
|
|
||||||
break
|
|
||||||
if len(line) > 2 and line[1][0:4] == 'CHAR' and line[2] == "ANSEL":
|
|
||||||
ansel = True
|
|
||||||
if len(line) > 2 and line[1][0:4] == 'SOUR' and line[2] == "GRAMPS":
|
|
||||||
gramps = True
|
|
||||||
ifile.close()
|
|
||||||
|
|
||||||
if not gramps and ansel:
|
if not gramps and ansel:
|
||||||
top = Glade()
|
top = Glade()
|
||||||
code = top.get_object('codeset')
|
code = top.get_object('codeset')
|
||||||
|
@ -1127,15 +1127,13 @@ class GedcomInfoDB(object):
|
|||||||
self.standard = GedcomDescription("GEDCOM 5.5 standard")
|
self.standard = GedcomDescription("GEDCOM 5.5 standard")
|
||||||
self.standard.set_dest("GEDCOM 5.5")
|
self.standard.set_dest("GEDCOM 5.5")
|
||||||
|
|
||||||
try:
|
filepath = os.path.join(DATA_DIR, "gedcom.xml")
|
||||||
filepath = os.path.join(DATA_DIR, "gedcom.xml")
|
if not os.path.exists(filepath):
|
||||||
ged_file = open(filepath, "rb")
|
|
||||||
except:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
parser = GedInfoParser(self)
|
with open(filepath, "rb") as ged_file:
|
||||||
parser.parse(ged_file)
|
parser = GedInfoParser(self)
|
||||||
ged_file.close()
|
parser.parse(ged_file)
|
||||||
|
|
||||||
def add_description(self, name, obj):
|
def add_description(self, name, obj):
|
||||||
self.map[name] = obj
|
self.map[name] = obj
|
||||||
|
@ -572,9 +572,8 @@ class VerifyResults(ManagedWindow):
|
|||||||
|
|
||||||
def _save_ignored(self,filename):
|
def _save_ignored(self,filename):
|
||||||
try:
|
try:
|
||||||
f = open(filename,'wb')
|
with open(filename,'wb') as f:
|
||||||
pickle.dump(self.ignores, f, 1)
|
pickle.dump(self.ignores, f, 1)
|
||||||
f.close()
|
|
||||||
return True
|
return True
|
||||||
except IOError:
|
except IOError:
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user