Match case for printer type discovery

This commit is contained in:
n07070
2026-11-13 03:01:21 +01:00
parent df070ebd72
commit ba7e854a6f

View File

@@ -90,7 +90,8 @@ class Printers:
hex(dev.idProduct),
)
if manufacturer == "EPSON":
match (manufacturer):
case ("EPSON"):
try:
# We create a new EscPosPrinter()
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
printers.add(escpos_printer)
self.app.logger.debug("Found a %s printer", manufacturer)
# We already found the type of printer,
# we don't need an extra comparaison.
continue
# or a Brother Printer
if manufacturer == "Brother":
case ("Brother"):
try:
# We create a new BrotherPrinter()
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
printers.add(brother_printer)
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))