datastorex 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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2018 The Python Packaging Authority
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: datastorex
3
+ Version: 0.0.1
4
+ Summary: An orderly data storage library
5
+ Author-email: Davyd Bilyi <10096d@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # Data storage
15
+
16
+ This is a data storage package.
17
+ # DISCLAIMER :
18
+ Do NOT open untrsuted datastore files.
19
+ Becuase the datastore package is backed by pickle ,
20
+ arbitrary code may be executed on load.
@@ -0,0 +1,7 @@
1
+ # Data storage
2
+
3
+ This is a data storage package.
4
+ # DISCLAIMER :
5
+ Do NOT open untrsuted datastore files.
6
+ Becuase the datastore package is backed by pickle ,
7
+ arbitrary code may be executed on load.
@@ -0,0 +1,20 @@
1
+ [project]
2
+ name = "datastorex"
3
+ version = "0.0.1"
4
+ authors = [
5
+ { name="Davyd Bilyi", email="10096d@gmail.com" },
6
+ ]
7
+ description = "An orderly data storage library"
8
+ readme = "README.md"
9
+ requires-python = ">=3.9"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "Operating System :: OS Independent",
13
+ ]
14
+ license = "MIT"
15
+ license-files = ["LICEN[CS]E*"]
16
+
17
+ [build-system]
18
+ requires = ["setuptools >= 77.0.3"]
19
+ build-backend = "setuptools.build_meta"
20
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,7 @@
1
+ class NotPicklableObjectInShelfError(Exception):
2
+ def __init__(self, *args):
3
+ super().__init__(*args)
4
+
5
+ class UnhashableLabelError(Exception):
6
+ def __init__(self, *args):
7
+ super().__init__(*args)
@@ -0,0 +1,55 @@
1
+ import pickle
2
+ import errors
3
+
4
+ class ShelfObject:
5
+ def __is_picklable(obj):
6
+ try:
7
+ pickle.dumps(obj)
8
+ return True
9
+ except Exception:
10
+ return False
11
+
12
+ def __init__(self,label,value):
13
+ self.label = label
14
+ try:
15
+ _ = hash(value)
16
+ except:
17
+ raise errors.UnhashableLabelError(f"Can't hash label {label}.")
18
+ if not self.__is_picklable(value):
19
+ raise errors.NotPicklableObjectInShelfError(f"Can't pickle object {value}.")
20
+ self.value = value
21
+ def __hash__(self):
22
+ return hash(self.value)
23
+
24
+
25
+ class Shelf:
26
+
27
+ def __init__(self,size):
28
+ if size == -1:
29
+ self.__unlimited = True
30
+ self.__data = []
31
+ else:
32
+ self.__unlimited = False
33
+ self.__data = [None] * size
34
+ self.name_to_index = {}
35
+
36
+ def __is_picklable(obj):
37
+ try:
38
+ pickle.dumps(obj)
39
+ return True
40
+ except Exception:
41
+ return False
42
+ def __setitem__(self, key, value:ShelfObject):
43
+ if not isinstance(key,int):
44
+ raise ValueError("Can not set object number to non-integer.")
45
+ self.name_to_index[value.label] = key
46
+ self.__data[key] = pickle.dumps(value)
47
+ def __getitem__(self, key):
48
+ if isinstance(key,int):
49
+ _key = key
50
+ else:
51
+ _key = self.name_to_index[key]
52
+ return pickle.loads(self.__data(_key))
53
+
54
+
55
+
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: datastorex
3
+ Version: 0.0.1
4
+ Summary: An orderly data storage library
5
+ Author-email: Davyd Bilyi <10096d@gmail.com>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # Data storage
15
+
16
+ This is a data storage package.
17
+ # DISCLAIMER :
18
+ Do NOT open untrsuted datastore files.
19
+ Becuase the datastore package is backed by pickle ,
20
+ arbitrary code may be executed on load.
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/datastorex/__init__.py
5
+ src/datastorex/errors.py
6
+ src/datastorex/shelf.py
7
+ src/datastorex.egg-info/PKG-INFO
8
+ src/datastorex.egg-info/SOURCES.txt
9
+ src/datastorex.egg-info/dependency_links.txt
10
+ src/datastorex.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ datastorex