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 os
import sys import sys
import re
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -397,7 +398,8 @@ 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 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\"") 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

@ -62,14 +62,14 @@ Application options
-C, --create=FAMILY_TREE Create on open if new Family Tree -C, --create=FAMILY_TREE Create on open if new Family Tree
-i, --import=FILENAME Import file -i, --import=FILENAME Import file
-e, --export=FILENAME Export 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 -f, --format=FORMAT Specify Family Tree format
-a, --action=ACTION Specify action -a, --action=ACTION Specify action
-p, --options=OPTIONS_STRING Specify options -p, --options=OPTIONS_STRING Specify options
-d, --debug=LOGGER_NAME Enable debug logs -d, --debug=LOGGER_NAME Enable debug logs
-l [FAMILY_TREE...] List Family Trees -l [FAMILY_TREE_PATTERN...] List Family Trees
-L [FAMILY_TREE...] List Family Trees in Detail -L [FAMILY_TREE_PATTERN...] List Family Trees in Detail
-t [FAMILY_TREE...] List Family Trees, tab delimited -t [FAMILY_TREE_PATTERN...] List Family Trees, tab delimited
-u, --force-unlock Force unlock of Family Tree -u, --force-unlock Force unlock of Family Tree
-s, --show Show config settings -s, --show Show config settings
-c, --config=[config.setting[:value]] Set config setting(s) and start Gramps -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: for item in self.current_names:
(name, dirpath, path_name, last, (name, dirpath, path_name, last,
tval, enable, stock_id) = item 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) 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):
@ -200,7 +201,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) = item 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) retval = self.get_dbdir_summary(dirpath, name)
summary_list.append( retval ) summary_list.append( retval )
return summary_list return summary_list