Skip to main content

Resolve application resource locations and configuration sources across platforms.

Project description

app-resource-resolver

app-resource-resolver resolves application resource locations across platforms: config, data, state, cache, logs, runtime files, locks, bins, credentials, and related app-owned resources.

The package is designed around two layers:

  • AppLocations: path and candidate resolution, similar in spirit to platformdirs but strategy-driven.
  • AppConfig: config source discovery, parsing, merging, and provenance.

The core package has no runtime dependencies outside the Python standard library.

Current Status

This project is in initial implementation. See:

The examples below show the implemented initial API surface.

Path Resolution Direction

AppLocations is intended to be the platformdirs-like interface. It should return default locations without scanning the filesystem unless the method name makes discovery explicit.

from app_resource_resolver import AppLocations

locations = AppLocations("myapp", strategy="native")

config_dir = locations.user_config_dir()
cache_dir = locations.user_cache_dir()
state_dir = locations.user_state_dir()

Strategies should hide platform-specific details:

from app_resource_resolver import AppLocations

locations = AppLocations(
    "myapp",
    strategy="portable",
    env_prefix="MYAPP",
)

for candidate in locations.config_candidates("config.toml"):
    print(candidate.path, candidate.provider, candidate.scope)

target = locations.config_write_target("config.toml")

Simple target methods answer where a new resource belongs. Discovery methods such as find_*, candidates_*, and resolve_* are the APIs that may inspect whether paths already exist.

Config Management Direction

AppConfig is intended to sit above AppLocations. It should discover config sources, parse supported formats, merge values according to precedence, and preserve provenance.

from app_resource_resolver import AppConfig

config = AppConfig(
    "myapp",
    strategy="portable",
    filenames=("config.toml", "settings.json"),
)

settings = config.load_merged()
sources = config.show_sources()

Common tool presets provide enum-first discovery for real config and data locations without requiring callers to spell out string resource kinds:

from app_resource_resolver import AppConfig, ToolPreset

git_config = AppConfig(preset=ToolPreset.GIT, cwd=project_dir)

for source in git_config.show_sources():
    print(source.candidate.kind, source.candidate.path, source.format_name)

settings = git_config.load_merged()

Some presets include non-config resources so they can be inspected with show_sources(). For example, cargo's ~/.cargo/env and zoxide's data file are discoverable, but load_merged() only loads files with a stdlib-supported suffix or a rule-specified format unless the caller registers another loader.

Presets are small source-rule specs, so applications can provide their own without depending on global state:

from app_resource_resolver import (
    AppConfig,
    ConfigFormat,
    ConfigPreset,
    Provider,
    SourceBase,
    SourceRule,
)

spec = ConfigPreset(
    name="example",
    app_name="example",
    rules=(
        SourceRule(
            SourceBase.XDG_CONFIG_HOME,
            "example/config",
            provider=Provider.XDG_USER,
            format=ConfigFormat.INI,
        ),
    ),
)

config = AppConfig(spec=spec)

The core package will use only standard-library parsers:

  • TOML via tomllib;
  • JSON via json;
  • INI-style files via configparser.

YAML and other formats should be supplied by caller-provided loaders, optional extras, or adapter packages rather than becoming core runtime dependencies.

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

app_resource_resolver-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

app_resource_resolver-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file app_resource_resolver-0.1.0.tar.gz.

File metadata

  • Download URL: app_resource_resolver-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for app_resource_resolver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4fb8ad5d2ac302676a26f5129e0b2b91d030154f6823188284748caf09e6f43a
MD5 5914203cc08c90576484cd1da3b1c1bd
BLAKE2b-256 790fa53feb6410b2a3f527f439f4eec35e8e10fd5286e70f1323eae10f3114fb

See more details on using hashes here.

File details

Details for the file app_resource_resolver-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: app_resource_resolver-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for app_resource_resolver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91335e93ad1e05f24b18281ef79409e2caaa77a4923644da2acb5b76243afdc4
MD5 b18f1879bab2c976a4b3459512d0ec28
BLAKE2b-256 d65ce1d40057741a59b95265063941cea24659717ac111bca9b30cd8defefe6e

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