pygra.preferences

preferences.py — persistent user preferences Stored in ~/.config/pygra/preferences.json

pygra.preferences.load_prefs()[source]

Load user preferences from disk.

Reads ~/.config/pygra/preferences.json and merges the saved values over DEFAULT_PREFS. If the file does not exist the defaults are returned silently. If the file exists but cannot be parsed, a warning is printed to stderr and the defaults are returned.

Returns:

Preference dictionary containing all keys from DEFAULT_PREFS, with any saved overrides applied.

Return type:

dict

pygra.preferences.save_prefs(prefs)[source]

Persist prefs to ~/.config/pygra/preferences.json.

The parent directory is created automatically if it does not exist.

Parameters:

prefs (dict) – Preference dictionary to serialise as JSON.

Raises:

OSError – If the file cannot be written (e.g. permission denied).