196 Commits

Author SHA1 Message Date
Benito López
59579c477d
Update src/escpos/printer/lp.py
Add return type

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-25 18:45:33 +02:00
Benito López
5062a09b0a
Update src/escpos/printer/lp.py
Add return type

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-25 18:45:11 +02:00
Benito López
cc22cf0ad2
Update src/escpos/printer/file.py
Add return type

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-25 18:44:37 +02:00
Benito López
848cc3417f
Update src/escpos/printer/file.py
Add return type

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-25 18:44:03 +02:00
belono
86ae775881 Fix LP waste of paper due to auto-flush + flush on close 2023-09-24 13:37:45 +02:00
belono
0984c93975 Fix type checking 2023-09-22 19:58:26 +02:00
belono
f8deb69f43 Fix LP printer stall 2023-09-21 20:35:32 +02:00
Benito López
a8e1c583e0
Merge branch 'master' into belono/issue445 2023-09-19 10:12:56 +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
belono
d3946212c7 Fix some docstrings 2023-09-18 15:26:08 +02:00
belono
2bd11b38d5 Enhance connectors consistency 2023-09-16 19:55:31 +02:00
belono
30a34460e8 Update USBNotFoundError return code 2023-09-09 18:11:40 +02:00
belono
f846347624 Add generic DeviceNotFounfError exception 2023-09-09 18:04:15 +02:00
Benito López
dcde8c072d
Merge branch 'master' into belono/issue445 2023-09-09 16:38:43 +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
Benito López
58be698b16
Update src/escpos/escpos.py
Remove 'Literal[False]' as a return value type of the property 'device'

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-07 12:57:18 +02:00
belono
77f97a906a Fix sort imports 2023-09-06 23:24:01 +02:00
belono
a825f8f06d Please mypy type checking 2023-09-06 23:13:58 +02:00
belono
e8814e4acb Fix mypy complains 2023-09-06 23:13:58 +02:00
belono
e434164202 Add type annotation to device.setter 2023-09-06 23:13:57 +02:00
belono
a7e7bc0a64 Add default value to all params + type annotations 2023-09-06 23:13:57 +02:00
Benito López
fa583e68d5
Merge branch 'master' into belono/issue445 2023-09-06 23:06:38 +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
Benito López
19782a733b
Merge branch 'master' into belono/issue445 2023-09-04 12:20:20 +02:00
belono
7103af083c Restore device status to False on close() 2023-09-03 20:42:09 +02:00
Patrick Kanzler
44444f3c51
Maintenance: fix read the docs and some annotations (#557) 2023-09-03 09:57:56 +02:00
Benito López
21b329a955
Update src/escpos/printer/cups.py
f-string

Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com>
2023-09-01 23:07:27 +02:00
belono
d68eee08a7 Separate open() and store connection in 'device' 2023-08-28 11:52:48 +02:00
belono
8763eba86c self-open mechanism through the 'device' property 2023-08-28 11:52:48 +02:00
belono
bf95fa1f56 Add self-open mechanism 2023-08-28 11:52:48 +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 110200dde678a165062707e8ccb985c837ed6f68.

* 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