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