fuckface (0.3.0)

Published 2026-07-24 19:12:41 +00:00 by Jack

Installation

pip install --index-url  fuckface

About this package

JSON settings that behave—unless you tell them to be a brat.

fuckface

A small JSON-backed settings module.

from fuckface import Settings, SettingsMode, SharedSettings

settings = Settings("settings.json", mode=SettingsMode.LOAD_OR_CREATE)
settings.set("theme", "dark")
settings["volume"] = 75
settings.save()

# Replace the current in-memory values with the file contents at any time.
settings.read()

# Enable brat mode for compact, one-line JSON:
compact_settings = Settings("compact.json", be_a_brat=True)
compact_settings.set("theme", "dark")
compact_settings.save()

# Pretty, indented JSON is the default:
pretty_settings = Settings("pretty.json", be_a_brat=False)

# Create/configure the shared instance before its first use.
shared = SharedSettings("shared-settings.json")

@SharedSettings.subscribe("theme")
def setting_theme_changed(old, new):
    print(f"theme changed from {old!r} to {new!r}")


shared.set("theme", "light")
shared.save()

SharedSettings() always returns the same instance within the process. Create it with the desired path before using its class-level subscribe decorator.

Creation modes are SettingsMode.LOAD_OR_FAIL, SettingsMode.LOAD_OR_CREATE, and SettingsMode.NOTHING (the default).

Errors from settings operations—including file access, JSON decoding, serialization, missing keys, and missing subscribers—are exposed as Fuckface...Exception subclasses of FuckFaceException. Exceptions raised by your own subscriber callbacks are left untouched.

Initialized by Hyperpyemia 0.3.4

Requirements

Requires Python: >=3.10
Details
PyPI
2026-07-24 19:12:41 +00:00
1
12 KiB
Assets (2)
Versions (2) View all
0.3.0 2026-07-24
0.2.0 2026-07-24