Simplify handling of getops error.
This commit is contained in:
parent
178d3ecb00
commit
1b53a3948a
@ -242,24 +242,25 @@ class ArgParser:
|
|||||||
try:
|
try:
|
||||||
options, leftargs = getopt.getopt(self.args[1:],
|
options, leftargs = getopt.getopt(self.args[1:],
|
||||||
SHORTOPTS, LONGOPTS)
|
SHORTOPTS, LONGOPTS)
|
||||||
except getopt.GetoptError as msg:
|
except getopt.GetoptError as error:
|
||||||
# Extract the arguments in the list.
|
# Extract the arguments in the list.
|
||||||
|
cli_args = "[ %s ]" % " ".join(self.args[1:])
|
||||||
|
|
||||||
# The % operator replaces the list elements
|
# The % operator replaces the list elements
|
||||||
# with repr() of the list elements
|
# with repr() of the list elements
|
||||||
# which is OK for latin characters,
|
# which is OK for latin characters,
|
||||||
# but not for non latin characters in list elements
|
# but not for non latin characters in list elements
|
||||||
cliargs = "[ "
|
translated_error_message = _(
|
||||||
for arg in range(len(self.args) - 1):
|
"Error parsing the arguments: %s \n"
|
||||||
cliargs += self.args[arg + 1] + " "
|
|
||||||
cliargs += "]"
|
|
||||||
# Must first do str() of the msg object.
|
|
||||||
msg = str(msg)
|
|
||||||
self.errors += [(_('Error parsing the arguments'),
|
|
||||||
msg + '\n' +
|
|
||||||
_("Error parsing the arguments: %s \n"
|
|
||||||
"Type gramps --help for an overview of "
|
"Type gramps --help for an overview of "
|
||||||
"commands, or read the manual pages."
|
"commands, or read the manual pages."
|
||||||
) % cliargs)]
|
) % cli_args
|
||||||
|
|
||||||
|
self.errors += [(
|
||||||
|
_('Error parsing the arguments'),
|
||||||
|
str(error) + '\n' + translated_error_message
|
||||||
|
)]
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Some args can work on a list of databases:
|
# Some args can work on a list of databases:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user