Skip to main content

Settings manager with layered scopes and tuple-key internals

Project description

pysigil

Preference management for small apps.

Quick start

Install pysigil in a virtual environment to make the sigil and pysigil commands available:

python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\Activate
pip install -e .  # or `pip install .` for a normal install
sigil --help
# or
pysigil --help
# or
python -m pysigil --help
from pysigil import (
    get_project_directory,
    get_user_directory,
    helpers_for,
)

get_setting, set_setting = helpers_for("pysigil")
project_root = get_project_directory("pysigil")
user_data = get_user_directory("pysigil")

get_setting("ui.color")
set_setting("ui.color", "blue")
# e.g. load a template shipped with the package
(project_root / "templates" / "dialog.ui").read_text()

Once installed, try a few commands:

sigil set ui.color blue --app demo
sigil get ui.color --app demo
sigil export --app demo

The CLI stores data under your user config directory (e.g. ~/.config/sigil/demo/settings.ini), so you can run these commands right from the source tree without creating a separate project. See tests/manual_tests/README.md for more examples.

Typed helper methods are available for convenient access: Sigil.get_int(), get_float(), get_bool(). For package integration details see docs/integration.md.

Policy API

The merge order and write permissions are managed by a configurable ScopePolicy. The default policy prefers project settings over user ones. To inspect or extend the policy:

from pysigil.policy import Scope, ScopePolicy, policy

# clone and add a git-tracked scope
scopes = [*policy._scopes, Scope("git", writable=True)]
git_policy = ScopePolicy(scopes)

# precedence can be switched at runtime
policy.set_store("user", {("pysigil", "policy"): "user_over_project"})

Using the GUI

pysigil ships with a simple graphical editor for viewing and editing preferences. After installation launch it with:

sigil gui

Any providers with existing configuration directories (e.g. ~/.config/sigil/user-custom) are automatically listed in the package selector.

To initialise or inspect the user configuration directory from a small helper interface, run:

sigil config gui

Click Initialize User Custom to create a per-host user-custom section. A confirmation dialog appears and the folder opens (e.g. ~/.config/sigil/user-custom) so you can edit the newly created file.

Package authors can register development defaults via:

sigil register  # alias: `sigil setup`

Launch authoring tools without the editor:

sigil author

Or launch it programmatically:

from pysigil.ui.tk import launch

launch()

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

pysigil-0.5.1.tar.gz (100.1 kB view details)

Uploaded Source

Built Distribution

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

pysigil-0.5.1-py3-none-any.whl (99.8 kB view details)

Uploaded Python 3

File details

Details for the file pysigil-0.5.1.tar.gz.

File metadata

  • Download URL: pysigil-0.5.1.tar.gz
  • Upload date:
  • Size: 100.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pysigil-0.5.1.tar.gz
Algorithm Hash digest
SHA256 9449cc6c8b5c9fae134221219f8e5bbd3354644a27d09a4bc944f19648a611fb
MD5 c3bef9f39253050715f9b402ae109305
BLAKE2b-256 dbb19dd8dcbaf9b79d0ea98c30f13b50dd385db39a5f05ef9007af59db14e77d

See more details on using hashes here.

File details

Details for the file pysigil-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: pysigil-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 99.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pysigil-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1b80c843df7bc989944cb44e7f7f1c550932ded056670d4477911a8dea3a4cd
MD5 afebe3537b721b7b05fc221a20291359
BLAKE2b-256 10e5b3a1f61156d0c6ed6a8ad2e3b79d99d139a85f6ec1704f5cca289faab2e3

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