Merge pull request #397 from python-escpos/use-pkg-resources-for-capabilities-access
use pkg_resources
This commit is contained in:
commit
d960eea4a8
|
@ -3,6 +3,7 @@ Pillow>=2.0
|
|||
qrcode>=4.0
|
||||
pyserial
|
||||
sphinx-rtd-theme
|
||||
setuptools
|
||||
setuptools-scm
|
||||
docutils>=0.12
|
||||
python-barcode>=0.11.0,<1
|
||||
|
|
|
@ -40,6 +40,7 @@ install_requires =
|
|||
qrcode>=4.0
|
||||
pyserial
|
||||
python-barcode>=0.9.1,<1
|
||||
setuptools
|
||||
six
|
||||
appdirs
|
||||
PyYAML
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
from os import environ, path
|
||||
import pkg_resources
|
||||
import pickle
|
||||
import logging
|
||||
import time
|
||||
|
@ -15,9 +16,9 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
|
||||
pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
|
||||
capabilities_path = environ.get(
|
||||
'ESCPOS_CAPABILITIES_FILE',
|
||||
path.join(path.dirname(__file__), 'capabilities.json'))
|
||||
# get a temporary file from pkg_resources if no file is specified in env
|
||||
capabilities_path = environ.get('ESCPOS_CAPABILITIES_FILE',
|
||||
pkg_resources.resource_filename(__name__, 'capabilities.json'))
|
||||
|
||||
# Load external printer database
|
||||
t0 = time.time()
|
||||
|
|
Loading…
Reference in New Issue