mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
reformat codebase
This commit is contained in:
@@ -27,7 +27,8 @@ Result/Exit codes:
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
""" Base class for ESC/POS errors """
|
||||
"""Base class for ESC/POS errors"""
|
||||
|
||||
def __init__(self, msg, status=None):
|
||||
Exception.__init__(self)
|
||||
self.msg = msg
|
||||
@@ -40,12 +41,13 @@ class Error(Exception):
|
||||
|
||||
|
||||
class BarcodeTypeError(Error):
|
||||
""" No Barcode type defined.
|
||||
"""No Barcode type defined.
|
||||
|
||||
This exception indicates that no known barcode-type has been entered. The barcode-type has to be
|
||||
one of those specified in :py:meth:`escpos.escpos.Escpos.barcode`.
|
||||
The returned error code is `10`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -56,12 +58,13 @@ class BarcodeTypeError(Error):
|
||||
|
||||
|
||||
class BarcodeSizeError(Error):
|
||||
""" Barcode size is out of range.
|
||||
"""Barcode size is out of range.
|
||||
|
||||
This exception indicates that the values for the barcode size are out of range.
|
||||
The size of the barcode has to be in the range that is specified in :py:meth:`escpos.escpos.Escpos.barcode`.
|
||||
The resulting returncode is `20`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -72,12 +75,13 @@ class BarcodeSizeError(Error):
|
||||
|
||||
|
||||
class BarcodeCodeError(Error):
|
||||
""" No Barcode code was supplied, or it is incorrect.
|
||||
"""No Barcode code was supplied, or it is incorrect.
|
||||
|
||||
No data for the barcode has been supplied in :py:meth:`escpos.escpos.Escpos.barcode` or the the `check` parameter
|
||||
was True and the check failed.
|
||||
The returncode for this exception is `30`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -88,24 +92,28 @@ class BarcodeCodeError(Error):
|
||||
|
||||
|
||||
class ImageSizeError(Error):
|
||||
""" Image height is longer than 255px and can't be printed.
|
||||
"""Image height is longer than 255px and can't be printed.
|
||||
|
||||
The returncode for this exception is `40`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
self.resultcode = 40
|
||||
|
||||
def __str__(self):
|
||||
return "Image height is longer than 255px and can't be printed ({msg})".format(msg=self.msg)
|
||||
return "Image height is longer than 255px and can't be printed ({msg})".format(
|
||||
msg=self.msg
|
||||
)
|
||||
|
||||
|
||||
class ImageWidthError(Error):
|
||||
""" Image width is too large.
|
||||
"""Image width is too large.
|
||||
|
||||
The return code for this exception is `41`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -116,26 +124,30 @@ class ImageWidthError(Error):
|
||||
|
||||
|
||||
class TextError(Error):
|
||||
""" Text string must be supplied to the `text()` method.
|
||||
"""Text string must be supplied to the `text()` method.
|
||||
|
||||
This exception is raised when an empty string is passed to :py:meth:`escpos.escpos.Escpos.text`.
|
||||
The returncode for this exception is `50`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
self.resultcode = 50
|
||||
|
||||
def __str__(self):
|
||||
return "Text string must be supplied to the text() method ({msg})".format(msg=self.msg)
|
||||
return "Text string must be supplied to the text() method ({msg})".format(
|
||||
msg=self.msg
|
||||
)
|
||||
|
||||
|
||||
class CashDrawerError(Error):
|
||||
""" Valid pin must be set in order to send pulse.
|
||||
"""Valid pin must be set in order to send pulse.
|
||||
|
||||
A valid pin number has to be passed onto the method :py:meth:`escpos.escpos.Escpos.cashdraw`.
|
||||
The returncode for this exception is `60`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -146,27 +158,31 @@ class CashDrawerError(Error):
|
||||
|
||||
|
||||
class TabPosError(Error):
|
||||
""" Valid tab positions must be set by using from 1 to 32 tabs, and between 1 and 255 tab size values.
|
||||
"""Valid tab positions must be set by using from 1 to 32 tabs, and between 1 and 255 tab size values.
|
||||
Both values multiplied must not exceed 255, since it is the maximum tab value.
|
||||
|
||||
This exception is raised by :py:meth:`escpos.escpos.Escpos.control`.
|
||||
The returncode for this exception is `70`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
self.resultcode = 70
|
||||
|
||||
def __str__(self):
|
||||
return "Valid tab positions must be in the range 0 to 16 ({msg})".format(msg=self.msg)
|
||||
return "Valid tab positions must be in the range 0 to 16 ({msg})".format(
|
||||
msg=self.msg
|
||||
)
|
||||
|
||||
|
||||
class CharCodeError(Error):
|
||||
""" Valid char code must be set.
|
||||
"""Valid char code must be set.
|
||||
|
||||
The supplied charcode-name in :py:meth:`escpos.escpos.Escpos.charcode` is unknown.
|
||||
Ths returncode for this exception is `80`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -177,11 +193,12 @@ class CharCodeError(Error):
|
||||
|
||||
|
||||
class USBNotFoundError(Error):
|
||||
""" Device wasn't found (probably not plugged in)
|
||||
"""Device wasn't found (probably not plugged in)
|
||||
|
||||
The USB device seems to be not plugged in.
|
||||
Ths returncode for this exception is `90`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -192,11 +209,12 @@ class USBNotFoundError(Error):
|
||||
|
||||
|
||||
class SetVariableError(Error):
|
||||
""" A set method variable was out of range
|
||||
"""A set method variable was out of range
|
||||
|
||||
Check set variables against minimum and maximum values
|
||||
Ths returncode for this exception is `100`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -208,12 +226,14 @@ class SetVariableError(Error):
|
||||
|
||||
# Configuration errors
|
||||
|
||||
|
||||
class ConfigNotFoundError(Error):
|
||||
""" The configuration file was not found
|
||||
"""The configuration file was not found
|
||||
|
||||
The default or passed configuration file could not be read
|
||||
Ths returncode for this exception is `200`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -224,11 +244,12 @@ class ConfigNotFoundError(Error):
|
||||
|
||||
|
||||
class ConfigSyntaxError(Error):
|
||||
""" The configuration file is invalid
|
||||
"""The configuration file is invalid
|
||||
|
||||
The syntax is incorrect
|
||||
Ths returncode for this exception is `210`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
@@ -239,11 +260,12 @@ class ConfigSyntaxError(Error):
|
||||
|
||||
|
||||
class ConfigSectionMissingError(Error):
|
||||
""" The configuration file is missing a section
|
||||
"""The configuration file is missing a section
|
||||
|
||||
The part of the config asked for doesn't exist in the loaded configuration
|
||||
Ths returncode for this exception is `220`.
|
||||
"""
|
||||
|
||||
def __init__(self, msg=""):
|
||||
Error.__init__(self, msg)
|
||||
self.msg = msg
|
||||
|
Reference in New Issue
Block a user