Migrated `%` string formating
This commit is contained in:
parent
331fe6a93a
commit
4343902024
|
@ -41,13 +41,13 @@ class Escpos:
|
||||||
buffer = ""
|
buffer = ""
|
||||||
|
|
||||||
self._raw(S_RASTER_N)
|
self._raw(S_RASTER_N)
|
||||||
buffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1]&0xff, size[1]>>8)
|
buffer = "{0:02X}{1:02X}{2:02X}{3:02X}".format(((size[0]/size[1])/8), 0, size[1]&0xff, size[1]>>8)
|
||||||
self._raw(buffer.decode('hex'))
|
self._raw(buffer.decode('hex'))
|
||||||
buffer = ""
|
buffer = ""
|
||||||
|
|
||||||
while i < len(line):
|
while i < len(line):
|
||||||
hex_string = int(line[i:i+8],2)
|
hex_string = int(line[i:i+8],2)
|
||||||
buffer += "%02X" % hex_string
|
buffer += "{0:02X}".format(hex_string)
|
||||||
i += 8
|
i += 8
|
||||||
cont += 1
|
cont += 1
|
||||||
if cont % 4 == 0:
|
if cont % 4 == 0:
|
||||||
|
@ -91,7 +91,7 @@ class Escpos:
|
||||||
for x in range(pattern_len):
|
for x in range(pattern_len):
|
||||||
if im_color <= (255 * 3 / pattern_len * (x+1)):
|
if im_color <= (255 * 3 / pattern_len * (x+1)):
|
||||||
if im_pattern[x] == "X":
|
if im_pattern[x] == "X":
|
||||||
pix_line += "%d" % switch
|
pix_line += "{0:d}".format(switch)
|
||||||
else:
|
else:
|
||||||
pix_line += im_pattern[x]
|
pix_line += im_pattern[x]
|
||||||
break
|
break
|
||||||
|
|
|
@ -52,13 +52,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!s}".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!s}".format(str(e))
|
||||||
|
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
@ -114,7 +114,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!s}".format(self.devfile)
|
||||||
|
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
@ -148,7 +148,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!s}".format(self.host)
|
||||||
|
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
@ -178,7 +178,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!s}".format(self.devfile)
|
||||||
|
|
||||||
|
|
||||||
def _raw(self, msg):
|
def _raw(self, msg):
|
||||||
|
|
Loading…
Reference in New Issue