funbase 0.0.1__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.
funbase-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nite017
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
funbase-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: funbase
3
+ Version: 0.0.1
4
+ Summary: FunBase: encrypted file-based database with .fb extension
5
+ Author: Nite017
6
+ Author-email: Nite017 <nite27845@yandex.ru>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 Nite017
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: Homepage, https://github.com/Nite017/funbase
29
+ Project-URL: Repository, https://github.com/Nite017/funbase
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: cryptography>=3.4
37
+ Dynamic: author
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+
41
+ # funbase
42
+
43
+ FunBase — простая файловая база данных с шифрованием и расширением `.fb`.
44
+
45
+ ## Установка
46
+
47
+ ```bash
48
+ pip install funbase
49
+ ```
50
+
51
+ ## Использование
52
+
53
+ ```python
54
+ from funbase import FunBase
55
+ from cryptography.fernet import Fernet
56
+
57
+ # ключ один раз создать и сохранить
58
+ key = Fernet.generate_key()
59
+ db = FunBase("data.fb", key)
60
+
61
+ db.create_table("users")
62
+ db.insert("users", {"id": 1, "name": "Alice"})
63
+ print(db.select_all("users"))
64
+ ```
65
+
66
+ Файлы базы данных имеют расширение `.fb` и зашифрованы с помощью `cryptography.fernet`.
67
+ Шифрование можно заменить, правя методы `_encrypt` и `_decrypt` в `FunBase`.
@@ -0,0 +1,27 @@
1
+ # funbase
2
+
3
+ FunBase — простая файловая база данных с шифрованием и расширением `.fb`.
4
+
5
+ ## Установка
6
+
7
+ ```bash
8
+ pip install funbase
9
+ ```
10
+
11
+ ## Использование
12
+
13
+ ```python
14
+ from funbase import FunBase
15
+ from cryptography.fernet import Fernet
16
+
17
+ # ключ один раз создать и сохранить
18
+ key = Fernet.generate_key()
19
+ db = FunBase("data.fb", key)
20
+
21
+ db.create_table("users")
22
+ db.insert("users", {"id": 1, "name": "Alice"})
23
+ print(db.select_all("users"))
24
+ ```
25
+
26
+ Файлы базы данных имеют расширение `.fb` и зашифрованы с помощью `cryptography.fernet`.
27
+ Шифрование можно заменить, правя методы `_encrypt` и `_decrypt` в `FunBase`.
@@ -0,0 +1,3 @@
1
+ from .funbase import FunBase
2
+
3
+ __all__ = ["FunBase"]
@@ -0,0 +1,78 @@
1
+ import json
2
+ import os
3
+ import sys
4
+ from typing import Any, Dict, List, Optional
5
+
6
+ # ↓↓↓ ТОЛЬКО ЭТО МЕСТО МОЖНО МЕНЯТЬ НА СВОЙ ШИФР ↓↓↓
7
+ from cryptography.fernet import Fernet # pip install cryptography
8
+
9
+
10
+ class FunBase:
11
+ """
12
+ Файловая база FunBase.
13
+ Файлы: *.fb (funbase format).
14
+ Шифрование вынесено в отдельный метод — его можно заменить.
15
+ """
16
+
17
+ def __init__(self, db_path: str, key: Optional[bytes] = None):
18
+ if not db_path.endswith(".fb"):
19
+ raise ValueError("FunBase file must have extension .fb")
20
+
21
+ self.db_path = db_path
22
+ self.key = key or Fernet.generate_key()
23
+ self.cipher = Fernet(self.key) # одно место с шифром
24
+
25
+ self.data: Dict[str, List[Dict]] = {}
26
+ self._load()
27
+
28
+ def _encrypt(self, data: bytes) -> bytes:
29
+ """Здесь можно поменять шифрацию на свою."""
30
+ return self.cipher.encrypt(data)
31
+
32
+ def _decrypt(self, data: bytes) -> bytes:
33
+ """Здесь можно поменять дешифрацию на свою."""
34
+ return self.cipher.decrypt(data)
35
+
36
+ def _load(self):
37
+ if not os.path.exists(self.db_path):
38
+ self.data = {}
39
+ self._save()
40
+ return
41
+
42
+ with open(self.db_path, "rb") as f:
43
+ encrypted = f.read()
44
+
45
+ decrypted = self._decrypt(encrypted)
46
+ self.data = json.loads(decrypted.decode("utf-8"))
47
+
48
+ def _save(self):
49
+ raw = json.dumps(self.data, ensure_ascii=False).encode("utf-8")
50
+ encrypted = self._encrypt(raw)
51
+
52
+ with open(self.db_path, "wb") as f:
53
+ f.write(encrypted)
54
+
55
+ def create_table(self, table_name: str) -> "FunBase":
56
+ if table_name not in self.data:
57
+ self.data[table_name] = []
58
+ self._save()
59
+ return self
60
+
61
+ def insert(self, table_name: str, record: Dict[str, Any]) -> "FunBase":
62
+ table = self.data.setdefault(table_name, [])
63
+ table.append(record)
64
+ self._save()
65
+ return self
66
+
67
+ def select_all(self, table_name: str) -> List[Dict]:
68
+ return self.data.get(table_name, [])
69
+
70
+ def delete_table(self, table_name: str) -> "FunBase":
71
+ if table_name in self.data:
72
+ del self.data[table_name]
73
+ self._save()
74
+ return self
75
+
76
+ def get_key(self) -> bytes:
77
+ """Вернуть ключ; его нужно сохранить отдельно."""
78
+ return self.key
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.4
2
+ Name: funbase
3
+ Version: 0.0.1
4
+ Summary: FunBase: encrypted file-based database with .fb extension
5
+ Author: Nite017
6
+ Author-email: Nite017 <nite27845@yandex.ru>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 Nite017
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Project-URL: Homepage, https://github.com/Nite017/funbase
29
+ Project-URL: Repository, https://github.com/Nite017/funbase
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Requires-Python: >=3.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: cryptography>=3.4
37
+ Dynamic: author
38
+ Dynamic: license-file
39
+ Dynamic: requires-python
40
+
41
+ # funbase
42
+
43
+ FunBase — простая файловая база данных с шифрованием и расширением `.fb`.
44
+
45
+ ## Установка
46
+
47
+ ```bash
48
+ pip install funbase
49
+ ```
50
+
51
+ ## Использование
52
+
53
+ ```python
54
+ from funbase import FunBase
55
+ from cryptography.fernet import Fernet
56
+
57
+ # ключ один раз создать и сохранить
58
+ key = Fernet.generate_key()
59
+ db = FunBase("data.fb", key)
60
+
61
+ db.create_table("users")
62
+ db.insert("users", {"id": 1, "name": "Alice"})
63
+ print(db.select_all("users"))
64
+ ```
65
+
66
+ Файлы базы данных имеют расширение `.fb` и зашифрованы с помощью `cryptography.fernet`.
67
+ Шифрование можно заменить, правя методы `_encrypt` и `_decrypt` в `FunBase`.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ funbase/__init__.py
6
+ funbase/funbase.py
7
+ funbase.egg-info/PKG-INFO
8
+ funbase.egg-info/SOURCES.txt
9
+ funbase.egg-info/dependency_links.txt
10
+ funbase.egg-info/requires.txt
11
+ funbase.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ cryptography>=3.4
@@ -0,0 +1 @@
1
+ funbase
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "funbase"
7
+ version = "0.0.1"
8
+ description = "FunBase: encrypted file-based database with .fb extension"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = {file = "LICENSE"}
12
+ authors = [
13
+ {name = "Nite017", email = "nite27845@yandex.ru"},
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+
21
+ dependencies = [
22
+ "cryptography>=3.4",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://github.com/Nite017/funbase"
27
+ Repository = "https://github.com/Nite017/funbase"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
funbase-0.0.1/setup.py ADDED
@@ -0,0 +1,22 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as f:
4
+ long_description = f.read()
5
+
6
+ setup(
7
+ name="funbase",
8
+ version="0.1.0",
9
+ author="Nite017",
10
+ author_email="nite27845@yandex.ru",
11
+ description="FunBase: encrypted file-based database with .fb extension",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ packages=find_packages(),
15
+ python_requires=">=3.7",
16
+ install_requires=["cryptography>=3.4"],
17
+ classifiers=[
18
+ "Programming Language :: Python :: 3",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ ],
22
+ )