pylint changes

This commit is contained in:
Davis Goglin 2016-03-16 16:24:23 -07:00 committed by Davis Goglin
parent 4f92247ed6
commit ca3b4665a2
1 changed files with 43 additions and 37 deletions

View File

@ -11,7 +11,7 @@ from . import config
# Key: The name of escpos function and the argument passed on the CLI. Some # Key: The name of escpos function and the argument passed on the CLI. Some
# manual translation is done in the case of barcodes_a -> barcode. # manual translation is done in the case of barcodes_a -> barcode.
# Value: A list of dictionaries to pass to the escpos function as arguments. # Value: A list of dictionaries to pass to the escpos function as arguments.
demo_functions = { DEMO_FUNCTIONS = {
'text': [ 'text': [
{'txt': 'Hello, World!',} {'txt': 'Hello, World!',}
], ],
@ -56,12 +56,13 @@ def main():
line arguments. Called when run from a CLI. line arguments. Called when run from a CLI.
""" """
c = config.Config() saved_config = config.Config()
printer = c.printer() printer = saved_config.printer()
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='CLI for python-escpos', description='CLI for python-escpos',
epilog='Printer configuration is defined in the python-escpos config file. See documentation for details.', epilog='Printer configuration is defined in the python-escpos config'
'file. See documentation for details.',
) )
command_subparsers = parser.add_subparsers( command_subparsers = parser.add_subparsers(
@ -128,7 +129,8 @@ def main():
required=True required=True
) )
parser_command_block_text = command_subparsers.add_parser('block_text', help='Print wrapped text') parser_command_block_text = command_subparsers.add_parser('block_text',
help='Print wrapped text')
parser_command_block_text.set_defaults(func='block_text') parser_command_block_text.set_defaults(func='block_text')
parser_command_block_text.add_argument( parser_command_block_text.add_argument(
'--txt', '--txt',
@ -194,10 +196,12 @@ def main():
) )
# Not supported # Not supported
# parser_command_direct_image = command_subparsers.add_parser('direct_direct_image', help='Print an direct_image') # parser_command_direct_image = command_subparsers.add_parser('direct_direct_image',
# help='Print an direct_image')
# parser_command_direct_image.set_defaults(func='direct_image') # parser_command_direct_image.set_defaults(func='direct_image')
parser_command_charcode = command_subparsers.add_parser('charcode', help='Set character code table') parser_command_charcode = command_subparsers.add_parser('charcode',
help='Set character code table')
parser_command_charcode.set_defaults(func='charcode') parser_command_charcode.set_defaults(func='charcode')
parser_command_charcode.add_argument( parser_command_charcode.add_argument(
'--code', '--code',
@ -276,7 +280,8 @@ def main():
type=int type=int
) )
parser_command_panel_buttons = command_subparsers.add_parser('panel_buttons', help='Disables panel buttons') parser_command_panel_buttons = command_subparsers.add_parser('panel_buttons',
help='Disables panel buttons')
parser_command_panel_buttons.set_defaults(func='panel_buttons') parser_command_panel_buttons.set_defaults(func='panel_buttons')
parser_command_panel_buttons.add_argument( parser_command_panel_buttons.add_argument(
'--enable', '--enable',
@ -285,7 +290,8 @@ def main():
required=True required=True
) )
parser_command_demo = command_subparsers.add_parser('demo', help='Demonstrates various functions') parser_command_demo = command_subparsers.add_parser('demo',
help='Demonstrates various functions')
parser_command_demo.set_defaults(func='demo') parser_command_demo.set_defaults(func='demo')
demo_group = parser_command_demo.add_mutually_exclusive_group() demo_group = parser_command_demo.add_mutually_exclusive_group()
demo_group.add_argument( demo_group.add_argument(
@ -332,7 +338,7 @@ def main():
def demo(printer, **kwargs): def demo(printer, **kwargs):
""" """
Prints specificed demos. Called when CLI is passed `demo`. This function Prints specificed demos. Called when CLI is passed `demo`. This function
uses the demo_functions dictionary. uses the DEMO_FUNCTIONS dictionary.
:param printer: A printer from escpos.printer :param printer: A printer from escpos.printer
:param kwargs: A dict with a key for each function you want to test. It's :param kwargs: A dict with a key for each function you want to test. It's
@ -345,7 +351,7 @@ def demo(printer, **kwargs):
.replace('barcodes_a', 'barcode') .replace('barcodes_a', 'barcode')
.replace('barcodes_b', 'barcode') .replace('barcodes_b', 'barcode')
) )
for params in demo_functions[demo_choice]: for params in DEMO_FUNCTIONS[demo_choice]:
command(**params) command(**params)
if __name__ == '__main__': if __name__ == '__main__':