mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ef34cca463 | ||
![]() |
4680fb16b1 | ||
![]() |
544bb4f904 | ||
![]() |
d330dd80fd | ||
![]() |
570661b3c8 | ||
![]() |
aa7f2773eb | ||
![]() |
ff39908674 | ||
![]() |
d960eea4a8 | ||
![]() |
f7962576b4 | ||
![]() |
f4e214ad17 | ||
![]() |
9e406efc86 | ||
![]() |
b9e3827867 | ||
![]() |
cbe412cfdb | ||
![]() |
42554d836c | ||
![]() |
8ca682e3ac | ||
![]() |
ab30ef4a8c | ||
![]() |
725f1254aa | ||
![]() |
1e313cefc6 | ||
![]() |
b0ea9aec41 | ||
![]() |
ab210b5996 | ||
![]() |
f3e1db8da2 | ||
![]() |
1e7b43a92d | ||
![]() |
0e41709703 | ||
![]() |
cb30d7a881 | ||
![]() |
142fc4af71 | ||
![]() |
8f71372bb0 | ||
![]() |
6a60b6706e | ||
![]() |
c14a414924 | ||
![]() |
faa9414da5 | ||
![]() |
2c4552a528 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -31,4 +31,8 @@ test/test-cli-output/
|
|||||||
*.swo
|
*.swo
|
||||||
|
|
||||||
# vscode
|
# vscode
|
||||||
.vscode/settings.json
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
@@ -8,9 +8,7 @@ addons:
|
|||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- graphviz
|
- graphviz
|
||||||
env:
|
- libenchant1c2a
|
||||||
global:
|
|
||||||
- ESCPOS_CAPABILITIES_FILE=/home/travis/build/python-escpos/python-escpos/capabilities-data/dist/capabilities.json
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
@@ -19,7 +17,7 @@ matrix:
|
|||||||
language: shell
|
language: shell
|
||||||
before_install:
|
before_install:
|
||||||
- choco install python
|
- choco install python
|
||||||
- pip install tox codecov 'sphinx>=1.5.1'
|
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
|
||||||
env:
|
env:
|
||||||
- TOXENV=py37
|
- TOXENV=py37
|
||||||
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
|
- PATH=/c/Python37:/c/Python37/Scripts:$PATH
|
||||||
@@ -57,7 +55,7 @@ matrix:
|
|||||||
- os: windows
|
- os: windows
|
||||||
- os: osx
|
- os: osx
|
||||||
before_install:
|
before_install:
|
||||||
- pip install tox codecov 'sphinx>=1.5.1'
|
- pip install tox codecov 'sphinx>=1.5.1' 'sphinxcontrib-spelling>=5'
|
||||||
- ./doc/generate_authors.sh --check
|
- ./doc/generate_authors.sh --check
|
||||||
script:
|
script:
|
||||||
- tox
|
- tox
|
||||||
|
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"restructuredtext.confPath": "${workspaceFolder}/doc",
|
||||||
|
"files.watcherExclude": {
|
||||||
|
"**/.git/objects/**": true,
|
||||||
|
"**/.git/subtree-cache/**": true,
|
||||||
|
"**/node_modules/*/**": true,
|
||||||
|
"**/.eggs/**": true,
|
||||||
|
"**/.hypothesis/**": true,
|
||||||
|
"**/.tox/**": true,
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,28 @@
|
|||||||
*********
|
*********
|
||||||
Changelog
|
Changelog
|
||||||
*********
|
*********
|
||||||
|
2020-05-12 - Version 3.0a8 - "Only Slightly Bent"
|
||||||
|
-------------------------------------------------
|
||||||
|
This release is the ninth alpha release of the new version 3.0.
|
||||||
|
Please be aware that the API is subject to change until v3.0 is
|
||||||
|
released.
|
||||||
|
|
||||||
|
This release drops support for Python 2, requiring at least
|
||||||
|
version 3.5 of Python.
|
||||||
|
|
||||||
|
changes
|
||||||
|
^^^^^^^
|
||||||
|
- Drop support for Python 2 and mark in setuptools as only supporting 3.5 and upwards
|
||||||
|
- remove landscape.io badge
|
||||||
|
- replace viivakoodi with python-barcode which is maintained
|
||||||
|
- add configuration for Visual Studio Code
|
||||||
|
- use pkg_resources for the retrieval of the capabilities.json
|
||||||
|
|
||||||
|
contributors
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
- Romain Porte
|
||||||
|
- Patrick Kanzler
|
||||||
|
|
||||||
2020-05-09 - Version 3.0a7 - "No Fixed Abode"
|
2020-05-09 - Version 3.0a7 - "No Fixed Abode"
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
This release is the eight alpha release of the new version 3.0.
|
This release is the eight alpha release of the new version 3.0.
|
||||||
|
@@ -27,25 +27,6 @@ Style-Guide
|
|||||||
|
|
||||||
When writing code please try to stick to these rules.
|
When writing code please try to stick to these rules.
|
||||||
|
|
||||||
Python 2 and 3
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
We have rewritten the code in order to maintain compatibility with both Python 2 and Python 3.
|
|
||||||
In order to ensure that we do not miss any accidental degradation, please add these imports to the top
|
|
||||||
of every file of code:
|
|
||||||
|
|
||||||
.. code-block:: Python
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
Furthermore please be aware of the differences between Python 2 and 3. For
|
|
||||||
example `this guide <https://docs.python.org/3/howto/pyporting.html>`_ is helpful.
|
|
||||||
Special care has to be taken when dealing with strings and byte-strings. Please note
|
|
||||||
that the :py:meth:`~escpos.escpos.Escpos._raw`-method only accepts byte-strings.
|
|
||||||
Often you can achieve compatibility quite easily with a tool from the `six`-package.
|
|
||||||
|
|
||||||
PEP8
|
PEP8
|
||||||
^^^^
|
^^^^
|
||||||
The entire codebase adheres to the rules of PEP8.
|
The entire codebase adheres to the rules of PEP8.
|
||||||
|
10
README.rst
10
README.rst
@@ -6,16 +6,12 @@ python-escpos - Python library to manipulate ESC/POS Printers
|
|||||||
:target: https://travis-ci.org/python-escpos/python-escpos
|
:target: https://travis-ci.org/python-escpos/python-escpos
|
||||||
:alt: Continous Integration
|
:alt: Continous Integration
|
||||||
|
|
||||||
.. image:: https://landscape.io/github/python-escpos/python-escpos/master/landscape.svg?style=flat
|
|
||||||
:target: https://landscape.io/github/python-escpos/python-escpos/master
|
|
||||||
:alt: Code Health
|
|
||||||
|
|
||||||
.. image:: https://codecov.io/github/python-escpos/python-escpos/coverage.svg?branch=master
|
.. image:: https://codecov.io/github/python-escpos/python-escpos/coverage.svg?branch=master
|
||||||
:target: https://codecov.io/github/python-escpos/python-escpos?branch=master
|
:target: https://codecov.io/github/python-escpos/python-escpos?branch=master
|
||||||
:alt: Code Coverage
|
:alt: Code Coverage
|
||||||
|
|
||||||
.. image:: https://readthedocs.org/projects/python-escpos/badge/?version=stable
|
.. image:: https://readthedocs.org/projects/python-escpos/badge/?version=latest
|
||||||
:target: http://python-escpos.readthedocs.io/en/latest/?badge=stable
|
:target: http://python-escpos.readthedocs.io/en/latest/?badge=latest
|
||||||
:alt: Documentation Status
|
:alt: Documentation Status
|
||||||
|
|
||||||
|
|
||||||
@@ -47,7 +43,7 @@ This library makes use of:
|
|||||||
* `Pillow <https://github.com/python-pillow/Pillow>`_ for image printing
|
* `Pillow <https://github.com/python-pillow/Pillow>`_ for image printing
|
||||||
* `qrcode <https://github.com/lincolnloop/python-qrcode>`_ for the generation of QR-codes
|
* `qrcode <https://github.com/lincolnloop/python-qrcode>`_ for the generation of QR-codes
|
||||||
* `pyserial <https://github.com/pyserial/pyserial>`_ for serial printers
|
* `pyserial <https://github.com/pyserial/pyserial>`_ for serial printers
|
||||||
* `viivakoodi <https://github.com/kxepal/viivakoodi>`_ for the generation of barcodes
|
* `python-barcode <https://github.com/WhyNotHugo/python-barcode>`_ for the generation of barcodes
|
||||||
|
|
||||||
Documentation and Usage
|
Documentation and Usage
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@@ -3,10 +3,9 @@ codecov:
|
|||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
status:
|
status:
|
||||||
project:
|
project: off
|
||||||
default: # status context
|
patch: off
|
||||||
target: auto
|
changes: off
|
||||||
threshold: "1%"
|
|
||||||
range: "60...100"
|
range: "60...100"
|
||||||
|
|
||||||
comment: off
|
comment: off
|
||||||
|
@@ -19,7 +19,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|||||||
# the i18n builder cannot share the environment and doctrees with the others
|
# the i18n builder cannot share the environment and doctrees with the others
|
||||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
||||||
|
|
||||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext spelling
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Please use \`make <target>' where <target> is one of"
|
@echo "Please use \`make <target>' where <target> is one of"
|
||||||
@@ -45,6 +45,7 @@ help:
|
|||||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||||
@echo " linkcheck to check all external links for integrity"
|
@echo " linkcheck to check all external links for integrity"
|
||||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||||
|
@echo " spelling to run the spellchecker"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILDDIR)/*
|
rm -rf $(BUILDDIR)/*
|
||||||
@@ -175,3 +176,8 @@ pseudoxml:
|
|||||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||||
@echo
|
@echo
|
||||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
||||||
|
|
||||||
|
spelling:
|
||||||
|
$(SPHINXBUILD) -b spelling $(ALLSPHINXOPTS) $(BUILDDIR)/spelling
|
||||||
|
@echo
|
||||||
|
@echo "Spellchecker finished."
|
||||||
|
@@ -43,6 +43,7 @@ extensions = [
|
|||||||
'sphinx.ext.todo',
|
'sphinx.ext.todo',
|
||||||
'sphinx.ext.graphviz',
|
'sphinx.ext.graphviz',
|
||||||
'sphinx.ext.inheritance_diagram',
|
'sphinx.ext.inheritance_diagram',
|
||||||
|
'sphinxcontrib.spelling',
|
||||||
]
|
]
|
||||||
|
|
||||||
# supress warnings for external images
|
# supress warnings for external images
|
||||||
@@ -292,3 +293,9 @@ texinfo_documents = [
|
|||||||
|
|
||||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||||
#texinfo_no_detailmenu = False
|
#texinfo_no_detailmenu = False
|
||||||
|
|
||||||
|
# spellchecker
|
||||||
|
spelling_ignore_pypi_package_names = True
|
||||||
|
spelling_ignore_wiki_words = True
|
||||||
|
spelling_ignore_python_builtins = True
|
||||||
|
spelling_ignore_importable_modules = True
|
||||||
|
@@ -3,6 +3,8 @@ Pillow>=2.0
|
|||||||
qrcode>=4.0
|
qrcode>=4.0
|
||||||
pyserial
|
pyserial
|
||||||
sphinx-rtd-theme
|
sphinx-rtd-theme
|
||||||
|
setuptools
|
||||||
setuptools-scm
|
setuptools-scm
|
||||||
docutils>=0.12
|
docutils>=0.12
|
||||||
viivakoodi
|
sphinxcontrib-spelling>=5
|
||||||
|
python-barcode>=0.11.0,<1
|
||||||
|
7
doc/spelling_wordlist.txt
Normal file
7
doc/spelling_wordlist.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Raspbian
|
||||||
|
ESC
|
||||||
|
POS
|
||||||
|
Escpos
|
||||||
|
Escpos
|
||||||
|
baudrate
|
||||||
|
lsusb
|
@@ -163,7 +163,7 @@ The printer section
|
|||||||
|
|
||||||
The ``printer`` configuration section defines a default printer to create.
|
The ``printer`` configuration section defines a default printer to create.
|
||||||
|
|
||||||
The only required paramter is ``type``. The value of this has to be one of the
|
The only required parameter is ``type``. The value of this has to be one of the
|
||||||
printers defined in :doc:`/user/printers`.
|
printers defined in :doc:`/user/printers`.
|
||||||
|
|
||||||
The rest of the given parameters will be passed on to the initialization of the printer class.
|
The rest of the given parameters will be passed on to the initialization of the printer class.
|
||||||
@@ -194,12 +194,12 @@ An USB-printer could be defined by::
|
|||||||
|
|
||||||
Printing text right
|
Printing text right
|
||||||
-------------------
|
-------------------
|
||||||
Python-escpos is designed to accept unicode. So make sure that you use ``u'strings'`` or import ``unicode_literals``
|
|
||||||
from ``__future__`` if you are on Python 2. On Python 3 you should be fine.
|
Python-escpos is designed to accept unicode.
|
||||||
|
|
||||||
For normal usage you can simply pass your text to the printers ``text()``-function. It will automatically guess
|
For normal usage you can simply pass your text to the printers ``text()``-function. It will automatically guess
|
||||||
the right codepage and then send the encoded data to the printer. If this feature does not work, please try to
|
the right codepage and then send the encoded data to the printer. If this feature does not work, please try to
|
||||||
isolate the error and then create an issue on the Github project page.
|
isolate the error and then create an issue on the GitHub project page.
|
||||||
|
|
||||||
If you want or need to you can manually set the codepage. For this please use the ``charcode()``-function. You can set
|
If you want or need to you can manually set the codepage. For this please use the ``charcode()``-function. You can set
|
||||||
any key-value that is in ``CHARCODE``. If something is wrong, an ``CharCodeError`` will be raised.
|
any key-value that is in ``CHARCODE``. If something is wrong, an ``CharCodeError`` will be raised.
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
"""Prints code page tables.
|
"""Prints code page tables.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
@@ -6,4 +6,4 @@ p = Usb(0x0416, 0x5011, profile="POS-5890")
|
|||||||
|
|
||||||
# Some software barcodes
|
# Some software barcodes
|
||||||
p.soft_barcode('code128', 'Hello')
|
p.soft_barcode('code128', 'Hello')
|
||||||
p.soft_barcode('code39', '123456')
|
p.soft_barcode('code39', '1234')
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
# Check out his github: https://github.com/AdamWhitcroft/climacons
|
# Check out his github: https://github.com/AdamWhitcroft/climacons
|
||||||
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import calendar
|
import calendar
|
||||||
import urllib
|
import urllib
|
||||||
|
68
setup.cfg
68
setup.cfg
@@ -1,11 +1,71 @@
|
|||||||
|
[metadata]
|
||||||
|
name = python-escpos
|
||||||
|
url = https://github.com/python-escpos/python-escpos
|
||||||
|
description = Python library to manipulate ESC/POS Printers
|
||||||
|
long_description = file: README.rst
|
||||||
|
license = MIT
|
||||||
|
license_file = LICENSE
|
||||||
|
author = Manuel F Martinez and others
|
||||||
|
author_email = dev@pkanzler.de
|
||||||
|
maintainer = Patrick Kanzler
|
||||||
|
maintainer_email = dev@pkanzler.de
|
||||||
|
keywords = ESC/POS, thermoprinter, voucher printer, printing, receipt
|
||||||
|
classifiers =
|
||||||
|
Development Status :: 4 - Beta
|
||||||
|
Environment :: Console
|
||||||
|
Intended Audience :: Developers
|
||||||
|
License :: OSI Approved :: MIT License
|
||||||
|
Operating System :: OS Independent
|
||||||
|
Programming Language :: Python
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
Programming Language :: Python :: 3.5
|
||||||
|
Programming Language :: Python :: 3.6
|
||||||
|
Programming Language :: Python :: 3.7
|
||||||
|
Programming Language :: Python :: 3.8
|
||||||
|
Programming Language :: Python :: Implementation :: CPython
|
||||||
|
Topic :: Software Development :: Libraries :: Python Modules
|
||||||
|
Topic :: Office/Business :: Financial :: Point-Of-Sale
|
||||||
|
project_urls =
|
||||||
|
Bug Tracker = https://github.com/python-escpos/python-escpos/issues
|
||||||
|
Documentation = https://python-escpos.readthedocs.io/en/latest/
|
||||||
|
Release Notes = https://github.com/python-escpos/python-escpos/releases
|
||||||
|
|
||||||
|
[options]
|
||||||
|
python_requires = >=3.5
|
||||||
|
zip_safe = false
|
||||||
|
include_package_data = true
|
||||||
|
install_requires =
|
||||||
|
pyusb>=1.0.0
|
||||||
|
Pillow>=2.0
|
||||||
|
qrcode>=4.0
|
||||||
|
pyserial
|
||||||
|
python-barcode>=0.9.1,<1
|
||||||
|
setuptools
|
||||||
|
six
|
||||||
|
appdirs
|
||||||
|
PyYAML
|
||||||
|
argparse
|
||||||
|
argcomplete
|
||||||
|
future
|
||||||
|
viivakoodi>=0.8
|
||||||
|
setup_requires = setuptools_scm
|
||||||
|
tests_require =
|
||||||
|
jaconv
|
||||||
|
tox
|
||||||
|
pytest!=3.2.0,!=3.3.0
|
||||||
|
pytest-cov
|
||||||
|
pytest-mock
|
||||||
|
nose
|
||||||
|
scripttest
|
||||||
|
mock
|
||||||
|
hypothesis>4
|
||||||
|
flake8
|
||||||
|
sphinxcontrib-spelling>=5
|
||||||
|
|
||||||
[nosetests]
|
[nosetests]
|
||||||
verbosity=3
|
verbosity=3
|
||||||
with-doctest=1
|
with-doctest=1
|
||||||
|
|
||||||
[bdist_wheel]
|
|
||||||
# This flag says that the code is written to work on both Python 2 and Python 3.
|
|
||||||
universal=1
|
|
||||||
|
|
||||||
[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
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
|
80
setup.py
80
setup.py
@@ -22,89 +22,19 @@ setuptools_scm_template = """\
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
# file generated by setuptools_scm
|
# file generated by setuptools_scm
|
||||||
# don't change, don't track in version control
|
# don't change, don't track in version control
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
version = '{version}'
|
version = '{version}'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='python-escpos',
|
|
||||||
use_scm_version={
|
use_scm_version={
|
||||||
'write_to': 'src/escpos/version.py',
|
"write_to": "src/escpos/version.py",
|
||||||
'write_to_template': setuptools_scm_template,
|
"write_to_template": setuptools_scm_template,
|
||||||
},
|
},
|
||||||
url='https://github.com/python-escpos/python-escpos',
|
platforms="any",
|
||||||
download_url='https://github.com/python-escpos/python-escpos/archive/master.zip',
|
|
||||||
description='Python library to manipulate ESC/POS Printers',
|
|
||||||
license='MIT',
|
|
||||||
long_description=read('README.rst'),
|
|
||||||
author='Manuel F Martinez and others',
|
|
||||||
author_email='manpaz@bashlinux.com',
|
|
||||||
maintainer='Patrick Kanzler',
|
|
||||||
maintainer_email='dev@pkanzler.de',
|
|
||||||
keywords=[
|
|
||||||
'ESC/POS',
|
|
||||||
'thermoprinter',
|
|
||||||
'voucher printer',
|
|
||||||
'printing',
|
|
||||||
'receipt,',
|
|
||||||
],
|
|
||||||
platforms='any',
|
|
||||||
package_dir={"": "src"},
|
package_dir={"": "src"},
|
||||||
packages=find_packages(where="src", exclude=["tests", "tests.*"]),
|
packages=find_packages(where="src", exclude=["tests", "tests.*"]),
|
||||||
package_data={'escpos': ['capabilities.json']},
|
package_data={"escpos": ["capabilities.json"]},
|
||||||
include_package_data=True,
|
entry_points={"console_scripts": ["python-escpos = escpos.cli:main"]},
|
||||||
classifiers=[
|
|
||||||
'Development Status :: 4 - Beta',
|
|
||||||
'Environment :: Console',
|
|
||||||
'Intended Audience :: Developers',
|
|
||||||
'License :: OSI Approved :: MIT License',
|
|
||||||
'Operating System :: OS Independent',
|
|
||||||
'Programming Language :: Python',
|
|
||||||
'Programming Language :: Python :: 3',
|
|
||||||
'Programming Language :: Python :: 3.5',
|
|
||||||
'Programming Language :: Python :: 3.6',
|
|
||||||
'Programming Language :: Python :: 3.7',
|
|
||||||
'Programming Language :: Python :: 3.8',
|
|
||||||
'Programming Language :: Python :: Implementation :: CPython',
|
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
||||||
'Topic :: Office/Business :: Financial :: Point-Of-Sale',
|
|
||||||
],
|
|
||||||
install_requires=[
|
|
||||||
'pyusb>=1.0.0',
|
|
||||||
'Pillow>=2.0',
|
|
||||||
'qrcode>=4.0',
|
|
||||||
'pyserial',
|
|
||||||
'six',
|
|
||||||
'appdirs',
|
|
||||||
'PyYAML',
|
|
||||||
'argparse',
|
|
||||||
'argcomplete',
|
|
||||||
'future',
|
|
||||||
'viivakoodi>=0.8'
|
|
||||||
],
|
|
||||||
setup_requires=[
|
|
||||||
'setuptools_scm',
|
|
||||||
],
|
|
||||||
tests_require=[
|
|
||||||
'jaconv',
|
|
||||||
'tox',
|
|
||||||
'pytest!=3.2.0,!=3.3.0',
|
|
||||||
'pytest-cov',
|
|
||||||
'pytest-mock',
|
|
||||||
'nose',
|
|
||||||
'scripttest',
|
|
||||||
'mock',
|
|
||||||
'hypothesis>4',
|
|
||||||
'flake8'
|
|
||||||
],
|
|
||||||
entry_points={
|
|
||||||
'console_scripts': [
|
|
||||||
'python-escpos = escpos.cli:main'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
@@ -2,10 +2,6 @@
|
|||||||
"""
|
"""
|
||||||
python-escpos enables you to manipulate escpos-printers
|
python-escpos enables you to manipulate escpos-printers
|
||||||
"""
|
"""
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
__all__ = ["constants", "escpos", "exceptions", "printer"]
|
__all__ = ["constants", "escpos", "exceptions", "printer"]
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import re
|
import re
|
||||||
from os import environ, path
|
from os import environ, path
|
||||||
|
import pkg_resources
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
@@ -15,9 +16,9 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
|
pickle_dir = environ.get('ESCPOS_CAPABILITIES_PICKLE_DIR', gettempdir())
|
||||||
pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
|
pickle_path = path.join(pickle_dir, '{v}.capabilities.pickle'.format(v=platform.python_version()))
|
||||||
capabilities_path = environ.get(
|
# get a temporary file from pkg_resources if no file is specified in env
|
||||||
'ESCPOS_CAPABILITIES_FILE',
|
capabilities_path = environ.get('ESCPOS_CAPABILITIES_FILE',
|
||||||
path.join(path.dirname(__file__), 'capabilities.json'))
|
pkg_resources.resource_filename(__name__, 'capabilities.json'))
|
||||||
|
|
||||||
# Load external printer database
|
# Load external printer database
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
@@ -58,7 +59,7 @@ BARCODE_B = 'barcodeB'
|
|||||||
|
|
||||||
|
|
||||||
class BaseProfile(object):
|
class BaseProfile(object):
|
||||||
"""This respresents a printer profile.
|
"""This represents a printer profile.
|
||||||
|
|
||||||
A printer profile knows about the number of columns, supported
|
A printer profile knows about the number of columns, supported
|
||||||
features, colors and more.
|
features, colors and more.
|
||||||
|
@@ -3,16 +3,12 @@
|
|||||||
""" CLI
|
""" CLI
|
||||||
|
|
||||||
This module acts as a command line interface for python-escpos. It mirrors
|
This module acts as a command line interface for python-escpos. It mirrors
|
||||||
closely the available ESCPOS commands while adding a couple extra ones for convience.
|
closely the available ESCPOS commands while adding a couple extra ones for convenience.
|
||||||
|
|
||||||
It requires you to have a configuration file. See documentation for details.
|
It requires you to have a configuration file. See documentation for details.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
try:
|
try:
|
||||||
@@ -558,7 +554,7 @@ def main():
|
|||||||
|
|
||||||
def demo(printer, **kwargs):
|
def demo(printer, **kwargs):
|
||||||
"""
|
"""
|
||||||
Prints specificed demos. Called when CLI is passed `demo`. This function
|
Prints demos. Called when CLI is passed `demo`. This function
|
||||||
uses the DEMO_FUNCTIONS dictionary.
|
uses the DEMO_FUNCTIONS dictionary.
|
||||||
|
|
||||||
:param printer: A printer from escpos.printer
|
:param printer: A printer from escpos.printer
|
||||||
|
@@ -1,13 +1,9 @@
|
|||||||
""" ESC/POS configuration manager.
|
""" ESC/POS configuration manager.
|
||||||
|
|
||||||
This module contains the implentations of abstract base class :py:class:`Config`.
|
This module contains the implementations of abstract base class :py:class:`Config`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import appdirs
|
import appdirs
|
||||||
|
@@ -11,10 +11,6 @@ moved to `capabilities` as in `escpos-php by @mike42 <https://github.com/mike42/
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@@ -10,10 +10,6 @@ This module contains the abstract base class :py:class:`Escpos`.
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import qrcode
|
import qrcode
|
||||||
import textwrap
|
import textwrap
|
||||||
@@ -402,7 +398,7 @@ class Escpos(object):
|
|||||||
*default*: A
|
*default*: A
|
||||||
|
|
||||||
:param check: If this parameter is True, the barcode format will be checked to ensure it meets the bc
|
:param check: If this parameter is True, the barcode format will be checked to ensure it meets the bc
|
||||||
requirements as defigned in the esc/pos documentation. See :py:meth:`.check_barcode()`
|
requirements as definged in the ESC/POS documentation. See :py:meth:`.check_barcode()`
|
||||||
for more information. *default*: True.
|
for more information. *default*: True.
|
||||||
|
|
||||||
:raises: :py:exc:`~escpos.exceptions.BarcodeSizeError`,
|
:raises: :py:exc:`~escpos.exceptions.BarcodeSizeError`,
|
||||||
@@ -483,7 +479,8 @@ class Escpos(object):
|
|||||||
self._raw(NUL)
|
self._raw(NUL)
|
||||||
|
|
||||||
def soft_barcode(self, barcode_type, data, impl='bitImageColumn',
|
def soft_barcode(self, barcode_type, data, impl='bitImageColumn',
|
||||||
module_height=5, module_width=0.2, text_distance=1):
|
module_height=5, module_width=0.2, text_distance=1,
|
||||||
|
center=True):
|
||||||
|
|
||||||
image_writer = ImageWriter()
|
image_writer = ImageWriter()
|
||||||
|
|
||||||
@@ -506,7 +503,7 @@ class Escpos(object):
|
|||||||
|
|
||||||
# Retrieve the Pillow image and print it
|
# Retrieve the Pillow image and print it
|
||||||
image = my_code.writer._image
|
image = my_code.writer._image
|
||||||
self.image(image, impl=impl)
|
self.image(image, impl=impl, center=center)
|
||||||
|
|
||||||
def text(self, txt):
|
def text(self, txt):
|
||||||
""" Print alpha-numeric text
|
""" Print alpha-numeric text
|
||||||
|
@@ -25,11 +25,6 @@ Result/Exit codes:
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
""" Base class for ESC/POS errors """
|
""" Base class for ESC/POS errors """
|
||||||
|
@@ -8,10 +8,6 @@ This module contains the image format handler :py:class:`EscposImage`.
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import math
|
import math
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
|
@@ -4,11 +4,6 @@
|
|||||||
I doubt that this currently works correctly.
|
I doubt that this currently works correctly.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import jaconv
|
import jaconv
|
||||||
|
@@ -12,10 +12,6 @@ The code is based on the encoding-code in py-xml-escpos by @fvdsn.
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from builtins import bytes
|
from builtins import bytes
|
||||||
from .constants import CODEPAGE_CHANGE
|
from .constants import CODEPAGE_CHANGE
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
import socket
|
import socket
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
"""verifies that the metaclass abc is properly used by Escpos
|
"""verifies that the metaclass abc is properly used by ESC/POS
|
||||||
|
|
||||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||||
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from nose.tools import raises
|
from nose.tools import raises
|
||||||
|
|
||||||
@@ -20,7 +16,7 @@ from abc import ABCMeta
|
|||||||
|
|
||||||
@raises(TypeError)
|
@raises(TypeError)
|
||||||
def test_abstract_base_class_raises():
|
def test_abstract_base_class_raises():
|
||||||
"""test whether the abstract base class raises an exception for Escpos"""
|
"""test whether the abstract base class raises an exception for ESC/POS"""
|
||||||
escpos.Escpos() # This call should raise TypeError because of abstractmethod _raw()
|
escpos.Escpos() # This call should raise TypeError because of abstractmethod _raw()
|
||||||
|
|
||||||
|
|
||||||
|
@@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@@ -1,11 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
from escpos.constants import BARCODE_TYPE_A, BARCODE_TYPE_B
|
|
||||||
from escpos.capabilities import Profile, BARCODE_B
|
from escpos.capabilities import Profile, BARCODE_B
|
||||||
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
|
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
|
||||||
import pytest
|
import pytest
|
||||||
|
@@ -1,8 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
from escpos.exceptions import CashDrawerError
|
from escpos.exceptions import CashDrawerError
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
import pytest
|
import pytest
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
|
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
|
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from nose.tools import raises
|
from nose.tools import raises
|
||||||
import pytest
|
import pytest
|
||||||
|
@@ -8,10 +8,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import mock
|
import mock
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
def test_soft_barcode():
|
@pytest.fixture
|
||||||
"""just execute soft_barcode
|
def instance():
|
||||||
"""
|
return printer.Dummy()
|
||||||
instance = printer.Dummy()
|
|
||||||
|
|
||||||
|
def test_soft_barcode_ean8(instance):
|
||||||
instance.soft_barcode("ean8", "1234")
|
instance.soft_barcode("ean8", "1234")
|
||||||
|
|
||||||
|
|
||||||
|
def test_soft_barcode_ean8_nocenter(instance):
|
||||||
|
instance.soft_barcode("ean8", "1234", center=False)
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import mock
|
import mock
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
|
|
||||||
|
@@ -8,10 +8,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from nose.tools import raises, assert_raises
|
from nose.tools import raises, assert_raises
|
||||||
|
@@ -8,10 +8,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import escpos
|
import escpos
|
||||||
|
@@ -7,10 +7,6 @@
|
|||||||
:license: MIT
|
:license: MIT
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
from __future__ import division
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
import escpos.printer as printer
|
||||||
import escpos.escpos as escpos
|
import escpos.escpos as escpos
|
||||||
|
5
tox.ini
5
tox.ini
@@ -18,7 +18,7 @@ deps = nose
|
|||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-mock
|
pytest-mock
|
||||||
hypothesis>4
|
hypothesis>4
|
||||||
viivakoodi
|
python-barcode
|
||||||
commands = pytest --cov escpos
|
commands = pytest --cov escpos
|
||||||
passenv = ESCPOS_CAPABILITIES_PICKLE_DIR ESCPOS_CAPABILITIES_FILE CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
|
passenv = ESCPOS_CAPABILITIES_PICKLE_DIR ESCPOS_CAPABILITIES_FILE CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
|
||||||
|
|
||||||
@@ -27,7 +27,8 @@ basepython = python
|
|||||||
changedir = doc
|
changedir = doc
|
||||||
deps = sphinx>=1.5.1
|
deps = sphinx>=1.5.1
|
||||||
setuptools_scm
|
setuptools_scm
|
||||||
viivakoodi
|
python-barcode
|
||||||
|
sphinxcontrib-spelling>=5
|
||||||
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
|
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
|
Reference in New Issue
Block a user