CLI: -l, -L, -t should match names with re patterns in them
This commit is contained in:
parent
8350859c0c
commit
8a6d766b06
@ -398,8 +398,10 @@ 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
|
||||||
|
@ -182,8 +182,10 @@ 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
|
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):
|
||||||
@ -202,8 +204,10 @@ 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
|
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
|
||||||
@ -243,7 +247,7 @@ class CLIDbManager(object):
|
|||||||
|
|
||||||
if (stock_id == 'gramps-lock'):
|
if (stock_id == 'gramps-lock'):
|
||||||
last = find_locker_name(dirpath)
|
last = find_locker_name(dirpath)
|
||||||
|
|
||||||
self.current_names.append(
|
self.current_names.append(
|
||||||
(name, os.path.join(dbdir, dpath), path_name,
|
(name, os.path.join(dbdir, dpath), path_name,
|
||||||
last, tval, enable, stock_id, backend_type, version))
|
last, tval, enable, stock_id, backend_type, version))
|
||||||
@ -398,7 +402,7 @@ class CLIDbManager(object):
|
|||||||
|
|
||||||
def remove_database(self, dbname, user=None):
|
def remove_database(self, dbname, user=None):
|
||||||
"""
|
"""
|
||||||
Deletes a database folder given a pattenr that matches
|
Deletes a database folder given a pattenr that matches
|
||||||
its proper name.
|
its proper name.
|
||||||
"""
|
"""
|
||||||
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
dbdir = os.path.expanduser(config.get('behavior.database-path'))
|
||||||
@ -409,10 +413,10 @@ 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",
|
||||||
"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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user