A bitfield diagram renderer
Project description
A Python3 port of the javascript bit-field library by Aliaksei Chapyzhenka.
Install
pip install bit_field
For JSON5 usage, install json5:
pip install json5
Library usage
from bit_field import render, jsonml_stringify
reg = [
{'bits': 8, 'name': 'data'}
]
jsonml = render(reg, hspace=888)
html = jsonml_stringify(jsonml)
# <svg...>
CLI Usage
python3 -m bit_field [options] input > alpha.svg
options
input : input JSON filename - must be specified always
--input : input JSON filename (kept for compatibility)
--compact : compact rendering mode
--vspace : vertical space - default 80
--hspace : horizontal space - default 640
--lanes : rectangle lanes - default 2
--bits : overall bitwidth - default 32
--bigendian : - default false
--fontfamily : - default sans-serif
--fontweight : - default normal
--fontsize : - default 14
--beautify : use xml beautifier
--json5 : force json5 input format (need json5 python module)
--no-json5 : never use json5 input format
alpha.json
[
{ "name": "IPO", "bits": 8, "attr": "RO" },
{ "bits": 7 },
{ "name": "BRK", "bits": 5, "attr": "RW", "type": 4 },
{ "name": "CPK", "bits": 1 },
{ "name": "Clear", "bits": 3 },
{ "bits": 8 }
]
alpha.svg
Licensing
This work is based on original work by Aliaksei Chapyzhenka under the MIT license (see LICENSE-ORIGINAL).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bit_field-0.3.0.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for bit_field-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01b1db3b5599937b0d4d499dabe53f5c88c2c84731dc511111b8667aea1e0e31 |
|
MD5 | 0c7226c2becd03c9c843f4b4f681433c |
|
BLAKE2b-256 | a9a0a383f55d5d228e6fe417f0c6c75176f26e3491b8f625eae894116acdd7f3 |