clidbman: restore accidently deleted code

This commit is contained in:
Doug Blank 2016-04-16 17:38:01 -04:00
parent 7accf755d5
commit 1e228b2193

View File

@ -159,9 +159,9 @@ class CLIDbManager(object):
if not self.is_locked(dirpath): if not self.is_locked(dirpath):
try: try:
database = self.dbstate.make_database(dbid) database = self.dbstate.make_database(dbid)
database.load(dirpath, None) database.load(dirpath, None, update=False)
retval = database.get_summary() retval = database.get_summary()
database.close() database.close(update=False)
except Exception as msg: except Exception as msg:
retval = {_("Unavailable"): str(msg)[:74] + "..."} retval = {_("Unavailable"): str(msg)[:74] + "..."}
else: else:
@ -174,7 +174,7 @@ class CLIDbManager(object):
}) })
return retval return retval
def print_family_tree_summaries(self): def print_family_tree_summaries(self, database_names=None):
""" """
Prints a detailed list of the known family trees. Prints a detailed list of the known family trees.
""" """
@ -182,16 +182,18 @@ class CLIDbManager(object):
for item in self.current_names: for item in self.current_names:
(name, dirpath, path_name, last, (name, dirpath, path_name, last,
tval, enable, stock_id, backend_type, version) = item tval, enable, stock_id, backend_type, version) = item
summary = self.get_dbdir_summary(dirpath, name) if (database_names is None or
print(_("Family Tree \"%s\":") % summary[_("Family Tree")]) any([re.match(dbname, name) for dbname in database_names])):
for item in sorted(summary): summary = self.get_dbdir_summary(dirpath, name)
if item != "Family Tree": print(_("Family Tree \"%s\":") % summary[_("Family Tree")])
# translators: needed for French, ignore otherwise for item in sorted(summary):
print(_(" %(item)s: %(summary)s") % { if item != "Family Tree":
'item' : item, # translators: needed for French, ignore otherwise
'summary' : summary[item] } ) print(_(" %(item)s: %(summary)s") % {
'item' : item,
'summary' : summary[item] } )
def family_tree_summary(self): def family_tree_summary(self, database_names=None):
""" """
Return a list of dictionaries of the known family trees. Return a list of dictionaries of the known family trees.
""" """
@ -199,9 +201,11 @@ class CLIDbManager(object):
summary_list = [] summary_list = []
for item in self.current_names: for item in self.current_names:
(name, dirpath, path_name, last, (name, dirpath, path_name, last,
tval, enable, stock_id, backend_type) = item tval, enable, stock_id, backend_type, version) = item
retval = self.get_dbdir_summary(dirpath, name) if (database_names is None or
summary_list.append( retval ) any([re.match(dbname, name) for dbname in database_names])):
retval = self.get_dbdir_summary(dirpath, name)
summary_list.append( retval )
return summary_list return summary_list
def _populate_cli(self): def _populate_cli(self):
@ -300,7 +304,7 @@ class CLIDbManager(object):
(tval, last) = time_val(new_path) (tval, last) = time_val(new_path)
self.current_names.append((title, new_path, path_name, self.current_names.append((title, new_path, path_name,
last, tval, False, "", "Backend Type")) last, tval, False, "", dbid))
return new_path, title return new_path, title
def _create_new_db(self, title=None, dbid=None): def _create_new_db(self, title=None, dbid=None):
@ -412,10 +416,10 @@ class CLIDbManager(object):
"No matching family tree found: '%s'" % dbname) "No matching family tree found: '%s'" % dbname)
# now delete them: # now delete them:
for (name, directory) in match_list: for (name, directory) in match_list:
if user is None or user.prompt( if user is None or not user.prompt(
_('Remove family tree warning'), _('Remove family tree warning'),
_('Are you sure you want to remove the family tree named\n"%s"?' % name), _('Are you sure you want to remove the family tree named\n"%s"?' % name),
_('Yes'), _('No'), None): _('no'), _('yes')):
try: try:
for (top, dirs, files) in os.walk(directory): for (top, dirs, files) in os.walk(directory):
for filename in files: for filename in files: