yamlsync
Yaml Sync is a very lightweight YAML-based cache for when you want to preserve the state of something on disk in a human readable way.
Installation
To install Yaml Sync, simply run:
pip install yaml-sync
Example usage
Here's a quick example of how to use Yaml Sync:
from yaml_sync import YamlCache
# Create a cache that reads and writes to the specified file
cache = YamlCache('cache.yaml', mode='rw')
# Save a key to the cache and write to disk
cache['hello'] = 'world'
# Check if a key is in the cache
assert 'hello' in cache
# Retrieve a key from the cache
variable = cache['hello']
# Save a list to the cache
cache['list_example'] = [1, 2, 3]
The resulting yaml will be:
hello: world
list_example:
0: 1
1: 2
2: 3
You can pass number_lists=True at init to save any lists as a numbered dictionary. Since the goal of Yaml Sync is a human-readable file, the numbering may be desired in some cases.
If a value is None, that key is not returned for key in cache. e.g.
cache['empty_key'] = None
assert 'empty_key' in cache
# AssertionError
Finally, you can specify a preferred order to the keys, to control what is shown first in the yaml.
cache = YamlCache('cache.yaml', order=['b', 'a'])
cache['a'] = 'hello'
cache['b'] = 'world'
with open('cache.yaml') as f:
print(f.read())
b: world
a: hello
License
This project is licensed under the MIT License.
Metadata
Release files for yaml-sync 0.2
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 |
|---|---|---|---|---|
| yaml-sync-0.2.tar.gz | 3.9 kB | Without provenance | Details for yaml-sync-0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaml_sync-0.2-py3-none-any.whl | Python 3 | none | any | Details for yaml_sync-0.2-py3-none-any.whl |
Total release size: 8.5 kB
Release files / yaml-sync-0.2.tar.gz
| Download URL | yaml-sync-0.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aea580a6a72ef325daa62695a3d1d67d0634725e2030af21d2e9ed8b4480703f
|
|
BLAKE2b-256 checksum How to use checksums |
6cb108abf8bca13d103103a3db3bddf420fe5e90503583a0b1597c17e5931f34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|
Release files / yaml_sync-0.2-py3-none-any.whl
| Download URL | yaml_sync-0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1515455d9194d97145f74297cd8f202fa94845b6d3db16d37afc2e7527056cde
|
|
BLAKE2b-256 checksum How to use checksums |
26ee9dfd24a17510811c6a7e87335b27027b71ea5d50a1eb6a6ef57642c61178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.12
|
Security for yaml-sync 0.2
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.