Match case for printer type discovery
This commit is contained in:
@@ -90,7 +90,8 @@ class Printers:
|
|||||||
hex(dev.idProduct),
|
hex(dev.idProduct),
|
||||||
)
|
)
|
||||||
|
|
||||||
if manufacturer == "EPSON":
|
match (manufacturer):
|
||||||
|
case ("EPSON"):
|
||||||
try:
|
try:
|
||||||
# We create a new EscPosPrinter()
|
# We create a new EscPosPrinter()
|
||||||
self.app.logger.debug("Trying to create a new EPSON printer")
|
self.app.logger.debug("Trying to create a new EPSON printer")
|
||||||
@@ -105,13 +106,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)
|
||||||
|
case ("Brother"):
|
||||||
# We already found the type of printer,
|
|
||||||
# we don't need an extra comparaison.
|
|
||||||
continue
|
|
||||||
|
|
||||||
# or a Brother Printer
|
|
||||||
if manufacturer == "Brother":
|
|
||||||
try:
|
try:
|
||||||
# We create a new BrotherPrinter()
|
# We create a new BrotherPrinter()
|
||||||
self.app.logger.debug("Trying to create a new BROTHER printer")
|
self.app.logger.debug("Trying to create a new BROTHER printer")
|
||||||
@@ -131,6 +126,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)
|
||||||
|
case (_):
|
||||||
|
self.app.logger.debug("Found a printer of unknown manufacturer : %s", manufacturer)
|
||||||
|
# end match
|
||||||
|
|
||||||
self.app.logger.debug("Found %s printers", len(printers))
|
self.app.logger.debug("Found %s printers", len(printers))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user