REFACTOR replace % op with format were it is easy
This commit is contained in:
parent
f25521f22f
commit
41c6afd3b8
|
@ -90,7 +90,7 @@ def echo(args): # pylint: disable=unused-argument
|
||||||
epson.barcode(data, bctype, 48, 2, '', '')
|
epson.barcode(data, bctype, 48, 2, '', '')
|
||||||
epson.set(align='left')
|
epson.set(align='left')
|
||||||
else:
|
else:
|
||||||
epson.text('%s\n' % line)
|
epson.text('{0}\n'.format(line))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
epson.cut()
|
epson.cut()
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ def _test_barcodes():
|
||||||
):
|
):
|
||||||
# TODO: Fix the library to restore old alignment somehow
|
# TODO: Fix the library to restore old alignment somehow
|
||||||
epson.set(align='center')
|
epson.set(align='center')
|
||||||
epson.text('\n%s\n' % name)
|
epson.text('\n{0}\n'.format(name))
|
||||||
epson.barcode(data, name, 64, 2, '', '')
|
epson.barcode(data, name, 64, 2, '', '')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -348,12 +348,12 @@ class Escpos(object):
|
||||||
if 1 <= height <= 255:
|
if 1 <= height <= 255:
|
||||||
self._raw(BARCODE_HEIGHT + chr(height))
|
self._raw(BARCODE_HEIGHT + chr(height))
|
||||||
else:
|
else:
|
||||||
raise BarcodeSizeError("height = %s" % height)
|
raise BarcodeSizeError("height = {height}".format(height=height))
|
||||||
# Width
|
# Width
|
||||||
if 2 <= width <= 6:
|
if 2 <= width <= 6:
|
||||||
self._raw(BARCODE_WIDTH + chr(width))
|
self._raw(BARCODE_WIDTH + chr(width))
|
||||||
else:
|
else:
|
||||||
raise BarcodeSizeError("width = %s" % width)
|
raise BarcodeSizeError("width = {width}".format(width=width))
|
||||||
# Font
|
# Font
|
||||||
if font.upper() == "B":
|
if font.upper() == "B":
|
||||||
self._raw(BARCODE_FONT_B)
|
self._raw(BARCODE_FONT_B)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class BarcodeTypeError(Error):
|
||||||
self.resultcode = 10
|
self.resultcode = 10
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "No Barcode type is defined (%s)" % self.msg
|
return "No Barcode type is defined ({msg})".format(msg=self.msg)
|
||||||
|
|
||||||
|
|
||||||
class BarcodeSizeError(Error):
|
class BarcodeSizeError(Error):
|
||||||
|
@ -62,7 +62,7 @@ class BarcodeSizeError(Error):
|
||||||
self.resultcode = 20
|
self.resultcode = 20
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Barcode size is out of range (%s)" % self.msg
|
return "Barcode size is out of range ({msg})".format(msg=self.msg)
|
||||||
|
|
||||||
|
|
||||||
class BarcodeCodeError(Error):
|
class BarcodeCodeError(Error):
|
||||||
|
|
|
@ -56,13 +56,13 @@ class Usb(Escpos):
|
||||||
self.device.detach_kernel_driver(0)
|
self.device.detach_kernel_driver(0)
|
||||||
except usb.core.USBError as e:
|
except usb.core.USBError as e:
|
||||||
if check_driver is not None:
|
if check_driver is not None:
|
||||||
print("Could not detatch kernel driver: %s" % str(e))
|
print("Could not detatch kernel driver: {0}".format(str(e)))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.device.set_configuration()
|
self.device.set_configuration()
|
||||||
self.device.reset()
|
self.device.reset()
|
||||||
except usb.core.USBError as e:
|
except usb.core.USBError as e:
|
||||||
print("Could not set configuration: %s" % str(e))
|
print("Could not set configuration: {0}".format(str(e)))
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
""" Print any command sent in raw format
|
""" Print any command sent in raw format
|
||||||
|
@ -120,7 +120,7 @@ class Serial(Escpos):
|
||||||
if self.device is not None:
|
if self.device is not None:
|
||||||
print("Serial printer enabled")
|
print("Serial printer enabled")
|
||||||
else:
|
else:
|
||||||
print("Unable to open serial printer on: %s" % self.devfile)
|
print("Unable to open serial printer on: {0}".format(str(self.devfile)))
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
""" Print any command sent in raw format
|
""" Print any command sent in raw format
|
||||||
|
@ -159,7 +159,7 @@ class Network(Escpos):
|
||||||
self.device.connect((self.host, self.port))
|
self.device.connect((self.host, self.port))
|
||||||
|
|
||||||
if self.device is None:
|
if self.device is None:
|
||||||
print("Could not open socket for %s" % self.host)
|
print("Could not open socket for {0}".format(self.host))
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
""" Print any command sent in raw format
|
""" Print any command sent in raw format
|
||||||
|
@ -195,7 +195,7 @@ class File(Escpos):
|
||||||
self.device = open(self.devfile, "wb")
|
self.device = open(self.devfile, "wb")
|
||||||
|
|
||||||
if self.device is None:
|
if self.device is None:
|
||||||
print("Could not open the specified file %s" % self.devfile)
|
print("Could not open the specified file {0}".format(self.devfile))
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
""" Flush printing content """
|
""" Flush printing content """
|
||||||
|
|
Loading…
Reference in New Issue