From 8763eba86c1687193ee46d7911b2d08ccd2062dd Mon Sep 17 00:00:00 2001 From: belono Date: Thu, 17 Aug 2023 21:19:42 +0200 Subject: [PATCH] self-open mechanism through the 'device' property --- src/escpos/escpos.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index a679510..fadd4df 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -114,7 +114,7 @@ class Escpos(object): class. """ - _device = False + _device = False # False -> Uninitialized def __init__(self, profile=None, magic_encode_args=None, **kwargs) -> None: """Initialize ESCPOS Printer. @@ -130,9 +130,14 @@ class Escpos(object): @property def device(self): - """Implements a self-open mechanism.""" + """Implements a self-open mechanism. + + An attempt to get the property before open the connection + will cause the connection to open. + """ if self._device is False: # Open device if not previously opened + self._device = None # None -> Initialized self.open() return self._device