Merge pull request #395 from MicroJoe/python-barcode

replace viivakoodi with python-barcode, center soft barcodes by default
This commit is contained in:
Patrick Kanzler 2020-05-10 18:42:04 +02:00 committed by GitHub
commit 42554d836c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 11 deletions

View File

@ -43,7 +43,7 @@ This library makes use of:
* `Pillow <https://github.com/python-pillow/Pillow>`_ for image printing
* `qrcode <https://github.com/lincolnloop/python-qrcode>`_ for the generation of QR-codes
* `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
-----------------------

View File

@ -5,4 +5,4 @@ pyserial
sphinx-rtd-theme
setuptools-scm
docutils>=0.12
viivakoodi
python-barcode>=0.11.0,<1

View File

@ -6,4 +6,4 @@ p = Usb(0x0416, 0x5011, profile="POS-5890")
# Some software barcodes
p.soft_barcode('code128', 'Hello')
p.soft_barcode('code39', '123456')
p.soft_barcode('code39', '1234')

View File

@ -39,6 +39,7 @@ install_requires =
Pillow>=2.0
qrcode>=4.0
pyserial
python-barcode>=0.9.1,<1
six
appdirs
PyYAML

View File

@ -479,7 +479,8 @@ class Escpos(object):
self._raw(NUL)
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()
@ -502,7 +503,7 @@ class Escpos(object):
# Retrieve the Pillow image and print it
image = my_code.writer._image
self.image(image, impl=impl)
self.image(image, impl=impl, center=center)
def text(self, txt):
""" Print alpha-numeric text

View File

@ -1,7 +1,6 @@
#!/usr/bin/python
import escpos.printer as printer
from escpos.constants import BARCODE_TYPE_A, BARCODE_TYPE_B
from escpos.capabilities import Profile, BARCODE_B
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
import pytest

View File

@ -4,9 +4,14 @@ import escpos.printer as printer
import pytest
def test_soft_barcode():
"""just execute soft_barcode
"""
instance = printer.Dummy()
@pytest.fixture
def instance():
return printer.Dummy()
def test_soft_barcode_ean8(instance):
instance.soft_barcode("ean8", "1234")
def test_soft_barcode_ean8_nocenter(instance):
instance.soft_barcode("ean8", "1234", center=False)

View File

@ -18,6 +18,7 @@ deps = nose
pytest-cov
pytest-mock
hypothesis>4
python-barcode
viivakoodi
commands = pytest --cov escpos
passenv = ESCPOS_CAPABILITIES_PICKLE_DIR ESCPOS_CAPABILITIES_FILE CI TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* CODECOV_*
@ -27,7 +28,7 @@ basepython = python
changedir = doc
deps = sphinx>=1.5.1
setuptools_scm
viivakoodi
python-barcode
commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
[testenv:flake8]