diff options
| author | Nippy <nippy@Nippy-Mac-mini.local> | 2026-11-01 18:13:54 +0100 |
|---|---|---|
| committer | Nippy <nippy@Nippy-Mac-mini.local> | 2026-11-01 18:13:54 +0100 |
| commit | a64ef966534f8dba6af889ba4bfce15691bfc85b (patch) | |
| tree | b30f284d05b80fa115569ab220deae13797fad6f /raveos-center/raveos_center/beallitasok.py | |
| parent | 919f977b40016f588b0c8532c8a57f6035056b95 (diff) | |
| download | RaveOS-PKGBUILD-a64ef966534f8dba6af889ba4bfce15691bfc85b.tar.gz RaveOS-PKGBUILD-a64ef966534f8dba6af889ba4bfce15691bfc85b.zip | |
új telepítő
Diffstat (limited to 'raveos-center/raveos_center/beallitasok.py')
| -rw-r--r-- | raveos-center/raveos_center/beallitasok.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/raveos-center/raveos_center/beallitasok.py b/raveos-center/raveos_center/beallitasok.py new file mode 100644 index 0000000..e041706 --- /dev/null +++ b/raveos-center/raveos_center/beallitasok.py @@ -0,0 +1,30 @@ +import json +import os +import threading +from pathlib import Path + +KONFIG = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / "raveos-center" +FAJL = KONFIG / "beallitasok.json" +_zar = threading.Lock() + + +def _olvas(): + try: + return json.loads(FAJL.read_text()) + except (OSError, ValueError): + return {} + + +def ertek(kulcs, alap=None): + with _zar: + return _olvas().get(kulcs, alap) + + +def beallit(kulcs, ertek_): + with _zar: + adat = _olvas() + adat[kulcs] = ertek_ + KONFIG.mkdir(parents=True, exist_ok=True) + ideiglenes = FAJL.with_suffix(".uj") + ideiglenes.write_text(json.dumps(adat, ensure_ascii=False, indent=2)) + os.replace(ideiglenes, FAJL) |