Deprecate pywin32-stubs, too
This commit is contained in:
parent
72a1a10faa
commit
8f54dfed00
@ -68,13 +68,11 @@ cups =
|
|||||||
pycups; platform_system!='Windows'
|
pycups; platform_system!='Windows'
|
||||||
win32 =
|
win32 =
|
||||||
pywin32; platform_system=='Windows'
|
pywin32; platform_system=='Windows'
|
||||||
pywin32-stubs; platform_system=='Windows'
|
|
||||||
all =
|
all =
|
||||||
pyusb>=1.0.0
|
pyusb>=1.0.0
|
||||||
pyserial
|
pyserial
|
||||||
pycups; platform_system!='Windows'
|
pycups; platform_system!='Windows'
|
||||||
pywin32; platform_system=='Windows'
|
pywin32; platform_system=='Windows'
|
||||||
pywin32-stubs; platform_system=='Windows'
|
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py
|
exclude = .git,.tox,.github,.eggs,__pycache__,doc/conf.py,build,dist,capabilities-data,test,src/escpos/constants.py
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from typing import Literal, Optional, Union
|
from typing import Literal, Optional, Type, Union
|
||||||
|
|
||||||
from ..escpos import Escpos
|
from ..escpos import Escpos
|
||||||
from ..exceptions import DeviceNotFoundError
|
from ..exceptions import DeviceNotFoundError
|
||||||
@ -20,8 +20,6 @@ _DEP_WIN32PRINT = False
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pywintypes
|
|
||||||
import win32helper.win32typing as _win32typing # pywin32-stubs package
|
|
||||||
import win32print
|
import win32print
|
||||||
|
|
||||||
_DEP_WIN32PRINT = True
|
_DEP_WIN32PRINT = True
|
||||||
@ -83,7 +81,9 @@ class Win32Raw(Escpos):
|
|||||||
self.job_name = ""
|
self.job_name = ""
|
||||||
|
|
||||||
self._device: Union[
|
self._device: Union[
|
||||||
Literal[False], Literal[None], "_win32typing.PyPrinterHANDLE"
|
Literal[False],
|
||||||
|
Literal[None],
|
||||||
|
Type[win32print.OpenPrinter],
|
||||||
] = False
|
] = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -118,14 +118,14 @@ class Win32Raw(Escpos):
|
|||||||
assert self.printer_name in self.printers, "Incorrect printer name"
|
assert self.printer_name in self.printers, "Incorrect printer name"
|
||||||
# Open device
|
# Open device
|
||||||
self.device: Optional[
|
self.device: Optional[
|
||||||
"_win32typing.PyPrinterHANDLE"
|
Type[win32print.OpenPrinter]
|
||||||
] = win32print.OpenPrinter(self.printer_name)
|
] = win32print.OpenPrinter(self.printer_name)
|
||||||
if self.device:
|
if self.device:
|
||||||
self.current_job = win32print.StartDocPrinter(
|
self.current_job = win32print.StartDocPrinter(
|
||||||
self.device, 1, (job_name, None, "RAW")
|
self.device, 1, (job_name, None, "RAW")
|
||||||
)
|
)
|
||||||
win32print.StartPagePrinter(self.device)
|
win32print.StartPagePrinter(self.device)
|
||||||
except (AssertionError, pywintypes.error) as e:
|
except AssertionError as e:
|
||||||
# Raise exception or log error and cancel
|
# Raise exception or log error and cancel
|
||||||
self.device = None
|
self.device = None
|
||||||
if raise_not_found:
|
if raise_not_found:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user