Apply linting to printers
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
"""
|
"""
|
||||||
A collection of Printers.
|
A collection of Printers.
|
||||||
|
|
||||||
It has methods to discover printers, and provides an interface for the methods expected from printers.
|
It has methods to discover printers, and provides an interface for
|
||||||
|
the methods expected from printers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Mapping, Set
|
from collections.abc import Set
|
||||||
import usb.core
|
import usb.core
|
||||||
import usb.util
|
import usb.util
|
||||||
from printer import Printer, EscPosPrinter, BrotherPrinter, PrinterType
|
from printer import Printer, EscPosPrinter, BrotherPrinter
|
||||||
|
|
||||||
|
|
||||||
class Printers:
|
class Printers:
|
||||||
@@ -81,7 +82,7 @@ class Printers:
|
|||||||
|
|
||||||
# If the object creation is successfull, we add it to the list of Printers
|
# If the object creation is successfull, we add it to the list of Printers
|
||||||
printers.add(escpos_printer)
|
printers.add(escpos_printer)
|
||||||
self.app.logger.debug("Found a %s printer" % manufacturer)
|
self.app.logger.debug("Found a %s printer", manufacturer)
|
||||||
|
|
||||||
# We already found the type of printer,
|
# We already found the type of printer,
|
||||||
# we don't need an extra comparaison.
|
# we don't need an extra comparaison.
|
||||||
@@ -99,7 +100,7 @@ class Printers:
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.logger.error(
|
self.app.logger.error(
|
||||||
"Could not create a %s printer class with %s:%s" % product,
|
"Could not create a %s printer class with %s:%s" , product,
|
||||||
dev.idVendor,
|
dev.idVendor,
|
||||||
dev.idProduct,
|
dev.idProduct,
|
||||||
)
|
)
|
||||||
@@ -107,9 +108,9 @@ class Printers:
|
|||||||
|
|
||||||
# If the object creation is successfull, we add it to the list of Printers
|
# If the object creation is successfull, we add it to the list of Printers
|
||||||
printers.add(brother_printer)
|
printers.add(brother_printer)
|
||||||
self.app.logger.debug("Found a %s printer" % manufacturer)
|
self.app.logger.debug("Found a %s printer" , manufacturer)
|
||||||
|
|
||||||
self.app.logger.debug("Found %s printers" % len(printers))
|
self.app.logger.debug("Found %s printers" , len(printers))
|
||||||
return printers
|
return printers
|
||||||
|
|
||||||
def any(self) -> Printer:
|
def any(self) -> Printer:
|
||||||
@@ -122,16 +123,20 @@ class Printers:
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError("No printers available")
|
raise RuntimeError("No printers available")
|
||||||
|
|
||||||
def get_printer(self, printer_type):
|
# def get_printer(self, printer_type):
|
||||||
"""
|
# """
|
||||||
Return a specific printer
|
# Return a specific printer
|
||||||
|
|
||||||
printer_type -- a printer type
|
# printer_type -- a printer type
|
||||||
"""
|
# """
|
||||||
return NotImplementedError()
|
# return NotImplementedError()
|
||||||
|
|
||||||
|
|
||||||
class _FindClass:
|
class _FindClass:
|
||||||
|
"""
|
||||||
|
Use by usb.core to modify the way USB devices are found
|
||||||
|
Taken from pyUSB documentation on Github
|
||||||
|
"""
|
||||||
def __init__(self, class_):
|
def __init__(self, class_):
|
||||||
self._class = class_
|
self._class = class_
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user