remove some six usage
This commit is contained in:
parent
bea4f29d28
commit
35565d5564
@ -11,7 +11,6 @@ from tempfile import mkdtemp
|
|||||||
from typing import Any, Dict, Optional, Type
|
from typing import Any, Dict, Optional, Type
|
||||||
|
|
||||||
import importlib_resources
|
import importlib_resources
|
||||||
import six
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
@ -113,7 +112,7 @@ class BaseProfile(object):
|
|||||||
Makes sure that the requested `font` is valid.
|
Makes sure that the requested `font` is valid.
|
||||||
"""
|
"""
|
||||||
font = {"a": 0, "b": 1}.get(font, font)
|
font = {"a": 0, "b": 1}.get(font, font)
|
||||||
if not six.text_type(font) in self.fonts:
|
if not str(font) in self.fonts:
|
||||||
raise NotSupported(
|
raise NotSupported(
|
||||||
'"{}" is not a valid font in the current profile'.format(font)
|
'"{}" is not a valid font in the current profile'.format(font)
|
||||||
)
|
)
|
||||||
@ -122,7 +121,7 @@ class BaseProfile(object):
|
|||||||
def get_columns(self, font):
|
def get_columns(self, font):
|
||||||
"""Return the number of columns for the given font."""
|
"""Return the number of columns for the given font."""
|
||||||
font = self.get_font(font)
|
font = self.get_font(font)
|
||||||
return self.fonts[six.text_type(font)]["columns"]
|
return self.fonts[str(font)]["columns"]
|
||||||
|
|
||||||
def supports(self, feature):
|
def supports(self, feature):
|
||||||
"""Return true/false for the given feature."""
|
"""Return true/false for the given feature."""
|
||||||
|
@ -20,8 +20,6 @@ except ImportError:
|
|||||||
pass # noqa
|
pass # noqa
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
from . import printer as escpos_printer_module
|
from . import printer as escpos_printer_module
|
||||||
from . import version
|
from . import version
|
||||||
@ -581,7 +579,7 @@ def main():
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
command_arguments = dict(
|
command_arguments = dict(
|
||||||
[k, v] for k, v in six.iteritems(args_dict) if v is not None
|
[k, v] for k, v in args_dict.items() if v is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
# If version should be printed, do this, then exit
|
# If version should be printed, do this, then exit
|
||||||
|
@ -866,8 +866,7 @@ class Escpos(object):
|
|||||||
:param txt: text to be printed
|
:param txt: text to be printed
|
||||||
:raises: :py:exc:`~escpos.exceptions.TextError`
|
:raises: :py:exc:`~escpos.exceptions.TextError`
|
||||||
"""
|
"""
|
||||||
txt = six.text_type(txt)
|
self.magic.write(str(txt))
|
||||||
self.magic.write(txt)
|
|
||||||
|
|
||||||
def textln(self, txt=""):
|
def textln(self, txt=""):
|
||||||
"""Print alpha-numeric text with a newline.
|
"""Print alpha-numeric text with a newline.
|
||||||
@ -1420,7 +1419,7 @@ class EscposIO(object):
|
|||||||
params = dict(self.params)
|
params = dict(self.params)
|
||||||
params.update(kwargs)
|
params.update(kwargs)
|
||||||
|
|
||||||
if isinstance(text, six.text_type):
|
if isinstance(text, str):
|
||||||
lines = text.split("\n")
|
lines = text.split("\n")
|
||||||
elif isinstance(text, list) or isinstance(text, tuple):
|
elif isinstance(text, list) or isinstance(text, tuple):
|
||||||
lines = text
|
lines = text
|
||||||
@ -1433,10 +1432,7 @@ class EscposIO(object):
|
|||||||
# TODO flush? or on print? (this should prob rather be handled by the _raw-method)
|
# TODO flush? or on print? (this should prob rather be handled by the _raw-method)
|
||||||
for line in lines:
|
for line in lines:
|
||||||
self.printer.set(**params)
|
self.printer.set(**params)
|
||||||
if isinstance(text, six.text_type):
|
self.printer.text("{0}\n".format(line))
|
||||||
self.printer.text("{0}\n".format(line))
|
|
||||||
else:
|
|
||||||
self.printer.text("{0}\n".format(line))
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""Close printer.
|
"""Close printer.
|
||||||
|
@ -292,7 +292,7 @@ class MagicEncode(object):
|
|||||||
|
|
||||||
def write_with_encoding(self, encoding, text):
|
def write_with_encoding(self, encoding, text):
|
||||||
"""Write the text and inject necessary codepage switches."""
|
"""Write the text and inject necessary codepage switches."""
|
||||||
if text is not None and type(text) is not six.text_type:
|
if text is not None and type(text) is not str:
|
||||||
raise Error(
|
raise Error(
|
||||||
"The supplied text has to be unicode, but is of type {type}.".format(
|
"The supplied text has to be unicode, but is of type {type}.".format(
|
||||||
type=type(text)
|
type=type(text)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import six
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
from escpos.constants import GS
|
from escpos.constants import GS
|
||||||
|
|
||||||
@ -8,5 +6,5 @@ def test_cut_without_feed():
|
|||||||
"""Test cut without feeding paper"""
|
"""Test cut without feeding paper"""
|
||||||
instance = printer.Dummy()
|
instance = printer.Dummy()
|
||||||
instance.cut(feed=False)
|
instance.cut(feed=False)
|
||||||
expected = GS + b"V" + six.int2byte(66) + b"\x00"
|
expected = GS + b"V" + bytes((66,)) + b"\x00"
|
||||||
assert instance.output == expected
|
assert instance.output == expected
|
||||||
|
Loading…
x
Reference in New Issue
Block a user