This change replaces the simple lists and dictionaries
defined in brother_ql/devicedependent.py with data class
definitions based on attrs. They are split into two
new modules:
* brother_ql/models.py and
* brother_ql/labels.py.
To keep the compatibility with other software relying on
this package, the old brother_ql/devicedependent.py module
can still be imported. Its content is recreated with the
help of the new modules in some _populate_legacy_structures()
functions.
There is a big problem with this commit - it only works with:
* Python 3.5 and later due to
type hints being introduced with
PEP-484 https://www.python.org/dev/peps/pep-0484/
lead to syntax errors on earlier versions.
* (even worse) only with Python 3.6+ due to
PEP 526 variable annotations (introduced in 3.6)
needed by dataclasses too.
We aim, however, at Python 2.7 compatibility with this project.
So after all, I reverse the commit and will implement the changes
in a different way.
This change replaces the simple lists and dictionaries
defined in brother_ql/devicedependent.py with data class
based definitions split into two new modules:
* brother_ql/models.py and
* brother_ql/labels.py.
To keep the compatibility with other software relying on
this package, the old brother_ql/devicedependent.py module
can still be imported. Its content is recreated with the
help of the new modules in some _populate_legacy_structures()
functions.
This command lists the running conditions as shown below:
##################
Information about the running environment of brother_ql.
(Please provide this information when reporting any issue.)
About the computer:
* Platform: Linux-4.4.138-59-default-x86_64-with-SuSE-42.3-x86_64
* Processor: x86_64
* Release: 4.4.138-59-default
* System: Linux
* Machine: x86_64
* Architecture: ('64bit', 'ELF')
About the installed Python version:
* 3.7.0 (default, Jul 31 2018, 19:42:44) [GCC 4.8.5]
About the brother_ql package:
* package location: /local/pyvenv/py37loc/lib/python3.7/site-packages
* package version: 0.9.dev0
* brother_ql CLI path: /local/pyvenv/py37loc/bin/brother_ql
About the requirements of brother_ql:
requirement | requested | installed version
-------------- | ---------- | -----------------
click | any | 6.7
future | any | 0.16.0
packbits | any | 0.6
pillow | >= 3.3.0 | 5.2.0
##################
* The installation instructions were extended to cover
the cases where pip was (willingly or not) used with
the --user flag.
See issue #36 were this came up.
* The use of brother_ql_{create,print,debug,analyze,info}
is now considered deprecated.
* Furthermore: wording on brother_ql_web improved
The code previously found in the function
create_label() in brother_ql.brother_ql_create
now went into a new function convert() in its own module:
convert() in brother_ql.conversion
In addition, the new convert() function is now able to
put more than one pages (labels) into one instruction file.
The strings like tcp://192.168.0.23:9100 or
usb://0x04f9:0x2015 are rather 'identifiers'
than descriptors (terminology).
Users relying on the returned dictionaries of the
list_available_devices() function need to update
the key from 'string_descr' to 'identifier'.
Sorry for the inconvenience.
with pillow < 3.3.0, the call of Image.new()
in brother_ql/brother_ql_create.py line 113
would fail with the following error:
[...]
File "/usr/lib/python3.4/site-packages/brother_ql/brother_ql_create.py", line 113, in create_label
new_im = Image.new(im.mode, (device_pixel_width, im.size[1]), (255,)*len(im.mode))
File "/usr/lib64/python3.4/site-packages/PIL/Image.py", line 2050, in new
return Image()._new(core.fill(mode, size, color))
TypeError: an integer is required (got type tuple)
create_label() is the most important function to be used (imported)
by other Python scripts and packages. It shouldn't force its calling
code or program to terminate in case of invalid input.
The dissection of the color into red, black, & white now
takes part in the HSV color space (instead of HLS before).
Pillow's built-in capabilities to convert RGB → HSV
are now used.
While the creation of --red labels still takes 16 times longer
than the simple black/white ones, it is now 90% less time than
before this commit.
* create_label() now accepts a new keyword argument compress.
The default is False → no compression if not set manually.
This will speed-up the label creation in many cases
at the expense of larger file sizes. Set to True if you
don't care about processing time but want to store the
generated label files.
* The brother_ql_create CLI offers this via the new
argument --compress.
New default (if not set): no compression.
The advantage is that the conversion to grayscale is now done
in the same way for all labels just before the conversion
to b/w.
The memory footprint shouln't increase too much.
And profiling showed that the the performance for small labels
that need pasting didn't deteriorate.