Add optional list of trees to command-line args: -t -l -L
This commit is contained in:
parent
dbd00b2a32
commit
dd55b367ce
@ -170,6 +170,7 @@ class ArgHandler(object):
|
||||
self.list = parser.list
|
||||
self.list_more = parser.list_more
|
||||
self.list_table = parser.list_table
|
||||
self.database_names = parser.database_names
|
||||
self.open_gui = parser.open_gui
|
||||
self.imp_db_path = None
|
||||
self.dbman = CLIDbManager(self.dbstate)
|
||||
@ -396,7 +397,7 @@ 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:
|
||||
print(_("%(full_DB_path)s with name \"%(f_t_name)s\"")
|
||||
% {'full_DB_path' : dirname, 'f_t_name' : name})
|
||||
return
|
||||
@ -409,13 +410,13 @@ class ArgHandler(object):
|
||||
|
||||
# Handle the "-L" List Family Trees in detail option.
|
||||
if self.list_more:
|
||||
self.dbman.print_family_tree_summaries()
|
||||
self.dbman.print_family_tree_summaries(self.database_names)
|
||||
return
|
||||
|
||||
# Handle the "-t" List Family Trees, tab delimited option.
|
||||
if self.list_table:
|
||||
print(_('Gramps Family Trees:'))
|
||||
summary_list = self.dbman.family_tree_summary()
|
||||
summary_list = self.dbman.family_tree_summary(self.database_names)
|
||||
if not summary_list:
|
||||
return
|
||||
# We have to construct the line elements together, to avoid
|
||||
|
@ -67,9 +67,9 @@ Application options
|
||||
-a, --action=ACTION Specify action
|
||||
-p, --options=OPTIONS_STRING Specify options
|
||||
-d, --debug=LOGGER_NAME Enable debug logs
|
||||
-l List Family Trees
|
||||
-L List Family Trees in Detail
|
||||
-t List Family Trees, tab delimited
|
||||
-l [FAMILY_TREE...] List Family Trees
|
||||
-L [FAMILY_TREE...] List Family Trees in Detail
|
||||
-t [FAMILY_TREE...] 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
|
||||
@ -201,6 +201,7 @@ class ArgParser(object):
|
||||
self.list = False
|
||||
self.list_more = False
|
||||
self.list_table = False
|
||||
self.database_names = None
|
||||
self.help = False
|
||||
self.usage = False
|
||||
self.force_unlock = False
|
||||
@ -241,6 +242,14 @@ class ArgParser(object):
|
||||
"read the manual pages.") % cliargs)]
|
||||
return
|
||||
|
||||
# Some args can work on a list of databases:
|
||||
if leftargs:
|
||||
for opt_ix in range(len(options)):
|
||||
option, value = options[opt_ix]
|
||||
if option in ['-L', '-l', '-t']:
|
||||
self.database_names = leftargs
|
||||
leftargs = []
|
||||
|
||||
if leftargs:
|
||||
# if there were an argument without option,
|
||||
# use it as a file to open and return
|
||||
|
@ -173,7 +173,7 @@ class CLIDbManager(object):
|
||||
})
|
||||
return retval
|
||||
|
||||
def print_family_tree_summaries(self):
|
||||
def print_family_tree_summaries(self, database_names=None):
|
||||
"""
|
||||
Prints a detailed list of the known family trees.
|
||||
"""
|
||||
@ -181,6 +181,7 @@ 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:
|
||||
summary = self.get_dbdir_summary(dirpath, name)
|
||||
print(_("Family Tree \"%s\":") % summary[_("Family Tree")])
|
||||
for item in sorted(summary):
|
||||
@ -190,7 +191,7 @@ class CLIDbManager(object):
|
||||
'item' : item,
|
||||
'summary' : summary[item] } )
|
||||
|
||||
def family_tree_summary(self):
|
||||
def family_tree_summary(self, database_names=None):
|
||||
"""
|
||||
Return a list of dictionaries of the known family trees.
|
||||
"""
|
||||
@ -199,6 +200,7 @@ 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:
|
||||
retval = self.get_dbdir_summary(dirpath, name)
|
||||
summary_list.append( retval )
|
||||
return summary_list
|
||||
|
Loading…
Reference in New Issue
Block a user