Fix of issue 6058 and printing of non ascii strings in Windows.
svn: r20445
This commit is contained in:
parent
98cb7c553d
commit
410985b0e1
@ -403,9 +403,8 @@ class ArgHandler(object):
|
|||||||
encode(sys.getfilesystemencoding())
|
encode(sys.getfilesystemencoding())
|
||||||
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()):
|
||||||
|
|
||||||
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,
|
{'full_DB_path' : dirname.decode(sys.getfilesystemencoding()),
|
||||||
'f_t_name' : name}).encode(sys.getfilesystemencoding())
|
'f_t_name' : name}).encode(sys.getfilesystemencoding())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
@ -413,11 +412,13 @@ class ArgHandler(object):
|
|||||||
print _('Gramps Family Trees:').encode(sys.getfilesystemencoding())
|
print _('Gramps Family Trees:').encode(sys.getfilesystemencoding())
|
||||||
summary_list = self.dbman.family_tree_summary()
|
summary_list = self.dbman.family_tree_summary()
|
||||||
for summary in sorted(summary_list,
|
for summary in sorted(summary_list,
|
||||||
key=lambda sum: sum["Family tree"].lower()):
|
key=lambda sum: sum[_("Family tree")].lower()):
|
||||||
print _("Family Tree \"%s\":").\
|
print _("Family Tree \"%s\":").\
|
||||||
encode(sys.getfilesystemencoding()) % summary["Family tree"]
|
encode(sys.getfilesystemencoding()) % summary[_("Family tree")]
|
||||||
for item in sorted(summary):
|
for item in sorted(summary):
|
||||||
if item != "Family tree":
|
if item == _("Path"):
|
||||||
|
summary[item] = (summary[item]).decode(sys.getfilesystemencoding())
|
||||||
|
if item != _("Family tree"):
|
||||||
print (" %s: %s" % (item, summary[item])).\
|
print (" %s: %s" % (item, summary[item])).\
|
||||||
encode(sys.getfilesystemencoding())
|
encode(sys.getfilesystemencoding())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
@ -426,9 +427,9 @@ class ArgHandler(object):
|
|||||||
self.__import_action()
|
self.__import_action()
|
||||||
|
|
||||||
for (action, op_string) in self.actions:
|
for (action, op_string) in self.actions:
|
||||||
print >> sys.stderr, _("Performing action: %s.") % action
|
print >> sys.stderr, (_("Performing action: %s.") % action).encode(sys.getfilesystemencoding())
|
||||||
if op_string:
|
if op_string:
|
||||||
print >> sys.stderr, _("Using options string: %s") % op_string
|
print >> sys.stderr, (_("Using options string: %s") % op_string).encode(sys.getfilesystemencoding())
|
||||||
self.cl_action(action, op_string)
|
self.cl_action(action, op_string)
|
||||||
|
|
||||||
for expt in self.exports:
|
for expt in self.exports:
|
||||||
@ -444,11 +445,11 @@ class ArgHandler(object):
|
|||||||
|
|
||||||
if cleanup:
|
if cleanup:
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
print >> sys.stderr, _("Exiting.")
|
print >> sys.stderr, _("Exiting.").encode(sys.getfilesystemencoding())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
print >> sys.stderr, _("Cleaning up.")
|
print >> sys.stderr, _("Cleaning up.").encode(sys.getfilesystemencoding())
|
||||||
# remove files in import db subdir after use
|
# remove files in import db subdir after use
|
||||||
self.dbstate.db.close()
|
self.dbstate.db.close()
|
||||||
if self.imp_db_path:
|
if self.imp_db_path:
|
||||||
@ -478,11 +479,11 @@ class ArgHandler(object):
|
|||||||
|
|
||||||
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").encode(sys.getfilesystemencoding())
|
||||||
print >> sys.stderr, msg
|
print >> sys.stderr, msg
|
||||||
except:
|
except:
|
||||||
print >> sys.stderr, _("Error opening the file.")
|
print >> sys.stderr, _("Error opening the file.").encode(sys.getfilesystemencoding())
|
||||||
print >> sys.stderr, _("Exiting...")
|
print >> sys.stderr, _("Exiting...").encode(sys.getfilesystemencoding())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for imp in self.imports:
|
for imp in self.imports:
|
||||||
@ -490,7 +491,7 @@ class ArgHandler(object):
|
|||||||
fmt = str(imp[1])
|
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' : fn, 'format' : fmt}
|
||||||
print >> sys.stderr, msg
|
print >> sys.stderr, msg.encode(sys.getfilesystemencoding())
|
||||||
self.cl_import(imp[0], imp[1])
|
self.cl_import(imp[0], imp[1])
|
||||||
|
|
||||||
def __open_action(self):
|
def __open_action(self):
|
||||||
@ -506,10 +507,10 @@ class ArgHandler(object):
|
|||||||
# we load this file for use
|
# we load this file for use
|
||||||
try:
|
try:
|
||||||
self.sm.open_activate(self.open)
|
self.sm.open_activate(self.open)
|
||||||
print >> sys.stderr, _("Opened successfully!")
|
print >> sys.stderr, _("Opened successfully!").encode(sys.getfilesystemencoding())
|
||||||
except:
|
except:
|
||||||
print >> sys.stderr, _("Error opening the file.")
|
print >> sys.stderr, _("Error opening the file.").encode(sys.getfilesystemencoding())
|
||||||
print >> sys.stderr, _("Exiting...")
|
print >> sys.stderr, _("Exiting...").encode(sys.getfilesystemencoding())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def check_db(self, dbpath, force_unlock = False):
|
def check_db(self, dbpath, force_unlock = False):
|
||||||
@ -581,7 +582,7 @@ class ArgHandler(object):
|
|||||||
options_str_dict = _split_options(options_str)
|
options_str_dict = _split_options(options_str)
|
||||||
except:
|
except:
|
||||||
options_str_dict = {}
|
options_str_dict = {}
|
||||||
print >> sys.stderr, _("Ignoring invalid options string.")
|
print >> sys.stderr, _("Ignoring invalid options string.").encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
name = options_str_dict.pop('name', None)
|
name = options_str_dict.pop('name', None)
|
||||||
_cl_list = pmgr.get_reg_reports(gui=False)
|
_cl_list = pmgr.get_reg_reports(gui=False)
|
||||||
@ -610,7 +611,7 @@ 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'}
|
||||||
|
|
||||||
print >> sys.stderr, _("%s\n Available names are:") % msg
|
print >> sys.stderr, (_("%s\n Available names are:") % msg).encode(sys.getfilesystemencoding())
|
||||||
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:
|
||||||
@ -628,7 +629,7 @@ class ArgHandler(object):
|
|||||||
chunk in options_str.split(',') ] )
|
chunk in options_str.split(',') ] )
|
||||||
except:
|
except:
|
||||||
options_str_dict = {}
|
options_str_dict = {}
|
||||||
print >> sys.stderr, _("Ignoring invalid options string.")
|
print >> sys.stderr, _("Ignoring invalid options string.").encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
name = options_str_dict.pop('name', None)
|
name = options_str_dict.pop('name', None)
|
||||||
_cli_tool_list = pmgr.get_reg_tools(gui=False)
|
_cli_tool_list = pmgr.get_reg_tools(gui=False)
|
||||||
|
@ -176,15 +176,15 @@ class CLIDbManager(object):
|
|||||||
tval, enable, stock_id) = item
|
tval, enable, stock_id) = item
|
||||||
count, version = self.get_dbdir_summary(dirpath)
|
count, version = self.get_dbdir_summary(dirpath)
|
||||||
retval = {}
|
retval = {}
|
||||||
retval["Number of people"] = count
|
retval[_("Number of people")] = count
|
||||||
if enable:
|
if enable:
|
||||||
retval["Locked?"] = "yes"
|
retval[_("Locked?")] = _("yes")
|
||||||
else:
|
else:
|
||||||
retval["Locked?"] = "no"
|
retval[_("Locked?")] = _("no")
|
||||||
retval["DB version"] = version
|
retval[_("DB version")] = version
|
||||||
retval["Family tree"] = name.encode(sys.getfilesystemencoding())
|
retval[_("Family tree")] = name.encode(sys.getfilesystemencoding())
|
||||||
retval["Path"] = dirpath
|
retval[_("Path")] = dirpath
|
||||||
retval["Last accessed"] = time.strftime('%x %X',
|
retval[_("Last accessed")] = time.strftime('%x %X',
|
||||||
time.localtime(tval))
|
time.localtime(tval))
|
||||||
list.append( retval )
|
list.append( retval )
|
||||||
return list
|
return list
|
||||||
|
@ -165,7 +165,7 @@ def _validate_options(options, dbase):
|
|||||||
phandle = None
|
phandle = None
|
||||||
person = dbase.get_person_from_handle(phandle)
|
person = dbase.get_person_from_handle(phandle)
|
||||||
if not person:
|
if not person:
|
||||||
print _("ERROR: Please specify a person")
|
print _("ERROR: Please specify a person").encode(sys.getfilesystemencoding())
|
||||||
if person:
|
if person:
|
||||||
option.set_value(person.get_gramps_id())
|
option.set_value(person.get_gramps_id())
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ def _validate_options(options, dbase):
|
|||||||
family = dbase.get_family_from_handle(family_handle)
|
family = dbase.get_family_from_handle(family_handle)
|
||||||
option.set_value(family.get_gramps_id())
|
option.set_value(family.get_gramps_id())
|
||||||
else:
|
else:
|
||||||
print _("ERROR: Please specify a family")
|
print _("ERROR: Please specify a family").encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -293,7 +293,7 @@ class CommandLineReport(object):
|
|||||||
elif self.category == CATEGORY_GRAPHVIZ:
|
elif self.category == CATEGORY_GRAPHVIZ:
|
||||||
for graph_format in graphdoc.FORMATS:
|
for graph_format in graphdoc.FORMATS:
|
||||||
self.options_help['off'][2].append(
|
self.options_help['off'][2].append(
|
||||||
graph_format["ext"] + "\t" + graph_format["descr"] )
|
graph_format["type"] + "\t" + graph_format["descr"] )
|
||||||
else:
|
else:
|
||||||
self.options_help['off'][2] = "NA"
|
self.options_help['off'][2] = "NA"
|
||||||
|
|
||||||
@ -400,12 +400,12 @@ class CommandLineReport(object):
|
|||||||
elif isinstance(option, Option):
|
elif isinstance(option, Option):
|
||||||
self.options_help[name].append(option.get_help())
|
self.options_help[name].append(option.get_help())
|
||||||
else:
|
else:
|
||||||
print _("Unknown option: %s") % option
|
print (_("Unknown option: %s") % option).encode(sys.getfilesystemencoding())
|
||||||
print _(" Valid options are:"), ", ".join(
|
print (_(" Valid options are:"), ", ".join(
|
||||||
self.options_dict.keys())
|
self.options_dict.keys())).encode(sys.getfilesystemencoding())
|
||||||
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"}).encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
def parse_options(self):
|
def parse_options(self):
|
||||||
"""
|
"""
|
||||||
@ -430,12 +430,12 @@ class CommandLineReport(object):
|
|||||||
option.set_value(self.options_dict[opt])
|
option.set_value(self.options_dict[opt])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print _("Ignoring unknown option: %s") % opt
|
print (_("Ignoring unknown option: %s") % opt).encode(sys.getfilesystemencoding())
|
||||||
print _(" Valid options are:"), ", ".join(
|
print (_(" Valid options are:"), ", ".join(
|
||||||
self.options_dict.keys())
|
self.options_dict.keys())).encode(sys.getfilesystemencoding())
|
||||||
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"}).encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
self.option_class.handler.output = self.options_dict['of']
|
self.option_class.handler.output = self.options_dict['of']
|
||||||
|
|
||||||
@ -468,13 +468,13 @@ class CommandLineReport(object):
|
|||||||
_chosen_format = self.__bookdoc_plugins[0].get_extension()
|
_chosen_format = self.__bookdoc_plugins[0].get_extension()
|
||||||
elif self.category == CATEGORY_GRAPHVIZ:
|
elif self.category == CATEGORY_GRAPHVIZ:
|
||||||
for graph_format in graphdoc.FORMATS:
|
for graph_format in graphdoc.FORMATS:
|
||||||
if graph_format['ext'] == self.options_dict['off']:
|
if graph_format['type'] == self.options_dict['off']:
|
||||||
if not self.format: # choose the first one, not the last
|
if not self.format: # choose the first one, not the last
|
||||||
self.format = graph_format["class"]
|
self.format = graph_format["class"]
|
||||||
if self.format is None:
|
if self.format is None:
|
||||||
# Pick the first one as the default.
|
# Pick the first one as the default.
|
||||||
self.format = graphdoc.FORMATS[0]["class"]
|
self.format = graphdoc.FORMATS[0]["class"]
|
||||||
_chosen_format = graphdoc.FORMATS[0]["ext"]
|
_chosen_format = graphdoc.FORMATS[0]["type"]
|
||||||
else:
|
else:
|
||||||
self.format = None
|
self.format = None
|
||||||
if _chosen_format and self.options_str_dict.has_key('off'):
|
if _chosen_format and self.options_str_dict.has_key('off'):
|
||||||
@ -482,9 +482,9 @@ class CommandLineReport(object):
|
|||||||
"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}).encode(sys.getfilesystemencoding())
|
||||||
print (_("Use '%(notranslate)s' to see valid values.") %
|
print (_("Use '%(notranslate)s' to see valid values.") %
|
||||||
{'notranslate' : "show=off"})
|
{'notranslate' : "show=off"}).encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
for paper in paper_sizes:
|
for paper in paper_sizes:
|
||||||
if paper.get_name() == self.options_dict['papers']:
|
if paper.get_name() == self.options_dict['papers']:
|
||||||
@ -517,7 +517,7 @@ class CommandLineReport(object):
|
|||||||
if not self.show:
|
if not self.show:
|
||||||
return
|
return
|
||||||
elif self.show == 'all':
|
elif self.show == 'all':
|
||||||
print _(" Available options:")
|
print _(" Available options:").encode(sys.getfilesystemencoding())
|
||||||
for key in sorted(self.options_dict.keys()):
|
for key in sorted(self.options_dict.keys()):
|
||||||
if key in self.options_help:
|
if key in self.options_help:
|
||||||
opt = self.options_help[key]
|
opt = self.options_help[key]
|
||||||
@ -530,12 +530,12 @@ class CommandLineReport(object):
|
|||||||
print optmsg.encode(sys.getfilesystemencoding())
|
print optmsg.encode(sys.getfilesystemencoding())
|
||||||
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"}).encode(sys.getfilesystemencoding())
|
||||||
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'
|
||||||
print ' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0])
|
print ' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0])
|
||||||
print _(" Available values are:")
|
print _(" Available values are:").encode(sys.getfilesystemencoding())
|
||||||
vals = opt[2]
|
vals = opt[2]
|
||||||
if isinstance(vals, (list, tuple)):
|
if isinstance(vals, (list, tuple)):
|
||||||
for val in vals:
|
for val in vals:
|
||||||
@ -549,7 +549,7 @@ class CommandLineReport(object):
|
|||||||
#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, 'donottranslate' : "show=all"})
|
{'optionname' : self.show, 'donottranslate' : "show=all"}).encode(sys.getfilesystemencoding())
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -559,7 +559,7 @@ class CommandLineReport(object):
|
|||||||
def cl_report(database, name, category, report_class, options_class,
|
def cl_report(database, name, category, report_class, options_class,
|
||||||
options_str_dict):
|
options_str_dict):
|
||||||
|
|
||||||
err_msg = _("Failed to write report. ")
|
err_msg = _("Failed to write report. ").encode(sys.getfilesystemencoding())
|
||||||
clr = CommandLineReport(database, name, category, options_class,
|
clr = CommandLineReport(database, name, category, options_class,
|
||||||
options_str_dict)
|
options_str_dict)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user