databx 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
databx-0.0.0/LICENSE ADDED
File without changes
databx-0.0.0/PKG-INFO ADDED
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: databx
3
+ Version: 0.0.0
4
+ License-File: LICENSE
5
+ Dynamic: license-file
databx-0.0.0/README.md ADDED
@@ -0,0 +1 @@
1
+ # Nice Module Containing functions to save data in .json files
@@ -0,0 +1,3 @@
1
+ from .core import clear, load, save
2
+
3
+ __all__ = ["clear", "load", "save"]
@@ -0,0 +1,49 @@
1
+ import json
2
+ import os
3
+
4
+
5
+ class DataStore:
6
+ def __init__(self, filename="data.json"):
7
+ self.filename = filename
8
+ self.data = []
9
+ self._load()
10
+
11
+ def _load(self):
12
+ if os.path.exists(self.filename):
13
+ with open(self.filename, "r", encoding="utf-8") as f:
14
+ try:
15
+ self.data = json.load(f)
16
+ except json.JSONDecodeError:
17
+ self.data = []
18
+ else:
19
+ self.data = []
20
+
21
+ def save(self, **kwargs):
22
+ self.data.append(kwargs)
23
+ with open(self.filename, "w", encoding="utf-8") as f:
24
+ json.dump(self.data, f, indent=4)
25
+
26
+ def load(self):
27
+ return self.data
28
+
29
+ def clear(self):
30
+ """Löscht alle Daten."""
31
+ self.data = []
32
+ with open(self.filename, "w", encoding="utf-8") as f:
33
+ json.dump(self.data, f, indent=4)
34
+
35
+
36
+ # ✅ Öffentliche API
37
+
38
+ def save(filename="data.json", **kwargs):
39
+ store = DataStore(filename)
40
+ store.save(**kwargs)
41
+
42
+
43
+ def load(filename="data.json"):
44
+ store = DataStore(filename)
45
+ return store.load()
46
+
47
+ def clear(filename="data.json"):
48
+ store = DataStore(filename)
49
+ store.clear()
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: databx
3
+ Version: 0.0.0
4
+ License-File: LICENSE
5
+ Dynamic: license-file
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ databx/__init__.py
5
+ databx/core.py
6
+ databx.egg-info/PKG-INFO
7
+ databx.egg-info/SOURCES.txt
8
+ databx.egg-info/dependency_links.txt
9
+ databx.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ databx
File without changes
databx-0.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+