A small XML-based markup language for tickets
Why?
====
As part of the code I write for [Imperial Cinema](http://www.imperialcinema.co.uk), I decided
I need some way of cleanly abstracting over multiple different (but similar) ticket printers.
I decided on a sort-of HTML-ish language, for which you will find a parser and ticket printing
backend for the following receipt printers:
* Citizen CBM-1000
* IBM 4610 family (tested on the 4610-TF6)
The XML
=======
The XML document has the following sort of style:
```xml
<?xml version="1.0" ?>
<ticket>
<head>
<logo num="1" />
not bold<b> suddenly bold</b> not bold again<br />
not underlined <u>suddenly underlined</u> not underlined<br />
now <b>for <u>a mix</u></b> <u>of <b>settings</b></u><br/>
<align mode="center"><logo num="2" /></align>
base font<br />
<font width="2">2x wide</font><br />
<font height="2">2x high</font><br />
<font width="2" height="2">2x big</font><br />
<font width="8" height="8">MASSIVE</font>
</head>
</ticket>
```
(Note that this document is formatted neatly - leading per-line whitespace is NOT stripped by the parser and may cause you issues!)
The following tags are implemented - unknown tags are ignored (but are still recursed into!):
* `ticket`: this is the root tag and is not treated specially
* `b`: activates emphasis (usually bold)
* `u`: activates underlining
* `logo num="NUMBER"`: prints pre-loaded image NUMBER
* `align mode="left|right|center"`: changes the alignment of text
* `br`: prints a newline
* `font (width="WIDTH") (height="HEIGHT")`: changes the font width/height multiplier
Using it
========
At the moment there's a fairly simplistic API. In order to get started, you'll need some sort of file-like output device. This is usually a PySerial `Serial` object.
```python
import serial
output = serial.Serial('/dev/ttyS1', 19200)
```
Now that you have an output device, you can construct a `Backend`. At present there's a choice of two, the `CbmBackend` (for Citizen CBM-1000 printers) and the `Ibm4610Backend` (for IBM 4610 series printers). Backends are up to take whatever arguments they choose - at the moment this is just the output device they should talk to.
```python
backend = ticketml.Ibm4610Backend(output)
```
Now you can finally construct a parser. This takes place in two stages - first you parse the input XML, then you tell the parser to render it to the output device:
```python
ticket = ticketml.TicketML.parse('<?xml version="1.0" ?>\n<ticket>Hello! This is my first ticket!</ticket>')
context = {}
ticket.go(context, backend)
```
The `context` parameter is unused at the moment, but is planned to be used for future templating functionality.
Metadata
Release files for ticketml 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ticketml-0.2.3.tar.gz | 8.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ticketml-0.2.3-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 18.3 kB
Release files / ticketml-0.2.3.tar.gz
| Download URL | ticketml-0.2.3.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
98a400ef442f3c7adce26a5d24f5994e710c2d8a8131b4c21df8534e9a114626
|
|
BLAKE2b-256 checksum How to use checksums |
8b3a400d03323654a282d9382cc9d70f0d200e76c03b3e5123559319bfa57a90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / ticketml-0.2.3-py2.py3-none-any.whl
| Download URL | ticketml-0.2.3-py2.py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2ed7d578813242eb727f9c2261fec9274bdbd233aac2c66f07a6286f6e68768a
|
|
BLAKE2b-256 checksum How to use checksums |
47ef6ccee88e3a07850f9a06bed1c47b9565d8ba48153ea2127a3a2caad3848c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ticketml 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.