Appdata Management Utilities

2.2.1 · active · verified Fri Apr 17

The `appdata` library provides utilities for managing application-specific data folders across different operating systems (Windows, macOS, Linux). It helps locate standard directories for user data, configuration, and cache, ensuring cross-platform compatibility. The current version is 2.2.1, with releases typically occurring on an as-needed basis to address bugs or introduce minor enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize `AppData` for your application and access the common user data, configuration, and cache directories. It highlights that the library returns `pathlib.Path` objects, which are flexible for path manipulation and can be converted to strings when necessary.

import os
from appdata import AppData

# Replace 'MyAwesomeApp' and 'MyCompany' with your actual app/company names
APP_NAME = os.environ.get('APPDATA_APP_NAME', 'MyTestApp')
APP_AUTHOR = os.environ.get('APPDATA_APP_AUTHOR', 'MyTestCompany')

# Initialize AppData for your application
app_data = AppData(APP_NAME, APP_AUTHOR)

# Access common application directories
user_data_dir = app_data.user_data_dir
user_config_dir = app_data.user_config_dir
user_cache_dir = app_data.user_cache_dir

print(f"User Data Directory: {user_data_dir} (Type: {type(user_data_dir)})")
print(f"User Config Directory: {user_config_dir} (Type: {type(user_config_dir)})")
print(f"User Cache Directory: {user_cache_dir} (Type: {type(user_cache_dir)})")

# You can create subdirectories and files easily with pathlib.Path
some_file_path = user_data_dir / "settings.json"
print(f"Example file path using pathlib: {some_file_path}")

# To convert to string for older APIs if needed:
print(f"User data as string: {str(user_data_dir)}")

view raw JSON →