Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adrianschlatter/ppf.datamatrix
Pure-python package to generate data matrix codes.
https://github.com/adrianschlatter/ppf.datamatrix
codecs datamatrix ipython python svg
Last synced: 24 days ago
JSON representation
Pure-python package to generate data matrix codes.
- Host: GitHub
- URL: https://github.com/adrianschlatter/ppf.datamatrix
- Owner: adrianschlatter
- License: other
- Created: 2021-05-17T16:37:45.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2024-03-10T15:01:26.000Z (8 months ago)
- Last Synced: 2024-09-28T18:40:56.242Z (about 1 month ago)
- Topics: codecs, datamatrix, ipython, python, svg
- Language: Python
- Homepage:
- Size: 109 KB
- Stars: 32
- Watchers: 2
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: docs/README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
ppf.datamatrix is a pure-python package to generate datamatrix codes in SVG.
Also, it integrates nicely in IPython.ppf.datamatrix has been ported from [datalog's
datamatrix-svg](https://github.com/datalog/datamatrix-svg), which is written in
javascript. If you like to see what you'll get before installation, check out
their [nice web demo](https://datalog.github.io/demo/datamatrix-svg).Creating a datamatrix with ppf.datamatrix is as easy as
```
from ppf.datamatrix import DataMatrixmyDataMatrix = DataMatrix('Test!')
```If you are working in a graphically enabled IPython terminal, you'll see your
datamatrix immediately:![IPython integration](imgs/ipython.png)
Using the DataMatrix object, you get the SVG source like this:
```
myDataMatrix.svg()'
Use this on your website, to stamp a pdf, to uniquely identify a drawing, or
whatever you like. Background and foreground color are configurable by
specifying fg and/or bg arguments. Create a light blue matrix on a petrol
background like this:```
myDataMatrix.svg(fg='#EEF', bg='#09D')
```Note: This sets the colors of the SVG.
It does *not* change the color of the representation inside your IPython
terminal.## Advanced Features
ppf.datamatrix supports a [variety of
encodings](https://en.m.wikipedia.org/wiki/Data_Matrix#Encoding), namely
EDIFACT ('datamatrix.edifact'), ASCII ('datamatrix.ascii'), X12
('datamatrix.X12'), C40 ('datamatrix.C40'), TEXT ('datamatrix.text'). These
are used to store your message inside the datamatrix code efficiently.
DataMatrix handles the encoding internally: If you just want to create a
DataMatrix, you don't have to care about any of this. If you want to do
advanced stuff (designing your own form of matrix code, maybe), ppf.datamatrix
enables you to use its encoders. After importing ppf.datamatrix, they are
available via the python codecs system:```
import ppf.datamatrixencoded = 'TEST'.encode('datamatrix.edifact')
encoded
b'\xf0PT\xd4'decoded = encoded.decode('datamatrix.edifact')
decoded
'TEST'
```Furthermore it is possible to tell the DataMatrix class which codecs to use.
The default is to try all valid datamatrix codecs and select the one
resulting in the shortest code. This line:```
myDataMatrix = DataMatrix('Test!', codecs=['C40', 'edifact'])
```will try (only) datamatrix.C40 and datamatrix.edifact and select the shorter
one. Of course, you can provide a list of one to enforce a particular
encoding.# Installation
ppf.datamatrix is available via [pypi](https://pypi.org):
```
pip install ppf.datamatrix
```# Still reading?
If you read this far, you're probably not here for the first time. If you use
and like this project, would you consider giving it a Github Star? (The button
is at the top of this website.) If not, maybe you're interested in one of
[my other projects](https://github.com/adrianschlatter/ppf.sample/blob/develop/docs/list_of_projects.md)?# Contributing
Did you find a bug and would like to report it? Or maybe you've fixed it
already or want to help fixing it? That's great! Please read
[CONTRIBUTING](./CONTRIBUTING.md) to learn how to proceed from there.To help ascertain that contributing to this project is a pleasant experience,
we have established a [code of conduct](./CODE_OF_CONDUCT.md). You can expect
everyone to adhere to it, just make sure you do as well.# Change Log
* 0.2: Fixed RTA problems causing erroneous datamatrices; added capability
to specify encoding(s) to use
* 0.1.2: Fixed bug in RS correction data for each block
* 0.1.1: Fixed bug in datamatrix.ascii encoding of digit pairs
* 0.1: Initial port of datamatrix–svg