databx 0.1.0__py3-none-any.whl
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/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
# interne Klasse für Speicherung
|
|
5
|
+
class _DataStore:
|
|
6
|
+
def __init__(self, filename="data.json"):
|
|
7
|
+
self.filename = filename
|
|
8
|
+
if os.path.exists(self.filename):
|
|
9
|
+
with open(self.filename, "r") as f:
|
|
10
|
+
try:
|
|
11
|
+
self.data = json.load(f)
|
|
12
|
+
except json.JSONDecodeError:
|
|
13
|
+
self.data = []
|
|
14
|
+
else:
|
|
15
|
+
self.data = []
|
|
16
|
+
|
|
17
|
+
def save(self, **kwargs):
|
|
18
|
+
self.data.append(kwargs)
|
|
19
|
+
with open(self.filename, "w") as f:
|
|
20
|
+
json.dump(self.data, f, indent=4)
|
|
21
|
+
|
|
22
|
+
def load_all(self):
|
|
23
|
+
return self.data
|
|
24
|
+
|
|
25
|
+
# Ein globales Objekt für direkten Zugriff
|
|
26
|
+
_store = _DataStore()
|
|
27
|
+
|
|
28
|
+
# Funktionen, die direkt aufgerufen werden können
|
|
29
|
+
def save(**kwargs):
|
|
30
|
+
"""Speichert beliebige Daten direkt."""
|
|
31
|
+
_store.save(**kwargs)
|
|
32
|
+
|
|
33
|
+
def load_all():
|
|
34
|
+
"""Lädt alle gespeicherten Daten."""
|
|
35
|
+
return _store.load_all()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: databx
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Speichere beliebige Daten flexibel
|
|
5
|
+
Author: Gurkennutelabro
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# Mein nices modul
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
databx/__init__.py,sha256=ynRw6fhiL91UiTQTRjw5gBOYFAT7aj0Z8dYefZUfdV0,931
|
|
2
|
+
databx-0.1.0.dist-info/licenses/LICENSE,sha256=5dz_6Da27IpY5JJBm1UOZfuMvcMIUDl55drLM6x-o7c,3
|
|
3
|
+
databx-0.1.0.dist-info/METADATA,sha256=LQXYR-GnDV-U-_-9byKLCHYH1HTR70SxjVXd4gWDEPc,258
|
|
4
|
+
databx-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
databx-0.1.0.dist-info/top_level.txt,sha256=0dm5pxZ-m1VNijAC7e-rBzbuKbSEuEoYi2ahMS9xkgo,7
|
|
6
|
+
databx-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
databx
|