From d00fc5016b5328ff4e3038aca64cde712ddb8960 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 14 Jan 2016 00:53:44 +0100 Subject: [PATCH 1/5] DOC add a todo directive to the documentation .. todo:: will create Todos that are listed in the TODO in the documentation --- doc/conf.py | 4 ++++ doc/user/todo.rst | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index dac6859..b110f59 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -34,8 +34,12 @@ extensions = [ 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode', + 'sphinx.ext.todo', ] +# enable todos +todo_include_todos = True + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/user/todo.rst b/doc/user/todo.rst index 2a54df8..8e79fde 100644 --- a/doc/user/todo.rst +++ b/doc/user/todo.rst @@ -35,4 +35,9 @@ Design * use something similar to the `capabilities` in escpos-php +Todos in the codebase +~~~~~~~~~~~~~~~~~~~~~ + +.. todolist:: + From cd2da59fc28730cb966aee9bb14e2133554d4403 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 14 Jan 2016 01:00:53 +0100 Subject: [PATCH 2/5] FIX and review barcode-printing --- escpos/escpos.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index fc94f95..26e4911 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -147,6 +147,9 @@ class Escpos(object): Prints an image. The image is automatically adjusted in size in order to print it. + .. todo:: Seems to be broken. Write test that simply executes function with a dummy printer in order to + check for bugs like these in the future. + :param path_img: complete filename and path to image of type `jpg`, `gif`, `png` or `bmp` """ im_open = Image.open(path_img) @@ -163,7 +166,11 @@ class Escpos(object): self._convert_image(im) def fullimage(self, img, max_height=860, width=512, histeq=True, bandsize=255): - """ Resizes and prints an arbitrarily sized image """ + """ Resizes and prints an arbitrarily sized image + + .. todo:: Seems to be broken. Write test that simply executes function with a dummy printer in order to + check for bugs like these in the future. + """ if isinstance(img, (Image, Image.Image)): im = img.convert("RGB") else: @@ -310,6 +317,13 @@ class Escpos(object): def barcode(self, code, bc, height, width, pos, font): """ Print Barcode + .. todo:: Documentation tells about default values. In fact no default values exist and supplying a default + value does not work. + .. todo:: Add a method to check barcode codes. + .. todo:: On TM-T88II width from 1 to 6 is accepted. Try to acquire command reference and correct the code. + .. todo:: Supplying pos has no effect in TM-T88II. Printed always below. Verify with other printers and , if + necessary, turn this into an issue. + :param code: alphanumeric data to be printed as bar code :param bc: barcode format, possible values are: @@ -322,10 +336,10 @@ class Escpos(object): * NW7 If none is specified, the method raises :py:exc:`~escpos.exceptions.BarcodeTypeError`. - :param height: barcode height, has to be between 2 and 6 - *default*: 3 - :param width: barcode width, has to be between 1 and 255 + :param height: barcode height, has to be between 1 and 255 *default*: 64 + :param width: barcode width, has to be between 2 and 6 + *default*: 3 :param pos: where to place the text relative to the barcode, *default*: below * ABOVE @@ -512,6 +526,7 @@ class Escpos(object): Without any arguments the paper will be cut completely. With 'mode=PART' a partial cut will be attempted. Note however, that not all models can do a partial cut. See the documentation of your printer for details. + .. todo:: Check this function on TM-T88II. :param mode: set to 'PART' for a partial cut """ From 713380baf90eed2c1ceda1ced65dc3a76c6a73cc Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 14 Jan 2016 14:04:35 +0100 Subject: [PATCH 3/5] DOC corrected todo in barcode-method --- escpos/escpos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index 26e4911..0c628af 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -321,8 +321,8 @@ class Escpos(object): value does not work. .. todo:: Add a method to check barcode codes. .. todo:: On TM-T88II width from 1 to 6 is accepted. Try to acquire command reference and correct the code. - .. todo:: Supplying pos has no effect in TM-T88II. Printed always below. Verify with other printers and , if - necessary, turn this into an issue. + .. todo:: Supplying pos does not have an effect for every barcode type. Check and document for which types this + is true. :param code: alphanumeric data to be printed as bar code :param bc: barcode format, possible values are: From 248ddf8456b70aecbf26ce6d9ebb8842cc5972b3 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 14 Jan 2016 14:51:26 +0100 Subject: [PATCH 4/5] IMPROVE barcode printing * adds default values to the auxiliary parameters * allows to suppress the centered alignment --- escpos/escpos.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index 0c628af..6ec3d7e 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -314,12 +314,11 @@ class Escpos(object): else: raise CharCodeError() - def barcode(self, code, bc, height, width, pos, font): + def barcode(self, code, bc, height=64, width=3, pos="BELOW", font="A", align_ct=True): """ Print Barcode - .. todo:: Documentation tells about default values. In fact no default values exist and supplying a default - value does not work. - .. todo:: Add a method to check barcode codes. + .. todo:: Add a method to check barcode codes. Alternatively or as an addition write explanations about each + barcode-type. .. todo:: On TM-T88II width from 1 to 6 is accepted. Try to acquire command reference and correct the code. .. todo:: Supplying pos does not have an effect for every barcode type. Check and document for which types this is true. @@ -338,9 +337,11 @@ class Escpos(object): If none is specified, the method raises :py:exc:`~escpos.exceptions.BarcodeTypeError`. :param height: barcode height, has to be between 1 and 255 *default*: 64 + :type height: int :param width: barcode width, has to be between 2 and 6 *default*: 3 - :param pos: where to place the text relative to the barcode, *default*: below + :type width: int + :param pos: where to place the text relative to the barcode, *default*: BELOW * ABOVE * BELOW @@ -352,12 +353,17 @@ class Escpos(object): * A * B + :param align_ct: If this parameter is True the barcode will be centered. Otherwise no alignment command will be + issued. + :type align_ct: bool + :raises: :py:exc:`~escpos.exceptions.BarcodeSizeError`, :py:exc:`~escpos.exceptions.BarcodeTypeError`, :py:exc:`~escpos.exceptions.BarcodeCodeError` """ # Align Bar Code() - self._raw(TXT_ALIGN_CT) + if align_ct: + self._raw(TXT_ALIGN_CT) # Height if 1 <= height <= 255: self._raw(BARCODE_HEIGHT + chr(height)) From 0c56f5c83151d830ff2b07446e22d6a139d2723e Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Thu, 14 Jan 2016 15:50:58 +0100 Subject: [PATCH 5/5] DOC improve docstring in barcode-method --- escpos/escpos.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/escpos/escpos.py b/escpos/escpos.py index 6ec3d7e..b8b8342 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -317,12 +317,28 @@ class Escpos(object): def barcode(self, code, bc, height=64, width=3, pos="BELOW", font="A", align_ct=True): """ Print Barcode + This method allows to print barcodes. The rendering of the barcode is done by the printer and therefore has to + be supported by the unit. Currently you have to check manually whether your barcode text is correct. Uncorrect + barcodes may lead to unexpected printer behaviour. + .. todo:: Add a method to check barcode codes. Alternatively or as an addition write explanations about each - barcode-type. + barcode-type. Research whether the check digits can be computed autmatically. + + Use the parameters `height` and `width` for adjusting of the barcode size. Please take notice that the barcode + will not be printed if it is outside of the printable area. (Which should be impossible with this method, so + this information is probably more useful for debugging purposes.) + .. todo:: On TM-T88II width from 1 to 6 is accepted. Try to acquire command reference and correct the code. .. todo:: Supplying pos does not have an effect for every barcode type. Check and document for which types this is true. + If you do not want to center the barcode you can call the method with `align_ct=False`, which will disable + automatic centering. Please note that when you use center alignment, then the alignment of text will be changed + automatically to centered. You have to manually restore the alignment if necessary. + + .. todo:: If further barcode-types are needed they could be rendered transparently as an image. (This could also + be of help if the printer does not support types that others do.) + :param code: alphanumeric data to be printed as bar code :param bc: barcode format, possible values are: