Small utility library to provide easy access to files and key-value store in an application directory
Project description
Python App Data
The py-appdata aims to solve the issue of storing simple application data and accessing it in an easy way.
The core idea is to expose a simple interface that has two properties
- A get/set interface to simple values
- A simple way of saving and retrieving files from the application directory
Stores
The AppData class provides an interface to two storage-abstractions: A file system and a key-value store. This lets
you easily save/retrieve files as well as setting/loading key/values which is a common app-data usage.
Get started
from appdata import appdata
from datetime import datetime, timezone
# defaults to app_data
appdata.set_file_store("my_app_data_dir")
# defaults to kv_store
appdata.set_key_value_store("my_store")
appdata["last_login"] = datetime.utcnow().replace(tzinfo=timezone.utc)
with appdata.write("some_file.txt") as f:
f.write("Mjello")
Dataclass support
If you like type hints, you can register a dataclass instance as a proxy for the key-value store
from appdata import appdata
from datetime import datetime, timezone
from dataclasses import dataclass
# Define the dataclass
@dataclass
class KV:
last_login: datetime = None
# Create an object to be referenced and register it to appdata
kv = KV()
appdata.register(kv)
# The KeyValue object now acts as a proxy, and can be used throughout your project
kv.last_login = datetime.utcnow().replace(tzinfo=timezone.utc)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py-appdata-0.0.2.tar.gz.
File metadata
- Download URL: py-appdata-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.7.13 Linux/5.13.0-1029-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95f482c878d19025aa998ee2bcf1ca8dfc554e0973d1b98fecde6bc8df6ac1b0
|
|
| MD5 |
33f193588fcec31fdb95b2e57654128b
|
|
| BLAKE2b-256 |
3ddbefb78a3b55e44a2ef95054de2f22fe929059b4c3c4bd13c1a44c2aea61db
|
File details
Details for the file py_appdata-0.0.2-py3-none-any.whl.
File metadata
- Download URL: py_appdata-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.7.13 Linux/5.13.0-1029-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b131013dbc06597ba5a21546477f62a7161f84f189159a30822ace03ca2ad3f
|
|
| MD5 |
8b13f3252a0ad6c32da8a6245e7c65a0
|
|
| BLAKE2b-256 |
793014da0c90e1b586645f62ebce2e1291d0f8b2dc8079aa21ccd65a4426ca73
|