From 516bba41804be053110d3f517a63cb6c2437a4f2 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 16 Apr 2016 03:03:57 -0400 Subject: [PATCH] CLI: add regular expression patterns to -t, -l, and -L --- gramps/cli/arghandler.py | 4 +++- gramps/cli/argparser.py | 8 ++++---- gramps/cli/clidbman.py | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gramps/cli/arghandler.py b/gramps/cli/arghandler.py index 668a538b2..b63bcce4a 100644 --- a/gramps/cli/arghandler.py +++ b/gramps/cli/arghandler.py @@ -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 diff --git a/gramps/cli/argparser.py b/gramps/cli/argparser.py index c8ad30407..42039fd39 100644 --- a/gramps/cli/argparser.py +++ b/gramps/cli/argparser.py @@ -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 diff --git a/gramps/cli/clidbman.py b/gramps/cli/clidbman.py index e0b280b37..78b84d9ad 100644 --- a/gramps/cli/clidbman.py +++ b/gramps/cli/clidbman.py @@ -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