peridata
peridata is a simple, tiny (<5KiB!) data storage system using JSON and files, meant to be easy to use, strict on typing, and to allow easy migrations via changing properties.
usage
Create a property dictionary:
from peridata import Property, PersistentStorage
epic_property_dict = {"nuclear_bombs": Property[int](default=1)}
Then, create a PersistentStorage instance:
ps = PersistentStorage(epic_property_dict, Path(".") / "data" / "makesurethisisafileloc.json")
You can then use it like a dictionary; however, adding new keys will error, and typing is checked:
print(ps["nuclear_bombs"]) # Output: 1 (since it's the default set earlier)
# Wait, we're British. That's it, we're invading France.
ps["nuclear_bombs"] -= 1
print(ps["nuclear_bombs"]) # Output: 0
# I'm gonna make a complex amount of nuclear bombs.
ps["nuclear_bombs"] = 2+1j # TypeError: Invalid type for property 'nuclear_bombs'. Expected int, got complex
# Fine, I'll try to store my tea in here, then.
ps["tea"] = Tea(Tea.Brand.YORKSHIRE, quantity=10000).serialize() # KeyError: 'Invalid property: tea'
The data is automatically saved to the file location:
// in data/makesurethisisafileloc.json
{
"nuclear_bombs": 0
}
And, loading the PersistentStorage again will take that instead of the default:
epic_property_dict = {"nuclear_bombs": Property[int](default=1)} # The properties stay the same.
ps = PersistentStorage(epic_property_dict, Path(".") / "data" / "makesurethisisafileloc.json") # The file location is also the same.
print(ps["nuclear_bombs"]) # Output: 0
You can also protect data; then, if you use write_unprivileged, you will get an error on writing:
epic_property_dict = {"nuclear_bombs": Property[int](default=1),
"tea": Property[str](default=Tea(Tea.Brand.YORKSHIRE, quantity=1).serialize(), protected=True)} # The library will manage setting new dictionary values, if you add them.
ps = PersistentStorage(epic_property_dict, Path(".") / "data" / "makesurethisisafileloc.json") # The file location still the same.
ps.write_unprivileged("nuclear_bombs", 100) # This works, since by default protected=False.
# I'm gonna annoy this brit so hard.
ps.write_unprivileged("tea", Coffee().serialize()) # PermissionError: The property 'tea' is protected and cannot be modified from write_unprivileged().
Metadata
Release files for peridata 1.3.3.post1
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 |
|---|---|---|---|---|
| peridata-1.3.3.post1.tar.gz | 4.3 kB | Without provenance | Details for peridata-1.3.3.post1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| peridata-1.3.3.post1-py3-none-any.whl | Python 3 | none | any | Details for peridata-1.3.3.post1-py3-none-any.whl |
Total release size: 8.8 kB
Release files / peridata-1.3.3.post1.tar.gz
| Download URL | peridata-1.3.3.post1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5afe7cd022a516d3d857724b06c8be7c8b3efc12fb4d54452c676dafa906396
|
|
BLAKE2b-256 checksum How to use checksums |
ed0489240a55bfdb672975a173d4b6ff6f8b09d2c489431639081aff9349b2fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Release files / peridata-1.3.3.post1-py3-none-any.whl
| Download URL | peridata-1.3.3.post1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e4c8fef9fbc19eec1224eaf3dc1e729f8b38a30f6a96332ac0f6224e77131447
|
|
BLAKE2b-256 checksum How to use checksums |
f67d0a2d9a4c0cb5786264096b9c1e311f5af1462299a4a3cd71d7b7e6b97deb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.2
|
Security for peridata 1.3.3.post1
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.