CLI typos and slight code cleanup
svn: r21712
This commit is contained in:
parent
9be852fe2c
commit
2c41488ea3
@ -184,8 +184,6 @@ class ArgHandler(object):
|
|||||||
if self.errorfunc:
|
if self.errorfunc:
|
||||||
self.errorfunc(msg1)
|
self.errorfunc(msg1)
|
||||||
else:
|
else:
|
||||||
# Need to convert to system file encoding before printing
|
|
||||||
# For non latin characters in path/file/user names
|
|
||||||
print(msg1, file=sys.stderr)
|
print(msg1, file=sys.stderr)
|
||||||
if msg2 is not None:
|
if msg2 is not None:
|
||||||
print(msg2, file=sys.stderr)
|
print(msg2, file=sys.stderr)
|
||||||
@ -299,8 +297,8 @@ class ArgHandler(object):
|
|||||||
print()
|
print()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
if ans.upper() in ('Y', 'YES', _('YES').upper()):
|
if ans.upper() in ('Y', 'YES', _('YES').upper()):
|
||||||
self.__error( _("Will overwrite the existing file: %s")
|
self.__error(_("Will overwrite the existing file: %s")
|
||||||
% fullpath)
|
% fullpath)
|
||||||
answer = "ok"
|
answer = "ok"
|
||||||
else:
|
else:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -433,14 +431,14 @@ class ArgHandler(object):
|
|||||||
for (action, op_string) in self.actions:
|
for (action, op_string) in self.actions:
|
||||||
print(_("Performing action: %s.") % action, file=sys.stderr)
|
print(_("Performing action: %s.") % action, file=sys.stderr)
|
||||||
if op_string:
|
if op_string:
|
||||||
print(_("Using options string: %s") % op_string, file=sys.stderr)
|
print(_("Using options string: %s")
|
||||||
|
% op_string, file=sys.stderr)
|
||||||
self.cl_action(action, op_string)
|
self.cl_action(action, op_string)
|
||||||
|
|
||||||
for expt in self.exports:
|
for expt in self.exports:
|
||||||
print(_("Exporting: file %(filename)s, "
|
print(_("Exporting: file %(filename)s, format %(format)s.")
|
||||||
"format %(format)s.") % \
|
% {'filename' : expt[0],
|
||||||
{'filename' : fn,
|
'format' : expt[1]}, file=sys.stderr)
|
||||||
'format' : fmt}, file=sys.stderr)
|
|
||||||
self.cl_export(expt[0], expt[1])
|
self.cl_export(expt[0], expt[1])
|
||||||
|
|
||||||
if cleanup:
|
if cleanup:
|
||||||
@ -472,25 +470,22 @@ class ArgHandler(object):
|
|||||||
if self.gui:
|
if self.gui:
|
||||||
self.imp_db_path, title = self.dbman.create_new_db_cli()
|
self.imp_db_path, title = self.dbman.create_new_db_cli()
|
||||||
else:
|
else:
|
||||||
self.imp_db_path = get_empty_tempdir("import_dbdir") \
|
self.imp_db_path = get_empty_tempdir("import_dbdir")
|
||||||
.encode(sys.filesystem.encoding, 'backslashreplace')
|
|
||||||
newdb = DbBsddb()
|
newdb = DbBsddb()
|
||||||
newdb.write_version(self.imp_db_path)
|
newdb.write_version(self.imp_db_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.sm.open_activate(self.imp_db_path)
|
self.sm.open_activate(self.imp_db_path)
|
||||||
msg = _("Created empty family tree successfully")
|
msg = _("Created empty family tree successfully")
|
||||||
gloclale.print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
except:
|
except:
|
||||||
print(_("Error opening the file."), file=sys.stderr)
|
print(_("Error opening the file."), file=sys.stderr)
|
||||||
print(_("Exiting..."), file=sys.stderr)
|
print(_("Exiting..."), file=sys.stderr)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for imp in self.imports:
|
for imp in self.imports:
|
||||||
fn = imp[0]
|
|
||||||
fmt = str(imp[1])
|
|
||||||
msg = _("Importing: file %(filename)s, format %(format)s.") % \
|
msg = _("Importing: file %(filename)s, format %(format)s.") % \
|
||||||
{'filename' : fn, 'format' : fmt}
|
{'filename' : imp[0], 'format' : imp[1]}
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
self.cl_import(imp[0], imp[1])
|
self.cl_import(imp[0], imp[1])
|
||||||
|
|
||||||
@ -612,11 +607,11 @@ class ArgHandler(object):
|
|||||||
"Please use one of %(donottranslate)s=reportname") % \
|
"Please use one of %(donottranslate)s=reportname") % \
|
||||||
{'donottranslate' : '[-p|--options] name'}
|
{'donottranslate' : '[-p|--options] name'}
|
||||||
|
|
||||||
glcoale.print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
||||||
for pdata in sorted(_cl_list, key= lambda pdata: pdata.id.lower()):
|
for pdata in sorted(_cl_list, key= lambda pdata: pdata.id.lower()):
|
||||||
# Print cli report name ([item[0]), GUI report name (item[4])
|
# Print cli report name ([item[0]), GUI report name (item[4])
|
||||||
if len(pdata.id) <= 25:
|
if len(pdata.id) <= 25:
|
||||||
glocle.print(" %s%s- %s"
|
print(" %s%s- %s"
|
||||||
% ( pdata.id, " " * (26 - len(pdata.id)),
|
% ( pdata.id, " " * (26 - len(pdata.id)),
|
||||||
pdata.name), file=sys.stderr)
|
pdata.name), file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
@ -654,7 +649,7 @@ class ArgHandler(object):
|
|||||||
"Please use one of %(donottranslate)s=toolname.") % \
|
"Please use one of %(donottranslate)s=toolname.") % \
|
||||||
{'donottranslate' : '[-p|--options] name'}
|
{'donottranslate' : '[-p|--options] name'}
|
||||||
|
|
||||||
glcoale.print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
print(_("%s\n Available names are:") % msg, file=sys.stderr)
|
||||||
for pdata in sorted(_cli_tool_list,
|
for pdata in sorted(_cli_tool_list,
|
||||||
key=lambda pdata: pdata.id.lower()):
|
key=lambda pdata: pdata.id.lower()):
|
||||||
# Print cli report name ([item[0]), GUI report name (item[4])
|
# Print cli report name ([item[0]), GUI report name (item[4])
|
||||||
|
@ -298,10 +298,10 @@ class ArgParser(object):
|
|||||||
% config.filename)
|
% config.filename)
|
||||||
for section in config.data:
|
for section in config.data:
|
||||||
for setting in config.data[section]:
|
for setting in config.data[section]:
|
||||||
print ("%s.%s=%s"
|
print("%s.%s=%s"
|
||||||
% (section, setting,
|
% (section, setting,
|
||||||
repr(config.data[section][setting])))
|
repr(config.data[section][setting])))
|
||||||
print ()
|
print()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif option in ('-c', '--config'):
|
elif option in ('-c', '--config'):
|
||||||
setting_name = value
|
setting_name = value
|
||||||
@ -328,7 +328,7 @@ class ArgParser(object):
|
|||||||
else:
|
else:
|
||||||
need_to_quit = True
|
need_to_quit = True
|
||||||
else:
|
else:
|
||||||
print(_("Gramps: no such config setting: %s")
|
print(_("Gramps: no such config setting: '%s'")
|
||||||
% setting_name, file=sys.stderr)
|
% setting_name, file=sys.stderr)
|
||||||
need_to_quit = True
|
need_to_quit = True
|
||||||
cleandbg += [opt_ix]
|
cleandbg += [opt_ix]
|
||||||
@ -404,8 +404,7 @@ class ArgParser(object):
|
|||||||
If the user gives the --help or -h option, print the output to terminal.
|
If the user gives the --help or -h option, print the output to terminal.
|
||||||
"""
|
"""
|
||||||
if self.help:
|
if self.help:
|
||||||
# Convert Help messages to file system encoding before printing
|
print(_HELP)
|
||||||
print (_HELP)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def print_usage(self):
|
def print_usage(self):
|
||||||
@ -413,6 +412,5 @@ class ArgParser(object):
|
|||||||
If the user gives the --usage print the output to terminal.
|
If the user gives the --usage print the output to terminal.
|
||||||
"""
|
"""
|
||||||
if self.usage:
|
if self.usage:
|
||||||
# Convert Help messages to file system encoding before printing
|
|
||||||
print(_USAGE)
|
print(_USAGE)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
@ -295,23 +295,17 @@ def startcli(errors, argparser):
|
|||||||
"""
|
"""
|
||||||
if errors:
|
if errors:
|
||||||
#already errors encountered. Show first one on terminal and exit
|
#already errors encountered. Show first one on terminal and exit
|
||||||
# Convert error message to file system encoding before print
|
|
||||||
errmsg = _('Error encountered: %s') % errors[0][0]
|
errmsg = _('Error encountered: %s') % errors[0][0]
|
||||||
errmsg = errmsg
|
|
||||||
print(errmsg)
|
print(errmsg)
|
||||||
errmsg = _(' Details: %s') % errors[0][1]
|
errmsg = _(' Details: %s') % errors[0][1]
|
||||||
errmsg = errmsg
|
|
||||||
print(errmsg)
|
print(errmsg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if argparser.errors:
|
if argparser.errors:
|
||||||
# Convert error message to file system encoding before print
|
|
||||||
errmsg = _('Error encountered in argument parsing: %s') \
|
errmsg = _('Error encountered in argument parsing: %s') \
|
||||||
% argparser.errors[0][0]
|
% argparser.errors[0][0]
|
||||||
errmsg = errmsg
|
|
||||||
print(errmsg)
|
print(errmsg)
|
||||||
errmsg = _(' Details: %s') % argparser.errors[0][1]
|
errmsg = _(' Details: %s') % argparser.errors[0][1]
|
||||||
errmsg = errmsg
|
|
||||||
print(errmsg)
|
print(errmsg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
@ -419,9 +419,9 @@ class CommandLineReport(object):
|
|||||||
print(_("Unknown option: %s") % option)
|
print(_("Unknown option: %s") % option)
|
||||||
print(_(" Valid options are:"),
|
print(_(" Valid options are:"),
|
||||||
", ".join(list(self.options_dict.keys())))
|
", ".join(list(self.options_dict.keys())))
|
||||||
print((_(" Use '%(donottranslate)s' to see description "
|
print(_(" Use '%(donottranslate)s' to see description "
|
||||||
"and acceptable values") %
|
"and acceptable values")
|
||||||
{'donottranslate' : "show=option"}))
|
% {'donottranslate' : "show=option"})
|
||||||
|
|
||||||
def parse_options(self):
|
def parse_options(self):
|
||||||
"""
|
"""
|
||||||
@ -471,13 +471,13 @@ class CommandLineReport(object):
|
|||||||
else:
|
else:
|
||||||
self.format = None
|
self.format = None
|
||||||
if _chosen_format and _format_str:
|
if _chosen_format and _format_str:
|
||||||
print((_("Ignoring '%(notranslate1)s=%(notranslate2)s' "
|
print(_("Ignoring '%(notranslate1)s=%(notranslate2)s' "
|
||||||
"and using '%(notranslate1)s=%(notranslate3)s'.") %
|
"and using '%(notranslate1)s=%(notranslate3)s'.")
|
||||||
{'notranslate1' : "off",
|
% {'notranslate1' : "off",
|
||||||
'notranslate2' : self.options_dict['off'],
|
'notranslate2' : self.options_dict['off'],
|
||||||
'notranslate3' : _chosen_format}))
|
'notranslate3' : _chosen_format})
|
||||||
print((_("Use '%(notranslate)s' to see valid values.") %
|
print(_("Use '%(notranslate)s' to see valid values.")
|
||||||
{'notranslate' : "show=off"}))
|
% {'notranslate' : "show=off"})
|
||||||
|
|
||||||
self.do_doc_options()
|
self.do_doc_options()
|
||||||
|
|
||||||
@ -570,14 +570,13 @@ class CommandLineReport(object):
|
|||||||
# Make the output nicer to read, assume a tab has 8 spaces
|
# Make the output nicer to read, assume a tab has 8 spaces
|
||||||
tabs = '\t\t' if len(key) < 10 else '\t'
|
tabs = '\t\t' if len(key) < 10 else '\t'
|
||||||
optmsg = " %s%s%s (%s)" % (key, tabs, opt[1], opt[0])
|
optmsg = " %s%s%s (%s)" % (key, tabs, opt[1], opt[0])
|
||||||
print(optmsg)
|
|
||||||
else:
|
else:
|
||||||
optmsg = " %s%s%s" % (key, tabs,
|
optmsg = " %s%s%s" % (key, tabs,
|
||||||
_('(no help available)'))
|
_('(no help available)'))
|
||||||
print(optmsg)
|
print(optmsg)
|
||||||
print(_(" Use '%(donottranslate)s' to see description "
|
print(_(" Use '%(donottranslate)s' to see description "
|
||||||
"and acceptable values") %
|
"and acceptable values")
|
||||||
{'donottranslate' : "show=option"})
|
% {'donottranslate' : "show=option"})
|
||||||
elif self.show in self.options_help:
|
elif self.show in self.options_help:
|
||||||
opt = self.options_help[self.show]
|
opt = self.options_help[self.show]
|
||||||
tabs = '\t\t' if len(self.show) < 10 else '\t'
|
tabs = '\t\t' if len(self.show) < 10 else '\t'
|
||||||
@ -586,18 +585,16 @@ class CommandLineReport(object):
|
|||||||
vals = opt[2]
|
vals = opt[2]
|
||||||
if isinstance(vals, (list, tuple)):
|
if isinstance(vals, (list, tuple)):
|
||||||
for val in vals:
|
for val in vals:
|
||||||
optmsg = " %s" % val
|
print(" %s" % val)
|
||||||
print(optmsg)
|
|
||||||
else:
|
else:
|
||||||
optmsg = " %s" % opt[2]
|
print(" %s" % opt[2])
|
||||||
print(optmsg)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#there was a show option given, but the option is invalid
|
#there was a show option given, but the option is invalid
|
||||||
print(_("option '%(optionname)s' not valid. "
|
print(_("option '%(optionname)s' not valid. "
|
||||||
"Use '%(donottranslate)s' to see all valid options.")
|
"Use '%(donottranslate)s' to see all valid options.")
|
||||||
% {'optionname' : self.show,
|
% {'optionname' : self.show,
|
||||||
'donottranslate' : "show=all"})
|
'donottranslate' : "show=all"})
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user