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
# serve to show the default.
import sys
import os
import sys
from importlib.metadata import version as imp_version
on_rtd = os.getenv("READTHEDOCS") == "True"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,18 @@
import re
from os import environ, path
import atexit
import pickle
import logging
import pickle
import platform
import re
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 yaml
from contextlib import ExitStack
from tempfile import mkdtemp
import platform
from typing import Any, Dict
logging.basicConfig()
logger = logging.getLogger(__name__)

View File

@ -18,9 +18,10 @@ except ImportError:
# this CLI works nevertheless without argcomplete
pass # noqa
import sys
import six
from . import config
from . import version
from . import config, version
# 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 appdirs
import yaml
from . import printer
from . import exceptions
from . import exceptions, printer
class Config(object):

View File

@ -11,80 +11,87 @@ This module contains the abstract base class :py:class:`Escpos`.
"""
import qrcode
import textwrap
import six
from abc import ABCMeta, abstractmethod # abstract base class support
from re import match as re_match
import barcode
import qrcode
import six
from barcode.writer import ImageWriter
from escpos.capabilities import get_profile
from escpos.image import EscposImage
from .constants import (
ESC,
GS,
NUL,
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_FONT_A,
BARCODE_FONT_B,
BARCODE_FORMATS,
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_BLW,
)
from .constants import TXT_SIZE, TXT_NORMAL
from .constants import SET_FONT
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,
BARCODE_TXT_BTH,
BARCODE_TXT_OFF,
BARCODE_TYPES,
BARCODE_WIDTH,
BUZZER,
)
from .constants import HW_RESET, HW_SELECT, HW_INIT
from .constants import (
CTL_VT,
CD_KICK_2,
CD_KICK_5,
CD_KICK_DEC_SEQUENCE,
CTL_CR,
CTL_FF,
CTL_LF,
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_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 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,
# convert to uppercase and map them to their original names.
HW_BARCODE_NAMES = {

View File

@ -10,6 +10,7 @@ This module contains the image format handler :py:class:`EscposImage`.
import math
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
import six
from .codepages import CodePages
from .constants import CODEPAGE_CHANGE
from .exceptions import Error
from .codepages import CodePages
import six
import re
class Encoder(object):

View File

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

View File

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

View File

@ -1,16 +1,18 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2016 Patrick Kanzler
:license: MIT
"""
import pytest
import escpos.escpos as escpos
from abc import ABCMeta
import pytest
import escpos.escpos as escpos
def test_abstract_base_class_raises():
"""test whether the abstract base class raises an exception for ESC/POS"""

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
:license: MIT

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT

View File

@ -2,18 +2,18 @@
# -*- coding: utf-8 -*-
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
import pytest
import mock
import pytest
from PIL import Image
from escpos.printer import Dummy
from PIL import Image
@mock.patch("escpos.printer.Dummy.image", spec=Dummy)

View File

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

View File

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

View File

@ -1,17 +1,18 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
import pytest
import mock
from hypothesis import given, assume
import hypothesis.strategies as st
import mock
import pytest
from hypothesis import assume, given
from escpos.printer import Dummy

View File

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

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT

View File

@ -2,19 +2,20 @@
# -*- coding: utf-8 -*-
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
import pytest
from hypothesis import given, example
import hypothesis.strategies as st
from escpos.magicencode import MagicEncode, Encoder
from escpos.katakana import encode_katakana
import pytest
from hypothesis import example, given
from escpos.exceptions import CharCodeError, Error
from escpos.katakana import encode_katakana
from escpos.magicencode import Encoder, MagicEncode
class TestEncoder:

View File

@ -2,16 +2,15 @@
# -*- coding: utf-8 -*-
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
import six
import pytest
import six
from hypothesis import given, settings
from hypothesis.strategies import text

View File

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

View File

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

View File

@ -1,7 +1,7 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
@ -9,6 +9,7 @@
import pytest
import escpos
import escpos.exceptions

View File

@ -1,15 +1,15 @@
#!/usr/bin/python
"""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>`_
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
:license: MIT
"""
import escpos.printer as printer
import escpos.escpos as escpos
import escpos.printer as printer
def test_with_statement():