REFACTOR do not shadow built-ins
This commit is contained in:
parent
07d8e073ae
commit
ef8035527c
|
@ -37,21 +37,21 @@ class Escpos(object):
|
||||||
""" Print formatted image """
|
""" Print formatted image """
|
||||||
i = 0
|
i = 0
|
||||||
cont = 0
|
cont = 0
|
||||||
buffer = ""
|
pbuffer = ""
|
||||||
|
|
||||||
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)
|
pbuffer = "%02X%02X%02X%02X" % (((size[0]/size[1])/8), 0, size[1] & 0xff, size[1] >> 8)
|
||||||
self._raw(buffer.decode('hex'))
|
self._raw(pbuffer.decode('hex'))
|
||||||
buffer = ""
|
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)
|
||||||
buffer += "%02X" % hex_string
|
pbuffer += "%02X" % hex_string
|
||||||
i += 8
|
i += 8
|
||||||
cont += 1
|
cont += 1
|
||||||
if cont % 4 == 0:
|
if cont % 4 == 0:
|
||||||
self._raw(buffer.decode("hex"))
|
self._raw(pbuffer.decode("hex"))
|
||||||
buffer = ""
|
pbuffer = ""
|
||||||
cont = 0
|
cont = 0
|
||||||
|
|
||||||
def _convert_image(self, im):
|
def _convert_image(self, im):
|
||||||
|
@ -231,7 +231,7 @@ class Escpos(object):
|
||||||
else:
|
else:
|
||||||
raise TextError()
|
raise TextError()
|
||||||
|
|
||||||
def set(self, align='left', font='a', type='normal', width=1, height=1, density=9):
|
def set(self, align='left', font='a', text_type='normal', width=1, height=1, density=9):
|
||||||
""" Set text properties """
|
""" Set text properties """
|
||||||
# Width
|
# Width
|
||||||
if height == 2 and width == 2:
|
if height == 2 and width == 2:
|
||||||
|
@ -246,22 +246,22 @@ class Escpos(object):
|
||||||
else: # DEFAULT SIZE: NORMAL
|
else: # DEFAULT SIZE: NORMAL
|
||||||
self._raw(TXT_NORMAL)
|
self._raw(TXT_NORMAL)
|
||||||
# Type
|
# Type
|
||||||
if type.upper() == "B":
|
if text_type.upper() == "B":
|
||||||
self._raw(TXT_BOLD_ON)
|
self._raw(TXT_BOLD_ON)
|
||||||
self._raw(TXT_UNDERL_OFF)
|
self._raw(TXT_UNDERL_OFF)
|
||||||
elif type.upper() == "U":
|
elif text_type.upper() == "U":
|
||||||
self._raw(TXT_BOLD_OFF)
|
self._raw(TXT_BOLD_OFF)
|
||||||
self._raw(TXT_UNDERL_ON)
|
self._raw(TXT_UNDERL_ON)
|
||||||
elif type.upper() == "U2":
|
elif text_type.upper() == "U2":
|
||||||
self._raw(TXT_BOLD_OFF)
|
self._raw(TXT_BOLD_OFF)
|
||||||
self._raw(TXT_UNDERL2_ON)
|
self._raw(TXT_UNDERL2_ON)
|
||||||
elif type.upper() == "BU":
|
elif text_type.upper() == "BU":
|
||||||
self._raw(TXT_BOLD_ON)
|
self._raw(TXT_BOLD_ON)
|
||||||
self._raw(TXT_UNDERL_ON)
|
self._raw(TXT_UNDERL_ON)
|
||||||
elif type.upper() == "BU2":
|
elif text_type.upper() == "BU2":
|
||||||
self._raw(TXT_BOLD_ON)
|
self._raw(TXT_BOLD_ON)
|
||||||
self._raw(TXT_UNDERL2_ON)
|
self._raw(TXT_UNDERL2_ON)
|
||||||
elif type.upper == "NORMAL":
|
elif text_type.upper == "NORMAL":
|
||||||
self._raw(TXT_BOLD_OFF)
|
self._raw(TXT_BOLD_OFF)
|
||||||
self._raw(TXT_UNDERL_OFF)
|
self._raw(TXT_UNDERL_OFF)
|
||||||
# Font
|
# Font
|
||||||
|
|
|
@ -85,7 +85,7 @@ class CashDrawerError(Error):
|
||||||
return "Valid pin must be set to send pulse"
|
return "Valid pin must be set to send pulse"
|
||||||
|
|
||||||
|
|
||||||
class TabError(Error):
|
class TabPosError(Error):
|
||||||
def __init__(self, msg=""):
|
def __init__(self, msg=""):
|
||||||
Error.__init__(self, msg)
|
Error.__init__(self, msg)
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
|
Loading…
Reference in New Issue