use importlib_resources
This commit is contained in:
parent
63f0829a74
commit
cbe61bb984
@ -9,3 +9,4 @@ docutils>=0.12
|
||||
sphinxcontrib-spelling>=7.2.0
|
||||
python-barcode>=0.11.0,<1
|
||||
importlib-metadata
|
||||
importlib_resources
|
||||
|
@ -48,6 +48,7 @@ install_requires =
|
||||
argparse
|
||||
argcomplete
|
||||
future
|
||||
importlib_resources
|
||||
setup_requires = setuptools_scm
|
||||
tests_require =
|
||||
jaconv
|
||||
|
@ -1,13 +1,15 @@
|
||||
import re
|
||||
from os import environ, path
|
||||
import pkg_resources
|
||||
import atexit
|
||||
import pickle
|
||||
import logging
|
||||
import time
|
||||
import importlib_resources
|
||||
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from contextlib import ExitStack
|
||||
from tempfile import mkdtemp
|
||||
import platform
|
||||
|
||||
@ -20,10 +22,13 @@ pickle_dir = environ.get("ESCPOS_CAPABILITIES_PICKLE_DIR", mkdtemp())
|
||||
pickle_path = path.join(
|
||||
pickle_dir, "{v}.capabilities.pickle".format(v=platform.python_version())
|
||||
)
|
||||
# get a temporary file from pkg_resources if no file is specified in env
|
||||
# get a temporary file from importlib_resources if no file is specified in env
|
||||
file_manager = ExitStack()
|
||||
atexit.register(file_manager.close)
|
||||
ref = importlib_resources.files(__name__) / "capabilities.json"
|
||||
capabilities_path = environ.get(
|
||||
"ESCPOS_CAPABILITIES_FILE",
|
||||
pkg_resources.resource_filename(__name__, "capabilities.json"),
|
||||
file_manager.enter_context(importlib_resources.as_file(ref)),
|
||||
)
|
||||
|
||||
# Load external printer database
|
||||
|
Loading…
x
Reference in New Issue
Block a user