diff --git a/README.rst b/README.rst index cc1bc7b..86683b0 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ This library makes use of: * `Pillow `_ for image printing * `qrcode `_ for the generation of QR-codes * `pyserial `_ for serial printers -* `viivakoodi `_ for the generation of barcodes +* `python-barcode `_ for the generation of barcodes Documentation and Usage ----------------------- diff --git a/doc/requirements.txt b/doc/requirements.txt index 9f38356..89cd833 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,4 +5,4 @@ pyserial sphinx-rtd-theme setuptools-scm docutils>=0.12 -viivakoodi +python-barcode>=0.11.0,<1 diff --git a/examples/software_barcode.py b/examples/software_barcode.py index 2fd3c18..9bbcc09 100644 --- a/examples/software_barcode.py +++ b/examples/software_barcode.py @@ -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') diff --git a/setup.cfg b/setup.cfg index a2dcf83..10e0396 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,7 @@ install_requires = Pillow>=2.0 qrcode>=4.0 pyserial + python-barcode>=0.9.1,<1 six appdirs PyYAML diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 17e0d12..24f6475 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -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 diff --git a/test/test_function_barcode.py b/test/test_function_barcode.py index c3a0c7f..a2db09c 100644 --- a/test/test_function_barcode.py +++ b/test/test_function_barcode.py @@ -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 diff --git a/test/test_function_softbarcode.py b/test/test_function_softbarcode.py index 1bef1cd..fc702d7 100644 --- a/test/test_function_softbarcode.py +++ b/test/test_function_softbarcode.py @@ -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) diff --git a/tox.ini b/tox.ini index 53211f3..d0f9361 100644 --- a/tox.ini +++ b/tox.ini @@ -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]