Migrated `%` string formating

This commit is contained in:
Cody 2016-03-19 20:57:25 +00:00
parent 309866f8c9
commit 58f93e9845
1 changed files with 8 additions and 8 deletions

View File

@ -83,13 +83,13 @@ class Escpos(object):
pbuffer = b'' pbuffer = b''
self._raw(S_RASTER_N) self._raw(S_RASTER_N)
pbuffer = "%02X%02X%02X%02X" % (((size[0]//size[1])//8), 0, size[1] & 0xff, size[1] >> 8) pbuffer = "{0:02X}{1:02X}{2:02X}{3:02X}".format(((size[0]//size[1])//8), 0, size[1] & 0xff, size[1] >> 8)
self._raw(binascii.unhexlify(pbuffer)) self._raw(binascii.unhexlify(pbuffer))
pbuffer = "" pbuffer = ""
while i < len(line): while i < len(line):
hex_string = int(line[i:i+8], 2) hex_string = int(line[i:i+8], 2)
pbuffer += "%02X" % hex_string pbuffer += "{0:02X}".format(hex_string)
i += 8 i += 8
cont += 1 cont += 1
if cont % 4 == 0: if cont % 4 == 0:
@ -135,7 +135,7 @@ class Escpos(object):
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
@ -230,10 +230,10 @@ class Escpos(object):
self._raw(S_RASTER_N) self._raw(S_RASTER_N)
headerX = int(width / 8) headerX = int(width / 8)
headerY = height headerY = height
buf = "%02X" % (headerX & 0xff) buf = "{0:02X}".format((headerX & 0xff))
buf += "%02X" % ((headerX >> 8) & 0xff) buf += "{0:02X}".format(((headerX >> 8) & 0xff))
buf += "%02X" % (headerY & 0xff) buf += "{0:02X}".format((headerY & 0xff))
buf += "%02X" % ((headerY >> 8) & 0xff) buf += "{0:02X}".format(((headerY >> 8) & 0xff))
#self._raw(binascii.unhexlify(buf)) #self._raw(binascii.unhexlify(buf))
for y in range(height): for y in range(height):
for x in range(width): for x in range(width):
@ -246,7 +246,7 @@ class Escpos(object):
i += 1 i += 1
if i == 8: if i == 8:
buf += ("%02X" % temp) buf += ("{0:02X}".format(temp))
mask = 0x80 mask = 0x80
i = 0 i = 0
temp = 0 temp = 0