tagish
A generic SGML tag-based serializer that uses tags to encode nodes. It shares the xml syntax for tags and attributes but forgoes the xml specifics as namespaces, cdata, and so on. No tag nor attribute names carry special meaning.
{ "title": "tagish", "section": {"title": "Introduction", "p":"A generic SGML tag-based format."}
As tagish:
<document>
<title>tagish</title>
<section>
<title>Introduction</title>
<p>A generic SGML tag-based format.</p>
</section>
</document>
Produces well formed nodes and is parsable by regular xml parsers. The api mirrors json's dump and load including indenting support.
Controlling Tag Output: Names, Attributes and Sequences
A strict transformation rule, where simple types become attributes whereas complex ones tags generate documents with no tag contents, not the kind of documents we'd expect. Tagish includes some common sense rules for these: where to get tag's content, when to use an attribute as a tag name and how to name items in a sequences. While (hopefully) useful, these can be configured.
Basic Transformation Rules
By default, tagish follows these principles:
- Simple types (strings, numbers, booleans) become XML attributes
- Complex types (objects, arrays) become child elements
- All elements use generic tag names based on JSON keys
Additional rules can be configured through TransformRules, namely:
- Tag contents comes from the first attributes name present as defined in tag_contents (default value, text and content)
- Tag names will be generated from attributes names as defined in
tag_names_from_attrs. - Sequence items' tag names are the sequence attribute name in naive singular form, that is a final 's' if present is removed. For more finer-grained control you can customize this by defining
irregular_plurals,non_plural_wordsor the direct maping bysequence_items_names. See the the transform rules for the full details.
For example, the dict:
data = {
"books": ["To Kill a Mocking Bird", "If traveler on a Winter's Night a Traveler" ],
"button": {
"text": "click me" ,
"class": "active"
}
}
Serializes to
<document>
<book>To Kill a Mocking Bird</book>
<book>If a Traveler on a Winters Night</book>
<button class="active">click me</button>
</document>
The Cli
Tagish includes a cli:
# outputs the tagish encoded path, for json, toml and yaml files.
$ tagish <path>
# Outputs tagish to other formats
$ tagish <path> --format (json|toml)
Install
tagish is available on Pypi and can be installed as one would so hope:
pipx install tagish
pip install tagish
Project
It's MIT Licensed, and contributions are welcome.
Metadata
Release files for tagish 1.0.0
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 | Actions |
|---|---|---|---|---|
| tagish-1.0.0.tar.gz | 15.4 kB | Without provenance | Details for tagish-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tagish-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for tagish-1.0.0-py3-none-any.whl |
Total release size: 32.9 kB
Release files / tagish-1.0.0.tar.gz
| Download URL | tagish-1.0.0.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
946ccf1b147c12445bd68aeec18bd8757b0cc4a26caa5ca1cf29034c2c9518fc
|
|
BLAKE2b-256 checksum How to use checksums |
0032ccf2d24bed63a2944f5614339b571cb5c203f86c49a0678c773db10075c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / tagish-1.0.0-py3-none-any.whl
| Download URL | tagish-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ad26ae874a6fd79bf41fb5baa298f3ca244ee8e5a6705e3cad237bad7bd3503
|
|
BLAKE2b-256 checksum How to use checksums |
e6284978fb04279488eb302272721df45da4f68f7454930a1512a3db4216dc63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for tagish 1.0.0
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.