Commit Graph

186 Commits

Author SHA1 Message Date
Benito López 1e9adb80f3
Fix CLI not working for some connectors Fixes #639 (#640) 2024-04-29 23:50:52 +02:00
Wesley Appler a865b715f3
Fixed lack of spacing for multi-line strings (#619)
Co-authored-by: Wes Appler <wes@lamemakes>
2024-01-11 12:35:03 +01:00
Patrick Kanzler 0c824cf295
More mypy (#612)
* remove type comment where type is annotated
* move function tests
* remove six from tests
* add none annotations
* add more types
* change mock (so that mypy understands it)
2023-12-16 23:09:20 +01:00
Alexandre Detiste 66a2e78e16
start removal of six and improve type annotation (#607)
* fix unfinished Python2 -> 3 translation
* remove some six usage
* annotate
* fix regression in Six removal
* mypy: self.enf is always defined
* fix return type of cups.py
* Usb idVendor/idProduct are integers
* self.default_args is always defined
* tweak usb_args, PEP589 is better
* lp.py: reassure mypy
* correctly cast call to CashDrawerError()
* update CUPS test
* add missing close() method in metaclass
* document a bug in typeshed
* query_status() returns bytes as seen in constants.py
* remove more SIX usage
* test examples too
* remove type comment where type is annotated
* adapt behavior of cups printer to match other implementations

---------

Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-12-16 22:02:24 +01:00
Patrick Kanzler 91cbc264fc
Refactor to using f-strings (#608)
* update authors

* refactor to using f-strings
2023-12-11 00:34:29 +01:00
Patrick Kanzler 815f247df1
Improve test coverage and fix issue in path loading (#602)
* reactivate skipped tests

* remove unused internal interfaces

* enable pytest in VS Code

* simplify and fix path logic in loader

* increase test coverage

* test missing config

* check for wrong printer names

* Skipped appdir test
2023-12-06 00:25:36 +01:00
Patrick Kanzler 5914c7c560
allow qr to set all arguments to image (#600)
* allow qr to set all arguments to image

* increase coverage
2023-12-04 01:15:19 +01:00
Patrick Kanzler 9a1699ab94
add type annotations for escpos image handler (#599) 2023-12-03 23:36:35 +01:00
Patrick Kanzler 90c89e66f0 filter for ValueError too in dpi logic 2023-11-17 00:48:31 +01:00
Benito López 3b6551004f
Restore types-pywin32 (#591)
* Restore types-pywin32 dependency

* Restore pywin32 type annotations in win32raw

* Add return type to _raw()
2023-10-31 13:55:48 +01:00
Patrick Kanzler 5d3d2ca34b
import TypedDict from typing, not from extensions (#589)
TypedDict is in the supported python versions
available in typing. Therefore an import from
potentially uninstalled typing_extensions is
not necessary.

fixes #560
2023-10-28 21:11:38 +02:00
Benito López a50a3b7167
Separate method open() and constructor, enhance consistency between connectors: Rework printer tests (#587)
* Add fixtures
* Add test_printer_file.py
* Remove old broken printer tests
* Include a close_on_reopen test
* Add test_printer_network.py
* Add test_printer_serial.py
* Add test_printer_usb.py
* Add test_printer_lp.py
* Add test_printer_cups.py
* Add test_printer_win32raw.py
* Test the 'printers' property
* Fix conftest import formatting
* Fix failing LP tests
* Cancel close only if literal False|None _device
* Fix win32raw failing tests (maybe)
* Include win32raw close_on_reopen test
* Include test _raw methods to win32raw
* Replace general exceptions in win32raw
* Replace wrong exception in cups
* Include more tests to cups
* Extend cups tests
2023-10-28 20:52:59 +02:00
Benito López a00b98937b
Separate method open() and constructor, enhance consistency between connectors. (#584)
* Add self-open mechanism
* self-open mechanism through the 'device' property
* Separate open() and store connection in 'device'
* Restore device status to False on close()
* Add default value to all params + type annotations
* Add generic DeviceNotFoundError exception
* Update USBNotFoundError return code
* Enhance connectors consistency
* Fix LP printer stall
* Fix LP waste of paper due to auto-flush + flush on close
* Move platform dependent printers' guard to init

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-10-16 11:36:07 +02:00
Patrick Kanzler 3a8af8a6f5
switch to python 3.12 (#582)
* switch to python 3.12
* 3.11 on RTD
* fix SyntaxWarning (regex strings were invalid partially)
2023-10-09 00:13:39 +02:00
Patrick Kanzler a70e1604d6
Magic encoder: fix codepage usage (#580)
* add unit test for issue pointed out by @scott-r in #570

* swap order of encoder search

As described by @scott-r in
Magic encoder does not use
previously used code pages
when possible #570
Thank you!
2023-10-05 14:55:12 +02:00
Patrick Kanzler ecfeeb9b13
Improve diagnostic output (#577)
* add extended version information

* autodocument argparser

* add spelling exception

* fix docstrings

* add annotations

* use typing types

* add test
2023-10-05 14:15:19 +02:00
Patrick Kanzler 6d0c475b9a
refactor set method (#547)
* add type annotations
* Update setup.cfg
* improve mypy and test config
* get_profile_class returns a baseProfile
* mute mypy type issue
* add set_with_default
* docstring
* add test for empty call
* correct type annotations in set_with_default
* improve tests
* test for exception
* sort with isort
* add default value to get call
* empty string has the same effect: will not be found --> None
* add mypy test to workflow
* explicitely call mypy
* update spelling
2023-09-19 07:51:39 +02:00
Patrick Kanzler cfa9ecf16d
Enable spell checking (#563)
* add spellchecking

* improve spelling

* improve spelling config

* extend word list

* improve spelling

* improve spelling

* escalate warning in spell check to failure

* fix spelling

* fix spelling

* add plural

* Update doc/spelling_wordlist.txt

* do not stop on warning

* require newest sphinxcontrib spelling

* remove old comment

* add authors as single line entry to spelling list

* reenable stop on warning
2023-09-07 22:08:31 +02:00
Patrick Kanzler 24217756f7
558 improve capabilities handling (#562)
* add handling for missing capabilities file

* improve documentation

* Update doc/user/installation.rst
2023-09-06 00:05:38 +02:00
Patrick Kanzler 44444f3c51
Maintenance: fix read the docs and some annotations (#557) 2023-09-03 09:57:56 +02:00
Patrick Kanzler c7c01cdbff
fix rtd theme (#553)
* use rtd_theme

* add types for serial

* annotate types where possible

* fix imports
2023-08-25 01:19:23 +02:00
Benito López f23bcacabe
fix typo in lp connector (#548) 2023-08-24 23:17:34 +02:00
Patrick Kanzler 3177c8d411
split off dependencies for optional installation (#546)
* add inheritance diagrams to all printers and exceptions
* split off printer implementations into separate files
* add wrapper that thros RuntimeError if not importable
* add dependency check for lp
* add dependency check for pyserial
* added check for usability
* import Win32Raw
* include WIn32Raw in documentation
* enable all extras on tox
* update github workflow
2023-08-17 01:37:50 +02:00
Patrick Kanzler fbabd8ed88
Drop Py37, improve typing and docstrings (#544)
Drops Py3.7, improves typing and adds a mypy config, improves the docstrings and isorts the imports.

* configure isort
* sort with isort
* add github action
* enable flake8-docstrings
* fix docstrings
* add mypy env
* no implicit optional
* add type for raw
* add some type hints
2023-08-15 01:03:36 +02:00
Patrick Kanzler 2b62c8e28d
modernize and cleanup documentation (#542)
* disable system packages on rtd

* install pycups on rtd

* enable cups binding in documentation

* document CupsPrinter

* fix formatting

* revise methods and installation

* revise user/printers

* revise raspi section

* further revise
2023-08-10 01:38:47 +02:00
Patrick Kanzler 09a598883c
351 ean example fix (#537)
* bug/doc: Fix invalid EAN-13 barcode in examples

In the various examples and python-escpos CLI there are a number of uses
of `13243546557687` as an EAN-13 example.  This EAN barcode is invalid
as the checksum should be `0` and not `7`.

```
$ python test_print.py
Traceback (most recent call last):
  File "test_print.py", line 5, in <module>
    p.barcode('13243546557687', 'EAN13', 64, 2, '', '')
  File "/home/pi/fatt-display/lib/python3.7/site-packages/escpos/escpos.py", line 433, in barcode
    bc=bc,
escpos.exceptions.BarcodeCodeError: No Barcode code was supplied (Barcode '13243546557687' not in a valid format for type 'EAN13')
```

This patch set removes `13243546557687` and replaces it with the valid
number `40063813339310`.

In researching the list of [assigned prefixes issued by
G1][g1-prefixes] there seemed to be no "officially" defined test  prefix, so
this change was made to be minimally invasive using the number from the
existing test cases.

Resolves #350

Affects #176

[g1-prefixes]: https://www.gs1.org/standards/id-keys/company-prefix
[test-code]: https://www.barcodelookup.com/4006381333931

---------

Co-authored-by: Brian 'Redbeard' Harrington <redbeard@dead-city.org>
2023-07-28 18:23:18 +02:00
Alfredo orozco df9e8ff394
Feature(escpos) Add buzzer function (#535)
* Add buzzer function
* Add `buzzer(time, duration)` function to control the buzzer on supported
   printers.
* Add unit tests for buzzer function.
* Update test_function_buzzer.py to pass black
* Run black in tests files
---------

Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
2023-07-27 19:10:19 +02:00
Benito López 9ff327d967
Remove sleep when quering status. Fixes #407 (#534)
* Remove sleep when quering status
* Remove unused import time
2023-07-23 23:22:27 +02:00
Patrick Kanzler e9e8b10582
Fixes from ci (#533)
* break line

* remove unused imports

* remove unused os import

* make flake8 more strict

* configure flake for black

* fix action

* use importlib_resources

* rename deprecated methods
2023-07-21 23:03:46 +02:00
Florent de Labarre cb3f4e856b
[FIX] doesn't work in multi user env (#532)
1/ launch code with user A, a temp dir is create with user A
2/ launch code with user B --> permission denied
2023-07-21 22:10:29 +02:00
Benito López 3c11c1b9ab
New high level barcode method. Closes #245, #244. (#527)
* Merge software and hardware barcodes to one method

* Fix wrong sw barcode heigh/width

* Add missing param to _sw_barcode call

* Make barcode() smarter, improvements and clean up

* Use param font_size in sw_barcode()

* Update docstrings

* Update barcode examples and docs

* Add --force_software option to CLI

* Attempt to match the sw and hw barcode sizes

* Better approximation to native font size

* Fix docs build

* Update tests at test_function_softbarcode

* Fix exception

* Move image dpi setting to writter_options

* Fix _sw_barcode() docstring param

* Fix wrong default param in docstring

* improve linkage in documentation

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
2023-07-12 20:45:41 +02:00
Mathieu Poussin 7bf8d4e4b8
Add support for slip/cheque dot matrix printers (#485)
* Add support for slip/cheque dot matrix printers

* format

* fix comments

---------

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
2023-05-09 01:25:48 +02:00
白月秋见心 6849dd3979
Add Chinese support (#356)
* Add Chinese support

* Add author

* Add newline

* Revert "Add Chinese support"

This reverts commit 110200dde6.

* Add Chinese support

* Add Chinese support

* update mailmap file

* update formatting

---------

Co-authored-by: Patrick Kanzler <dev@pkanzler.de>
Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-05-09 01:18:00 +02:00
B. Howell 8bbbf7ceac
soft_barcode to render directly (#469)
Rendering to /dev/null by a call to .write causes an error. Calling .render directly is simpler and fixes the error.

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-05-09 01:07:56 +02:00
Patrick Kanzler 1626af5def
Merge branch 'master' into development 2023-04-19 22:27:56 +02:00
Patrick Kanzler 709d90809c fixed formatting with black 2023-04-19 22:23:23 +02:00
Patrick Kanzler 70d4da1364 format with black 2023-04-19 22:11:09 +02:00
belono b1a1204bb8 Add _read() method to the CupsPrinter() connector 2023-04-14 12:36:15 +02:00
Benito López 361afe3555
Merge branch 'master' into development 2023-02-17 00:17:20 +01:00
belono ea61f287cb Add/Improve documentation of the new connectors 2022-12-11 16:29:33 +01:00
belono 69e9dca761 Fix black linter checks - Remove u"" strings 2022-11-24 20:23:21 +01:00
belono 9a3057c8a8 Add LP Connector - UNIX printing via lp command 2022-11-24 00:11:01 +01:00
Benito López 0b695eff79
Merge branch 'master' into development 2022-08-28 21:45:21 +02:00
belono f0760ddbc0 Add support for remote CUPS server 2022-08-28 21:39:01 +02:00
vendryan 7f9878282d
Fix typo 2022-05-13 08:52:27 +07:00
Patrick Kanzler 435f2bba24 reformat codebase 2021-10-30 18:15:22 +02:00
Patrick Kanzler a4e15c6ac2
Merge branch 'master' into patch-1 2021-10-30 17:58:24 +02:00
Alejandro Hernández 15c18f225e
Update printer.py
without the call to open function, the printer isn't initialize to print, i tested on a generic and epson physical printers.
2021-10-27 17:35:53 -05:00
B. Howell 69e9b9103e
Update escpos.py
Set block_text to use the default font. This means calls will wrap to full paper width.
2020-11-28 00:41:11 +01:00
Patrick Kanzler 1ad53eb642 drop support for python 3.5 2020-11-08 23:51:57 +01:00