CLI: add regular expression patterns to -t, -l, and -L

This commit is contained in:
Doug Blank 2016-04-16 03:03:57 -04:00
parent 67a6e0cf79
commit 516bba4180
3 changed files with 11 additions and 7 deletions

View File

@ -36,6 +36,7 @@ Module responsible for handling the command line arguments for Gramps.
#-------------------------------------------------------------------------
import os
import sys
import re
#-------------------------------------------------------------------------
#
@ -397,7 +398,8 @@ class ArgHandler(object):
for name, dirname in sorted(self.dbman.family_tree_list(),
key=lambda pair: pair[0].lower()):
if self.database_names is None or name in self.database_names:
if (self.database_names is None or
any([re.match(dbname, name) for dbname in self.database_names])):
print(_("%(full_DB_path)s with name \"%(f_t_name)s\"")
% {'full_DB_path' : dirname, 'f_t_name' : name})
return

View File

@ -62,14 +62,14 @@ Application options
-C, --create=FAMILY_TREE Create on open if new Family Tree
-i, --import=FILENAME Import file
-e, --export=FILENAME Export file
-r, --remove=FAMILY_TREE_PATTERN Remove matching Family Tree(s)
-r, --remove=FAMILY_TREE_PATTERN Remove matching Family Tree(s) (use regular expressions)
-f, --format=FORMAT Specify Family Tree format
-a, --action=ACTION Specify action
-p, --options=OPTIONS_STRING Specify options
-d, --debug=LOGGER_NAME Enable debug logs
-l [FAMILY_TREE...] List Family Trees
-L [FAMILY_TREE...] List Family Trees in Detail
-t [FAMILY_TREE...] List Family Trees, tab delimited
-l [FAMILY_TREE_PATTERN...] List Family Trees
-L [FAMILY_TREE_PATTERN...] List Family Trees in Detail
-t [FAMILY_TREE_PATTERN...] List Family Trees, tab delimited
-u, --force-unlock Force unlock of Family Tree
-s, --show Show config settings
-c, --config=[config.setting[:value]] Set config setting(s) and start Gramps

View File

@ -181,7 +181,8 @@ class CLIDbManager(object):
for item in self.current_names:
(name, dirpath, path_name, last,
tval, enable, stock_id) = item
if database_names is None or name in database_names:
if (database_names is None or
any([re.match(dbname, name) for dbname in database_names])):
summary = self.get_dbdir_summary(dirpath, name)
print(_("Family Tree \"%s\":") % summary[_("Family Tree")])
for item in sorted(summary):
@ -200,7 +201,8 @@ class CLIDbManager(object):
for item in self.current_names:
(name, dirpath, path_name, last,
tval, enable, stock_id) = item
if database_names is None or name in database_names:
if (database_names is None or
any([re.match(dbname, name) for dbname in database_names])):
retval = self.get_dbdir_summary(dirpath, name)
summary_list.append( retval )
return summary_list