fix inconsistent behaviour of argparse-code
this affected certain versions of argparse in python3
This commit is contained in:
parent
9f5eed0020
commit
a5cae3adb7
|
@ -456,7 +456,10 @@ def main():
|
|||
# cli [subparser] -args
|
||||
command_subparsers = parser.add_subparsers(
|
||||
title='ESCPOS Command',
|
||||
dest='parser',
|
||||
)
|
||||
# fix inconsistencies in the behaviour of some versions of argparse
|
||||
command_subparsers.required = False # force 'required' testing
|
||||
|
||||
# Build the ESCPOS command arguments
|
||||
for command in ESCPOS_COMMANDS:
|
||||
|
@ -522,6 +525,9 @@ def main():
|
|||
|
||||
target_command = command_arguments.pop('func')
|
||||
|
||||
# remove helper-argument 'parser' from dict
|
||||
command_arguments.pop('parser', None)
|
||||
|
||||
if hasattr(printer, target_command):
|
||||
# print command with args
|
||||
getattr(printer, target_command)(**command_arguments)
|
||||
|
|
Loading…
Reference in New Issue