dictature 0.9.1__tar.gz → 0.9.2__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.
- {dictature-0.9.1/src/dictature.egg-info → dictature-0.9.2}/PKG-INFO +1 -1
- {dictature-0.9.1 → dictature-0.9.2}/pyproject.toml +1 -1
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/dictature.py +17 -3
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/transformer/aes.py +5 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/transformer/mock.py +3 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/transformer/passthrough.py +3 -0
- {dictature-0.9.1 → dictature-0.9.2/src/dictature.egg-info}/PKG-INFO +1 -1
- {dictature-0.9.1 → dictature-0.9.2}/LICENSE +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/README.md +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/setup.cfg +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/__init__.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/backend/__init__.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/backend/directory.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/backend/mock.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/backend/sqlite.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature/transformer/__init__.py +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature.egg-info/SOURCES.txt +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature.egg-info/dependency_links.txt +0 -0
- {dictature-0.9.1 → dictature-0.9.2}/src/dictature.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dictature
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.2
|
4
4
|
Summary: dictature -- A generic wrapper around dict-like interface with mulitple backends
|
5
5
|
Author-email: Adam Hlavacek <git@adamhlavacek.com>
|
6
6
|
Project-URL: Homepage, https://github.com/esoadamo/dictature
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "dictature"
|
7
|
-
version = "0.9.
|
7
|
+
version = "0.9.2"
|
8
8
|
description = "dictature -- A generic wrapper around dict-like interface with mulitple backends"
|
9
9
|
authors = [
|
10
10
|
{ name = "Adam Hlavacek", email = "git@adamhlavacek.com" }
|
@@ -70,7 +70,7 @@ class DictatureTable:
|
|
70
70
|
self.__backend = backend
|
71
71
|
self.__name_transformer = name_transformer
|
72
72
|
self.__value_transformer = value_transformer
|
73
|
-
self.__table = self.__backend.table(self.
|
73
|
+
self.__table = self.__backend.table(self.__table_key(table_name))
|
74
74
|
self.__table_created = False
|
75
75
|
|
76
76
|
def get(self, item: str, default: Optional[Any] = None) -> Any:
|
@@ -106,7 +106,7 @@ class DictatureTable:
|
|
106
106
|
|
107
107
|
def __getitem__(self, item: str) -> Any:
|
108
108
|
self.__create_table()
|
109
|
-
saved_value = self.__table.get(self.
|
109
|
+
saved_value = self.__table.get(self.__item_key(item))
|
110
110
|
mode = ValueMode(saved_value.mode)
|
111
111
|
value = self.__value_transformer.backward(saved_value.value)
|
112
112
|
match mode:
|
@@ -130,7 +130,7 @@ class DictatureTable:
|
|
130
130
|
value = b64encode(compress(pickle.dumps(value))).decode('ascii')
|
131
131
|
value_mode = value_mode.pickle
|
132
132
|
|
133
|
-
key = self.
|
133
|
+
key = self.__item_key(key)
|
134
134
|
value = self.__value_transformer.forward(value)
|
135
135
|
self.__table.set(key, Value(value=value, mode=value_mode.value))
|
136
136
|
|
@@ -148,3 +148,17 @@ class DictatureTable:
|
|
148
148
|
return
|
149
149
|
self.__table.create()
|
150
150
|
self.__table_created = True
|
151
|
+
|
152
|
+
def __item_key(self, item: str) -> str:
|
153
|
+
if not self.__name_transformer.static:
|
154
|
+
for key in self.__table.keys():
|
155
|
+
if self.__name_transformer.backward(key) == item:
|
156
|
+
return key
|
157
|
+
return self.__name_transformer.forward(item)
|
158
|
+
|
159
|
+
def __table_key(self, table_name: str) -> str:
|
160
|
+
if not self.__name_transformer.static:
|
161
|
+
for key in self.__backend.keys():
|
162
|
+
if self.__name_transformer.backward(key) == table_name:
|
163
|
+
return key
|
164
|
+
return self.__name_transformer.forward(table_name)
|
@@ -12,6 +12,7 @@ class AESTransformer(MockTransformer):
|
|
12
12
|
def __init__(self, passphrase: str, static_names_mode: bool, salt: str = 'dictature') -> None:
|
13
13
|
self.__key = scrypt(passphrase, salt, 16, N=2 ** 14, r=8, p=1)
|
14
14
|
self.__mode = AES.MODE_GCM if not static_names_mode else AES.MODE_ECB
|
15
|
+
self.__static = static_names_mode
|
15
16
|
|
16
17
|
def forward(self, text: str) -> str:
|
17
18
|
cipher = self.__cipher
|
@@ -36,3 +37,7 @@ class AESTransformer(MockTransformer):
|
|
36
37
|
def __cipher(self) -> AES:
|
37
38
|
# noinspection PyTypeChecker
|
38
39
|
return AES.new(self.__key, self.__mode)
|
40
|
+
|
41
|
+
@property
|
42
|
+
def static(self) -> bool:
|
43
|
+
return self.__static
|
@@ -4,3 +4,6 @@ class MockTransformer:
|
|
4
4
|
raise NotImplementedError("This method should be implemented by the child class")
|
5
5
|
def backward(self, text: str) -> str:
|
6
6
|
raise NotImplementedError("This method should be implemented by the child class")
|
7
|
+
@property
|
8
|
+
def static(self) -> bool:
|
9
|
+
raise NotImplementedError("This method should be implemented by the child class")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dictature
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.2
|
4
4
|
Summary: dictature -- A generic wrapper around dict-like interface with mulitple backends
|
5
5
|
Author-email: Adam Hlavacek <git@adamhlavacek.com>
|
6
6
|
Project-URL: Homepage, https://github.com/esoadamo/dictature
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|