Move platform dependent printers' guard to init

This commit is contained in:
belono 2023-10-14 01:35:37 +02:00
parent 8f54dfed00
commit dfd48e229d
3 changed files with 1 additions and 6 deletions

View File

@ -176,7 +176,6 @@ class CupsPrinter(Escpos):
self.pending_job = False
raise ValueError("Printer job not opened")
@dependency_pycups
def send(self):
"""Send the print job to the printer."""
if self.pending_job:

View File

@ -63,6 +63,7 @@ class LP(Escpos):
"""
return is_usable()
@dependency_linux_lp
def __init__(self, printer_name: str = "", *args, **kwargs):
"""LP class constructor.
@ -108,7 +109,6 @@ class LP(Escpos):
return ""
return name
@dependency_linux_lp
def open(
self,
job_name: str = "python-escpos",

View File

@ -87,7 +87,6 @@ class Win32Raw(Escpos):
] = False
@property
@dependency_win32print
def printers(self) -> dict:
"""Available Windows printers."""
return {
@ -95,7 +94,6 @@ class Win32Raw(Escpos):
for printer in win32print.EnumPrinters(win32print.PRINTER_ENUM_NAME, "", 4)
}
@dependency_win32print
def open(
self, job_name: str = "python-escpos", raise_not_found: bool = True
) -> None:
@ -138,7 +136,6 @@ class Win32Raw(Escpos):
return
logging.info("Win32Raw printer enabled")
@dependency_win32print
def close(self) -> None:
"""Close connection to default printer."""
if not self._device:
@ -149,7 +146,6 @@ class Win32Raw(Escpos):
win32print.ClosePrinter(self._device)
self._device = False
@dependency_win32print
def _raw(self, msg):
"""Print any command sent in raw format.