TiddlyParse allows Python to interact with TiddlyWiki files.
At the moment it handles standalone HTML files, with the two tiddler formats. The first one was used in version up to and including 5.1.23, the second one uses JSON snippets and is in use since 5.2.0.
Points that are currently open but can be added upon interest:
- Seamlessly interact with a server-side TiddlyWiki and use the REST API in that context
- Handle encrypted files
Usage
Use the parse method to get a wiki instance returned:
from tiddlyparse import parse
from pathlib import Path
wiki_file = Path('wiki.html')
wiki = parse(file=wiki_file)
This will automatically detect the format and transparently handle this also for saving back.
The number of tiddlers are returned with the len function:
>>> len(wiki)
7
Note that only the root tiddlers are returned. The individual tiddlers contained therein are not currently handled, though that may change.
You can access individual tiddlers using dictionary notation or get:
>>> wiki['$:/isEncrypted']
<tiddlyparse.parser.JsonTiddler object at 0x105a85130>
>>> wiki.get('no such tiddler')
It is also possible to execute simple searches. Any keyword argument to the search function is converted into a query component. If the argument value is True, then all tiddlers that have this attribute defined are returned:
>>> tiddlers = wiki.search(author=True)
>>> tiddlers
[<tiddlyparse.parser.JsonTiddler object at 0x101827e80>, <tiddlyparse.parser.JsonTiddler object at 0x101832130>, <tiddlyparse.parser.JsonTiddler object at 0x101832190>]
>>> [t.title for t in tiddlers]
['$:/core', '$:/themes/tiddlywiki/snowwhite', '$:/themes/tiddlywiki/vanilla']
If it's any string value, then all tiddlers that have this attribute set to exactly this value are returned:
>>> tiddlers = wiki.search(name='Snow White')
>>> [t.title for t in tiddlers]
['$:/themes/tiddlywiki/snowwhite']
The tiddlers are all represented using the Tiddler class (JsonTiddler or DivTiddler more specifically). The tiddler attributes are available as properties are available on those objects:
>>> tiddler = wiki['$:/isEncrypted']
>>> tiddler.text
'no'
>>> tiddler = wiki.get('$:/core')
>>> tiddler.author
'JeremyRuston'
To create or modify a tiddler, use the get_or_create method to first get the tiddler. Then add it to the wiki with add:
>>> tiddler = wiki.get_or_create('Testing TiddlyParse')
>>> tiddler.text = "This is the first ''test'' with TiddlyParse."
>>> tiddler.tags = 'Test TiddlyParse'
>>> wiki.add(tiddler)
To persist the changes, use save:
>>> wiki.save()
Metadata
Release files for TiddlyParse 0.2.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 | |
|---|---|---|---|---|
| tiddlyparse-0.2.0.tar.gz | 7.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tiddlyparse-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / tiddlyparse-0.2.0.tar.gz
| Download URL | tiddlyparse-0.2.0.tar.gz |
|---|---|
| Size | 7.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba351ab3acfce2edb83127104c0d79fb007717cabe2c4897f9958e918be95a21
|
|
BLAKE2b-256 checksum How to use checksums |
69ba429e769845f2ea29a81f8a5587883247129ef6f8ee4e7e985abb730ad065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.6 Darwin/22.6.0
|
Release files / tiddlyparse-0.2.0-py3-none-any.whl
| Download URL | tiddlyparse-0.2.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0752ce0f62d3c6a3d7f9901028294517ca9183bb1a0ee7ac3ff3ef476a0db4a
|
|
BLAKE2b-256 checksum How to use checksums |
d3dee31dc93b53c09b0e9907c5fab1ee29319a24f3d1e6d98ddc3440fbe56328
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.11.6 Darwin/22.6.0
|
Security for TiddlyParse 0.2.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.