localstorage-py-local 1.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.
- localstorage_py_local-1.0.0/LICENSE +0 -0
- localstorage_py_local-1.0.0/PKG-INFO +15 -0
- localstorage_py_local-1.0.0/README.md +1 -0
- localstorage_py_local-1.0.0/localstorage/__init__.py +1 -0
- localstorage_py_local-1.0.0/localstorage/core.py +38 -0
- localstorage_py_local-1.0.0/localstorage_py_local.egg-info/PKG-INFO +15 -0
- localstorage_py_local-1.0.0/localstorage_py_local.egg-info/SOURCES.txt +9 -0
- localstorage_py_local-1.0.0/localstorage_py_local.egg-info/dependency_links.txt +1 -0
- localstorage_py_local-1.0.0/localstorage_py_local.egg-info/top_level.txt +1 -0
- localstorage_py_local-1.0.0/pyproject.toml +21 -0
- localstorage_py_local-1.0.0/setup.cfg +4 -0
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: localstorage-py-local
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Простая библиотека для имитации localStorage в Python с сохранением в JSON
|
|
5
|
+
Author-email: - <-@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
Библеотека для работы с localstorage.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Библеотека для работы с localstorage.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .core import localstorage
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
class localstorage:
|
|
5
|
+
def __init__(self, filename, default_value=None):
|
|
6
|
+
# Каждому объекту задаем свое имя файла
|
|
7
|
+
self.filename = f"{filename}.json"
|
|
8
|
+
self.value = default_value
|
|
9
|
+
self.load(default_value)
|
|
10
|
+
|
|
11
|
+
def load(self, default_value):
|
|
12
|
+
if os.path.exists(self.filename):
|
|
13
|
+
try:
|
|
14
|
+
with open(self.filename, "r", encoding="utf-8") as f:
|
|
15
|
+
data = json.load(f)
|
|
16
|
+
self.value = data.get("value", default_value)
|
|
17
|
+
except Exception:
|
|
18
|
+
self.value = default_value
|
|
19
|
+
else:
|
|
20
|
+
self.value = default_value
|
|
21
|
+
self.save()
|
|
22
|
+
|
|
23
|
+
def save(self):
|
|
24
|
+
try:
|
|
25
|
+
with open(self.filename, "w", encoding="utf-8") as f:
|
|
26
|
+
json.dump({"value": self.value}, f, ensure_ascii=False, indent=4)
|
|
27
|
+
except Exception as e:
|
|
28
|
+
print(f"Ошибка сохранения: {e}")
|
|
29
|
+
|
|
30
|
+
def set(self, new_value):
|
|
31
|
+
self.value = new_value
|
|
32
|
+
self.save()
|
|
33
|
+
|
|
34
|
+
def __str__(self):
|
|
35
|
+
return str(self.value)
|
|
36
|
+
|
|
37
|
+
def __repr__(self):
|
|
38
|
+
return f"localstorage({repr(self.value)})"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: localstorage-py-local
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Простая библиотека для имитации localStorage в Python с сохранением в JSON
|
|
5
|
+
Author-email: - <-@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.6
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
Библеотека для работы с localstorage.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
localstorage/__init__.py
|
|
5
|
+
localstorage/core.py
|
|
6
|
+
localstorage_py_local.egg-info/PKG-INFO
|
|
7
|
+
localstorage_py_local.egg-info/SOURCES.txt
|
|
8
|
+
localstorage_py_local.egg-info/dependency_links.txt
|
|
9
|
+
localstorage_py_local.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
localstorage
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "localstorage-py-local"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Простая библиотека для имитации localStorage в Python с сохранением в JSON"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "-", email = "-@example.com" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
requires-python = ">=3.6"
|
|
20
|
+
dependencies = []
|
|
21
|
+
|