18 lines
479 B
Python
18 lines
479 B
Python
from escpos.printer import Dummy, Network
|
|
|
|
|
|
class PrinterFactory:
|
|
|
|
def __init__(self, type_="dummy", host="0.0.0.0", port=9100):
|
|
self.type_ = type_
|
|
self.host = host
|
|
self.port = port
|
|
|
|
def _get_printer(self):
|
|
if self.type_ == "dummy":
|
|
return Dummy()
|
|
elif self.type_ == "network":
|
|
return Network(self.host, self.port)
|
|
else:
|
|
raise ValueError(f"Tipo de impresora no soportado: {self.type_}")
|