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,6 +182,8 @@ 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
if (database_names is None or
any([re.match(dbname, name) for dbname in database_names])):
summary = self.get_dbdir_summary(dirpath, name) summary = self.get_dbdir_summary(dirpath, name)
print(_("Family Tree \"%s\":") % summary[_("Family Tree")]) print(_("Family Tree \"%s\":") % summary[_("Family Tree")])
for item in sorted(summary): for item in sorted(summary):
@ -191,7 +193,7 @@ class CLIDbManager(object):
'item' : item, 'item' : item,
'summary' : summary[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,7 +201,9 @@ 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
if (database_names is None or
any([re.match(dbname, name) for dbname in database_names])):
retval = self.get_dbdir_summary(dirpath, name) retval = self.get_dbdir_summary(dirpath, name)
summary_list.append( retval ) summary_list.append( retval )
return summary_list return summary_list
@ -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: