Skip to content

API turboframe.config

rafageist edited this page Dec 4, 2026 · 4 revisions

turboframe.config

Source: turboframe/config.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.

An application's settings in a JSON file of the user's: the store TurboFrame's components take.

JsonStore("myapp") is $XDG_CONFIG_HOME/myapp/config.json (~/.config by default; %APPDATA% on Windows unless appdata=False). It is what turboframe.ui.history.set_store, DesktopApp.colors_store and DiffView.store take: an object with load() -> dict and save(dict).

  • A missing, unreadable or malformed file loads as {}; a value that is not a JSON object too.
  • A save writes a temporary file next to the target, then replaces it: an interrupted save leaves the old settings whole.
  • set_value on a read-only home keeps the value for nothing but says nothing: a setting is not worth an error dialog.

Contents

JsonStore, config_home

class JsonStore

class JsonStore
JsonStore(app: str, file: str = 'config.json', *, appdata: bool = True)

<config home>/<app>/<file>, read and written whole.

  • path (property): Computed each time: a test (or the user) may change XDG_CONFIG_HOME.
  • load() -> dict[str, Any]
  • save(settings: dict[str, Any]) -> None
  • get(key: str, default: Any = None) -> Any
  • set_value(key: str, value: Any) -> None

config_home

def config_home(*, appdata: bool = True) -> Path

Where users' settings live: $XDG_CONFIG_HOME, else %APPDATA% on Windows (when appdata), else ~/.config.

Clone this wiki locally