Skip to main content

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

py-appdata-0.0.3.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_appdata-0.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file py-appdata-0.0.3.tar.gz.

File metadata

  • Download URL: py-appdata-0.0.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.7.13 Linux/5.13.0-1031-azure

File hashes

Hashes for py-appdata-0.0.3.tar.gz
Algorithm Hash digest
SHA256 03560ca320ab36d2f00d7094d25347cae432c0cf3b4b71f8a4e5afbf1d7a8c34
MD5 fb48da363d11a4f85c6a0aaa8f7830a1
BLAKE2b-256 6910d140d52c63e8a3f639a65286dbd99993815bf61b7201da16fc6552779124

See more details on using hashes here.

File details

Details for the file py_appdata-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_appdata-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.7.13 Linux/5.13.0-1031-azure

File hashes

Hashes for py_appdata-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06eec712e31bd6ad095fcdfde41bac1ad484975cce112d5f06c49e6a41ba3c5e
MD5 0878d2c34d2c88e219858d4699fa6169
BLAKE2b-256 3a6c35dc9e77031ff830401450e036f3d00ee4c3b1090569ad77fe64443762fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page