CLI: -l, -L, -t should match names with re patterns in them

This commit is contained in:
Doug Blank 2016-05-03 13:04:24 -04:00
parent 8350859c0c
commit 8a6d766b06
2 changed files with 16 additions and 10 deletions

View File

@ -399,7 +399,9 @@ class ArgHandler(object):
for name, dirname in sorted(self.dbman.family_tree_list(), for name, dirname in sorted(self.dbman.family_tree_list(),
key=lambda pair: pair[0].lower()): key=lambda pair: pair[0].lower()):
if (self.database_names is None or if (self.database_names is None or
any([re.match("^" + dbname + "$", name) for dbname in self.database_names])): any([(re.match("^" + dbname + "$", name) or
dbname == name)
for dbname in self.database_names])):
print(_("%(full_DB_path)s with name \"%(f_t_name)s\"") print(_("%(full_DB_path)s with name \"%(f_t_name)s\"")
% {'full_DB_path' : dirname, 'f_t_name' : name}) % {'full_DB_path' : dirname, 'f_t_name' : name})
return return

View File

@ -183,7 +183,9 @@ class CLIDbManager(object):
(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 if (database_names is None or
any([re.match("^" + dbname + "$", name) for dbname in database_names])): any([(re.match("^" + dbname + "$", name) or
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):
@ -203,7 +205,9 @@ class CLIDbManager(object):
(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 if (database_names is None or
any([re.match("^" + dbname + "$", name) for dbname in database_names])): any([(re.match("^" + dbname + "$", name) or
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
@ -409,7 +413,7 @@ class CLIDbManager(object):
if os.path.isfile(path_name): if os.path.isfile(path_name):
with open(path_name, 'r', encoding='utf8') as file: with open(path_name, 'r', encoding='utf8') as file:
name = file.readline().strip() name = file.readline().strip()
if re.match("^" + dbname + "$", name): if re.match("^" + dbname + "$", name) or dbname == name:
match_list.append((name, dirpath)) match_list.append((name, dirpath))
if len(match_list) == 0: if len(match_list) == 0:
CLIDbManager.ERROR("Family tree not found", CLIDbManager.ERROR("Family tree not found",