Skip to main content

App Data

Application data directory management and user profile storage with Pydantic models and filesystem-based persistence.

Overview

vcti-app-data provides two components for managing application state on disk. AppDataDirectory is a context manager that creates and scopes operations to an application data directory. ProfileManager handles CRUD operations for named user profiles, each stored as a JSON file in its own directory, with active profile tracking and a default profile that cannot be deleted.

Installation

pip install vcti-app-data>=1.0.0

Quick Start

Application data directory

from vcti.app_data import AppDataDirectory

with AppDataDirectory("~/.config/my_app").context() as ctx:
    # Working directory is now ~/.config/my_app (created if needed)
    (ctx.path / "config.json").write_text('{"theme": "dark"}')
# Original working directory restored on exit

Profile management

from vcti.app_data import ProfileManager

mgr = ProfileManager("~/.config/my_app/profiles")

# Default profile created automatically
mgr.create_profile("dev", name="Development", tags=["dev"])
mgr.create_profile("prod", name="Production", attributes={"region": "us-east"})

mgr.set_active_profile("dev")
print(mgr.get_active_profile())  # "dev"

for profile in mgr.list_profiles():
    print(f"{profile.id}: {profile.info.name}")

mgr.delete_profile("prod")
# Deleting the active profile resets to default

Core API

AppDataDirectory

Method Description
context() Context manager — creates dir, changes CWD, restores on exit
path The directory path

ProfileManager

Method Description
create_profile(profile_id, name, ...) Create a new profile
get_profile(profile_id) Get profile by ID
update_profile_info(profile_id, **kwargs) Update profile fields
delete_profile(profile_id) Delete profile (not default)
list_profiles() List all profiles (sorted by ID)
set_active_profile(profile_id) Set the active profile
get_active_profile() Get active profile ID
profile_exists(profile_id) Check if profile exists

Pydantic Models

Model Purpose
ProfileInfo name, description, avatar, tags, attributes
Profile id + ProfileInfo
ProfileList Collection of profiles (RootModel)

Dependencies

  • pydantic (>=2.0) — data validation and JSON serialization

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_app_data-1.0.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

vcti_app_data-1.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file vcti_app_data-1.0.0.tar.gz.

File metadata

  • Download URL: vcti_app_data-1.0.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_app_data-1.0.0.tar.gz
Algorithm Hash digest
SHA256 91d59dfc75e27dccc0239a7a319dac83d7a95eecf21d291e5852f931b35bb4b9
MD5 ae57656478cc228fb51e0f8efa881fa6
BLAKE2b-256 5c188805406188ea79fc912ff63b2af73314b79f1916718ea9d9e3a4a895d980

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_app_data-1.0.0.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-app-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_app_data-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vcti_app_data-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_app_data-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97c0fe25cabd622980ec9838e1399d5a9245d1a767ddcf0e91e6c8aeeccf782f
MD5 0becd3acaa621039c381f27a132fca49
BLAKE2b-256 714e21b0f5b10e10848d14503a482e436c0b101f211461fc0b8963cc1e52b24a

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_app_data-1.0.0-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-app-data

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

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