diff --git a/setup.cfg b/setup.cfg index 64dd7c7..5e7ceb6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,5 +16,6 @@ require-code = True # FI16 __future__ import "nested_scopes" missing # FI17 __future__ import "generators" missing # FI5x __future__ import "xxx" present -ignore = FI12,FI15,FI16,FI17,FI5 +# I101 Imported names are in the wrong order. +ignore = FI12,FI15,FI16,FI17,FI5, I101 copyright-check = True diff --git a/src/escpos/capabilities.py b/src/escpos/capabilities.py index c39d8c8..cebcfe8 100644 --- a/src/escpos/capabilities.py +++ b/src/escpos/capabilities.py @@ -3,17 +3,17 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import re -from os import environ, path -import pickle import logging +import pickle +import platform +import re import time +from os import environ, path +from tempfile import gettempdir import six -import yaml -from tempfile import gettempdir -import platform +import yaml logging.basicConfig() logger = logging.getLogger(__name__) diff --git a/src/escpos/cli.py b/src/escpos/cli.py index dcc377d..7728c5b 100644 --- a/src/escpos/cli.py +++ b/src/escpos/cli.py @@ -15,13 +15,15 @@ from __future__ import print_function from __future__ import unicode_literals import argparse +import sys + try: import argcomplete except ImportError: # this CLI works nevertheless without argcomplete pass # noqa -import sys import six + from . import config from . import version diff --git a/src/escpos/codepages.py b/src/escpos/codepages.py index ca63ef3..a015ea4 100644 --- a/src/escpos/codepages.py +++ b/src/escpos/codepages.py @@ -1,3 +1,8 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + from .capabilities import CAPABILITIES diff --git a/src/escpos/config.py b/src/escpos/config.py index 7528934..d6a708f 100644 --- a/src/escpos/config.py +++ b/src/escpos/config.py @@ -10,11 +10,13 @@ from __future__ import print_function from __future__ import unicode_literals import os + import appdirs + import yaml -from . import printer from . import exceptions +from . import printer class Config(object): diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index f7a9fa5..f6ff53b 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -15,42 +15,41 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -import qrcode +import os import textwrap -import six import time +from abc import ABCMeta, abstractmethod # abstract base class support from re import match as re_match import barcode from barcode.writer import ImageWriter -import os +import qrcode -from .constants import ESC, GS, NUL, QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_H, QR_ECLEVEL_Q -from .constants import QR_MODEL_1, QR_MODEL_2, QR_MICRO, BARCODE_TYPES, BARCODE_HEIGHT, BARCODE_WIDTH +import six + +from .capabilities import BARCODE_B, get_profile from .constants import BARCODE_FONT_A, BARCODE_FONT_B, BARCODE_FORMATS from .constants import BARCODE_TXT_OFF, BARCODE_TXT_BTH, BARCODE_TXT_ABV, BARCODE_TXT_BLW -from .constants import TXT_SIZE, TXT_NORMAL -from .constants import SET_FONT +from .constants import BARCODE_TYPES, BARCODE_HEIGHT, BARCODE_WIDTH +from .constants import CD_KICK_DEC_SEQUENCE, CD_KICK_5, CD_KICK_2, PAPER_FULL_CUT, PAPER_PART_CUT +from .constants import CTL_VT, CTL_CR, CTL_FF, CTL_LF, CTL_SET_HT, PANEL_BUTTON_OFF, PANEL_BUTTON_ON +from .constants import ESC, GS, NUL, QR_ECLEVEL_L, QR_ECLEVEL_M, QR_ECLEVEL_H, QR_ECLEVEL_Q +from .constants import HW_INIT, HW_RESET, HW_SELECT from .constants import LINESPACING_FUNCS, LINESPACING_RESET from .constants import LINE_DISPLAY_OPEN, LINE_DISPLAY_CLEAR, LINE_DISPLAY_CLOSE -from .constants import CD_KICK_DEC_SEQUENCE, CD_KICK_5, CD_KICK_2, PAPER_FULL_CUT, PAPER_PART_CUT -from .constants import HW_RESET, HW_SELECT, HW_INIT -from .constants import CTL_VT, CTL_CR, CTL_FF, CTL_LF, CTL_SET_HT, PANEL_BUTTON_OFF, PANEL_BUTTON_ON -from .constants import TXT_STYLE -from .constants import RT_STATUS_ONLINE, RT_MASK_ONLINE +from .constants import QR_MODEL_1, QR_MODEL_2, QR_MICRO +from .constants import RT_MASK_ONLINE, RT_STATUS_ONLINE from .constants import RT_STATUS_PAPER, RT_MASK_PAPER, RT_MASK_LOWPAPER, RT_MASK_NOPAPER - -from .exceptions import BarcodeTypeError, BarcodeSizeError, TabPosError -from .exceptions import CashDrawerError, SetVariableError, BarcodeCodeError -from .exceptions import ImageWidthError - +from .constants import SET_FONT +from .constants import TXT_SIZE, TXT_NORMAL +from .constants import TXT_STYLE +from .exceptions import BarcodeCodeError, BarcodeSizeError, BarcodeTypeError +from .exceptions import CashDrawerError, ImageWidthError +from .exceptions import SetVariableError, TabPosError +from .image import EscposImage from .magicencode import MagicEncode -from abc import ABCMeta, abstractmethod # abstract base class support -from escpos.image import EscposImage -from escpos.capabilities import get_profile, BARCODE_B - @six.add_metaclass(ABCMeta) class Escpos(object): @@ -409,17 +408,17 @@ class Escpos(object): if bc in BARCODE_TYPES['B']: if not self.profile.supports(BARCODE_B): raise BarcodeTypeError(( - 'Barcode type '{bc} not supported for ' + "Barcode type '{bc}' not supported for " 'the current printer profile').format(bc=bc)) function_type = 'B' else: raise BarcodeTypeError(( - 'Barcode type '{bc} is not valid').format(bc=bc)) + "Barcode type '{bc}' is not valid").format(bc=bc)) bc_types = BARCODE_TYPES[function_type.upper()] if bc.upper() not in bc_types.keys(): raise BarcodeTypeError(( - 'Barcode '{bc}' not valid for barcode function type ' + "Barcode '{bc}' not valid for barcode function type " '{function_type}').format( bc=bc, function_type=function_type, @@ -427,7 +426,7 @@ class Escpos(object): if check and not self.check_barcode(bc, code): raise BarcodeCodeError(( - 'Barcode '{code}' not in a valid format for type '{bc}'').format( + "Barcode '{code}' not in a valid format for type '{bc}'").format( code=code, bc=bc, )) @@ -671,7 +670,7 @@ class Escpos(object): mode = mode.upper() if mode not in ('FULL', 'PART'): - raise ValueError('Mode must be one of ('FULL', 'PART')') + raise ValueError("Mode must be one of ('FULL', 'PART')") if mode == 'PART': if self.profile.supports('paperPartCut'): diff --git a/src/escpos/image.py b/src/escpos/image.py index e428048..5556336 100644 --- a/src/escpos/image.py +++ b/src/escpos/image.py @@ -14,6 +14,7 @@ from __future__ import print_function from __future__ import unicode_literals import math + from PIL import Image, ImageOps diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 12eb0fb..d80bc00 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -18,10 +18,12 @@ from __future__ import print_function from __future__ import unicode_literals from builtins import bytes + +import six + +from .codepages import CodePages from .constants import CODEPAGE_CHANGE from .exceptions import Error -from .codepages import CodePages -import six class Encoder(object): diff --git a/src/escpos/printer.py b/src/escpos/printer.py index 1d7e644..40e7c43 100644 --- a/src/escpos/printer.py +++ b/src/escpos/printer.py @@ -13,10 +13,12 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals +import socket + +import serial + import usb.core import usb.util -import serial -import socket from .escpos import Escpos from .exceptions import USBNotFoundError