sort with isort

This commit is contained in:
Patrick Kanzler 2023-08-10 22:09:29 +02:00
parent b82c8526b2
commit b8dfd47422
36 changed files with 147 additions and 126 deletions

View File

@ -12,9 +12,8 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import sys
import os import os
import sys
from importlib.metadata import version as imp_version from importlib.metadata import version as imp_version
on_rtd = os.getenv("READTHEDOCS") == "True" on_rtd = os.getenv("READTHEDOCS") == "True"

View File

@ -1,6 +1,5 @@
from escpos.printer import Usb from escpos.printer import Usb
# Adapt to your needs # Adapt to your needs
p = Usb(0x0416, 0x5011, profile="TM-T88II") p = Usb(0x0416, 0x5011, profile="TM-T88II")

View File

@ -2,18 +2,19 @@
""" """
import six
import sys import sys
import six
from escpos import printer from escpos import printer
from escpos.constants import ( from escpos.constants import (
CODEPAGE_CHANGE, CODEPAGE_CHANGE,
ESC,
CTL_LF,
CTL_FF,
CTL_CR, CTL_CR,
CTL_FF,
CTL_HT, CTL_HT,
CTL_LF,
CTL_VT, CTL_VT,
ESC,
) )

View File

@ -1,6 +1,7 @@
from escpos.printer import CupsPrinter
from flask import Flask from flask import Flask
from escpos.printer import CupsPrinter
# Initialize Flask app # Initialize Flask app
app = Flask(__name__) app = Flask(__name__)

View File

@ -1,6 +1,5 @@
from escpos.printer import Usb from escpos.printer import Usb
# Adapt to your needs # Adapt to your needs
p = Usb(0x0416, 0x5011, profile="POS-5890") p = Usb(0x0416, 0x5011, profile="POS-5890")

View File

@ -13,12 +13,12 @@
# Check out his github: https://github.com/AdamWhitcroft/climacons # Check out his github: https://github.com/AdamWhitcroft/climacons
from datetime import datetime
import calendar import calendar
import urllib
import json import json
import time
import os import os
import time
import urllib
from datetime import datetime
from escpos.printer import Usb from escpos.printer import Usb

View File

@ -2,8 +2,8 @@
import os import os
import sys import sys
from setuptools import find_packages, setup
from setuptools import find_packages, setup
base_dir = os.path.dirname(__file__) base_dir = os.path.dirname(__file__)
src_dir = os.path.join(base_dir, "src") src_dir = os.path.join(base_dir, "src")

View File

@ -1,20 +1,18 @@
import re
from os import environ, path
import atexit import atexit
import pickle
import logging import logging
import pickle
import platform
import re
import time import time
import importlib_resources from contextlib import ExitStack
from os import environ, path
from tempfile import mkdtemp
from typing import Any, Dict
import importlib_resources
import six import six
import yaml import yaml
from contextlib import ExitStack
from tempfile import mkdtemp
import platform
from typing import Any, Dict
logging.basicConfig() logging.basicConfig()
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -18,9 +18,10 @@ except ImportError:
# this CLI works nevertheless without argcomplete # this CLI works nevertheless without argcomplete
pass # noqa pass # noqa
import sys import sys
import six import six
from . import config
from . import version from . import config, version
# Must be defined before it's used in DEMO_FUNCTIONS # Must be defined before it's used in DEMO_FUNCTIONS

View File

@ -6,11 +6,11 @@ This module contains the implementations of abstract base class :py:class:`Confi
import os import os
import appdirs import appdirs
import yaml import yaml
from . import printer from . import exceptions, printer
from . import exceptions
class Config(object): class Config(object):

View File

@ -11,80 +11,87 @@ This module contains the abstract base class :py:class:`Escpos`.
""" """
import qrcode
import textwrap import textwrap
import six from abc import ABCMeta, abstractmethod # abstract base class support
from re import match as re_match from re import match as re_match
import barcode import barcode
import qrcode
import six
from barcode.writer import ImageWriter from barcode.writer import ImageWriter
from escpos.capabilities import get_profile
from escpos.image import EscposImage
from .constants import ( from .constants import (
ESC, BARCODE_FONT_A,
GS, BARCODE_FONT_B,
NUL, BARCODE_FORMATS,
QR_ECLEVEL_L,
QR_ECLEVEL_M,
QR_ECLEVEL_H,
QR_ECLEVEL_Q,
SHEET_ROLL_MODE,
SHEET_SLIP_MODE,
SLIP_PRINT_AND_EJECT,
SLIP_SELECT,
SLIP_EJECT,
)
from .constants import (
QR_MODEL_1,
QR_MODEL_2,
QR_MICRO,
BARCODE_TYPES,
BARCODE_HEIGHT, BARCODE_HEIGHT,
BARCODE_WIDTH,
)
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_ABV,
BARCODE_TXT_BLW, BARCODE_TXT_BLW,
) BARCODE_TXT_BTH,
from .constants import TXT_SIZE, TXT_NORMAL BARCODE_TXT_OFF,
from .constants import SET_FONT BARCODE_TYPES,
from .constants import LINESPACING_FUNCS, LINESPACING_RESET BARCODE_WIDTH,
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,
BUZZER, BUZZER,
) CD_KICK_2,
from .constants import HW_RESET, HW_SELECT, HW_INIT CD_KICK_5,
from .constants import ( CD_KICK_DEC_SEQUENCE,
CTL_VT,
CTL_CR, CTL_CR,
CTL_FF, CTL_FF,
CTL_LF, CTL_LF,
CTL_SET_HT, CTL_SET_HT,
CTL_VT,
ESC,
GS,
HW_INIT,
HW_RESET,
HW_SELECT,
LINE_DISPLAY_CLEAR,
LINE_DISPLAY_CLOSE,
LINE_DISPLAY_OPEN,
LINESPACING_FUNCS,
LINESPACING_RESET,
NUL,
PANEL_BUTTON_OFF, PANEL_BUTTON_OFF,
PANEL_BUTTON_ON, PANEL_BUTTON_ON,
PAPER_FULL_CUT,
PAPER_PART_CUT,
QR_ECLEVEL_H,
QR_ECLEVEL_L,
QR_ECLEVEL_M,
QR_ECLEVEL_Q,
QR_MICRO,
QR_MODEL_1,
QR_MODEL_2,
RT_MASK_LOWPAPER,
RT_MASK_NOPAPER,
RT_MASK_ONLINE,
RT_MASK_PAPER,
RT_STATUS_ONLINE,
RT_STATUS_PAPER,
SET_FONT,
SHEET_ROLL_MODE,
SHEET_SLIP_MODE,
SLIP_EJECT,
SLIP_PRINT_AND_EJECT,
SLIP_SELECT,
TXT_NORMAL,
TXT_SIZE,
TXT_STYLE,
)
from .exceptions import (
BarcodeCodeError,
BarcodeSizeError,
BarcodeTypeError,
CashDrawerError,
ImageWidthError,
SetVariableError,
TabPosError,
) )
from .constants import TXT_STYLE
from .constants import RT_STATUS_ONLINE, RT_MASK_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 .magicencode import MagicEncode from .magicencode import MagicEncode
from abc import ABCMeta, abstractmethod # abstract base class support
from escpos.image import EscposImage
from escpos.capabilities import get_profile
# Remove special characters and whitespaces of the supported barcode names, # Remove special characters and whitespaces of the supported barcode names,
# convert to uppercase and map them to their original names. # convert to uppercase and map them to their original names.
HW_BARCODE_NAMES = { HW_BARCODE_NAMES = {

View File

@ -10,6 +10,7 @@ This module contains the image format handler :py:class:`EscposImage`.
import math import math
from PIL import Image, ImageOps from PIL import Image, ImageOps

View File

@ -13,12 +13,14 @@ The code is based on the encoding-code in py-xml-escpos by @fvdsn.
""" """
import re
from builtins import bytes from builtins import bytes
import six
from .codepages import CodePages
from .constants import CODEPAGE_CHANGE from .constants import CODEPAGE_CHANGE
from .exceptions import Error from .exceptions import Error
from .codepages import CodePages
import six
import re
class Encoder(object): class Encoder(object):

View File

@ -31,9 +31,10 @@ except ImportError:
_CUPSPRINT = False _CUPSPRINT = False
try: try:
import cups
import tempfile import tempfile
import cups
_CUPSPRINT = True _CUPSPRINT = True
except ImportError: except ImportError:
pass pass

View File

@ -1,4 +1,5 @@
import pytest import pytest
from escpos.printer import Dummy from escpos.printer import Dummy

View File

@ -1,16 +1,18 @@
#!/usr/bin/python #!/usr/bin/python
"""verifies that the metaclass abc is properly used by ESC/POS """verifies that the metaclass abc is properly used by ESC/POS
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 Patrick Kanzler :copyright: Copyright (c) 2016 Patrick Kanzler
:license: MIT :license: MIT
""" """
import pytest
import escpos.escpos as escpos
from abc import ABCMeta from abc import ABCMeta
import pytest
import escpos.escpos as escpos
def test_abstract_base_class_raises(): def test_abstract_base_class_raises():
"""test whether the abstract base class raises an exception for ESC/POS""" """test whether the abstract base class raises an exception for ESC/POS"""

View File

@ -4,10 +4,12 @@
import os import os
import shutil
import tempfile
import pytest import pytest
from scripttest import TestFileEnvironment as TFE from scripttest import TestFileEnvironment as TFE
import tempfile
import shutil
import escpos import escpos
TEST_DIR = tempfile.mkdtemp() + "/cli-test" TEST_DIR = tempfile.mkdtemp() + "/cli-test"

View File

@ -1,10 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
import escpos.printer as printer
from escpos.capabilities import Profile, BARCODE_B
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
import pytest import pytest
import escpos.printer as printer
from escpos.capabilities import BARCODE_B, Profile
from escpos.exceptions import BarcodeCodeError, BarcodeTypeError
@pytest.mark.parametrize( @pytest.mark.parametrize(
"bctype,data,expected", "bctype,data,expected",

View File

@ -1,5 +1,5 @@
import six
import pytest import pytest
import six
from escpos import printer from escpos import printer
from escpos.constants import BUZZER from escpos.constants import BUZZER

View File

@ -1,8 +1,9 @@
#!/usr/bin/python #!/usr/bin/python
import pytest
import escpos.printer as printer import escpos.printer as printer
from escpos.exceptions import CashDrawerError from escpos.exceptions import CashDrawerError
import pytest
def test_raise_CashDrawerError(): def test_raise_CashDrawerError():

View File

@ -2,9 +2,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import escpos.printer as printer
import pytest import pytest
import escpos.printer as printer
@pytest.mark.parametrize( @pytest.mark.parametrize(
"bctype,data", "bctype,data",

View File

@ -9,7 +9,6 @@
import pytest import pytest
from PIL import Image from PIL import Image
import escpos.printer as printer import escpos.printer as printer

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
"""tests for line display """tests for line display
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
"""tests for panel button function """tests for panel button function
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT

View File

@ -2,18 +2,18 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""tests for the non-native part of qr() """tests for the non-native part of qr()
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
""" """
import pytest
import mock import mock
import pytest
from PIL import Image
from escpos.printer import Dummy from escpos.printer import Dummy
from PIL import Image
@mock.patch("escpos.printer.Dummy.image", spec=Dummy) @mock.patch("escpos.printer.Dummy.image", spec=Dummy)

View File

@ -1,9 +1,7 @@
import six import six
import escpos.printer as printer import escpos.printer as printer
from escpos.constants import TXT_NORMAL, TXT_STYLE, SET_FONT from escpos.constants import SET_FONT, TXT_NORMAL, TXT_SIZE, TXT_STYLE
from escpos.constants import TXT_SIZE
# Default test, please copy and paste this block to test set method calls # Default test, please copy and paste this block to test set method calls

View File

@ -1,9 +1,10 @@
#!/usr/bin/python #!/usr/bin/python
import escpos.printer as printer
import barcode.errors import barcode.errors
import pytest import pytest
import escpos.printer as printer
@pytest.fixture @pytest.fixture
def instance(): def instance():

View File

@ -1,17 +1,18 @@
#!/usr/bin/python #!/usr/bin/python
"""tests for the text printing function """tests for the text printing function
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
""" """
import pytest
import mock
from hypothesis import given, assume
import hypothesis.strategies as st import hypothesis.strategies as st
import mock
import pytest
from hypothesis import assume, given
from escpos.printer import Dummy from escpos.printer import Dummy

View File

@ -1,4 +1,5 @@
import pytest import pytest
from escpos.printer import Dummy from escpos.printer import Dummy

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
"""very basic test cases that load the classes """very basic test cases that load the classes
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT

View File

@ -2,19 +2,20 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""tests for the magic encode module """tests for the magic encode module
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
""" """
import pytest
from hypothesis import given, example
import hypothesis.strategies as st import hypothesis.strategies as st
from escpos.magicencode import MagicEncode, Encoder import pytest
from escpos.katakana import encode_katakana from hypothesis import example, given
from escpos.exceptions import CharCodeError, Error from escpos.exceptions import CharCodeError, Error
from escpos.katakana import encode_katakana
from escpos.magicencode import Encoder, MagicEncode
class TestEncoder: class TestEncoder:

View File

@ -2,16 +2,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""tests for the File printer """tests for the File printer
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
""" """
import six
import pytest import pytest
import six
from hypothesis import given, settings from hypothesis import given, settings
from hypothesis.strategies import text from hypothesis.strategies import text

View File

@ -1,10 +1,12 @@
#!/usr/bin/python #!/usr/bin/python
import escpos.printer as printer
import pytest
import mock
import socket import socket
import mock
import pytest
import escpos.printer as printer
@pytest.fixture @pytest.fixture
def instance(): def instance():

View File

@ -1,5 +1,6 @@
import pytest import pytest
from escpos.capabilities import get_profile, NotSupported, BARCODE_B, Profile
from escpos.capabilities import BARCODE_B, NotSupported, Profile, get_profile
@pytest.fixture @pytest.fixture

View File

@ -1,7 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
"""test the raising of errors with the error module """test the raising of errors with the error module
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
@ -9,6 +9,7 @@
import pytest import pytest
import escpos import escpos
import escpos.exceptions import escpos.exceptions

View File

@ -1,15 +1,15 @@
#!/usr/bin/python #!/usr/bin/python
"""test the facility which enables usage of the with-statement """test the facility which enables usage of the with-statement
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_ :author: `Patrick Kanzler <dev@pkanzler.de>`_
:organization: `python-escpos <https://github.com/python-escpos>`_ :organization: `python-escpos <https://github.com/python-escpos>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ :copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT :license: MIT
""" """
import escpos.printer as printer
import escpos.escpos as escpos import escpos.escpos as escpos
import escpos.printer as printer
def test_with_statement(): def test_with_statement():