Bare headless QR code generator
Project description
bareqr - Bare headless QR code generator
bareqr was derived from python-qrcode. I removed all dependencies, console scripts, renderers, and made it headless.
bareqr is:
- stateless
- threadsafe
- PEP-8 compliant
- fully typed
Main features
There is just one feature: produce the matrix.
from bareqr import qrcode
from pprint import pprint
qr = qrcode("1234")
pprint(qr.rows)
>>>
[[1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1],
[1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1],
...
[1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0]]
bareqr won't automatically split data to chunks of different types. You may split data manually:
qr = qrcode("1234", "HELLO", "world")
For each chunk bareqr will choose the correct data type: number, alphanumeric or bytes.
The automatic splitting is available as a separate utility:
from bareqr import optimal_chunks
chunks = optimal_chunks("1234HELLOworld", min_chunk=4)
qr = qrcode(*chunks)
qrcode has an internal global cache of precomputed blank QR codes.
In bareqr this cache is external and opt-in:
cache = {}
qr1 = qrcode("1234", blanks_cache=cache)
qr2 = qrcode("5678", blanks_cache=cache)
Extra features
Ok, in fact bareqr is not completely headless. There are two utils to render QR as ascii or png. Treat them as handy extras.
from bareqr import qrcode, as_ascii, as_png
qr = qrcode("1234")
asc = as_ascii(qr, border=2, invert=True)
for row in asc:
print(row)
png = as_png(qr, border=2, scale=4)
with open("qr.png", "wb") as f:
f.write(png)
The png encoder is custom to avoid extra dependencies.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bareqr-0.1.1.tar.gz.
File metadata
- Download URL: bareqr-0.1.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a66ea1efd9d21ab0b2520a8a1646c5338b94a9a26e596e020af3d75b7c26e311
|
|
| MD5 |
491122c50ee1210c0576e9c21f457cd7
|
|
| BLAKE2b-256 |
eaf2878c6c55d69da62a1b267e322490719e0fcc8a3ec9f96a69568f04707130
|
File details
Details for the file bareqr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bareqr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.31.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa0950bb4f330ae6ab1d2a844bb622620f553dcb0a8d9fe31ae06b9e6e02d87
|
|
| MD5 |
9c5dde1d6ddf71f3878203eba3cc9f45
|
|
| BLAKE2b-256 |
29defff6a2486c0084e4b53ae721c2f682fc4139578216ff9133bdec94a779b3
|