ramifice 0.8.17__py3-none-any.whl → 0.8.19__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.
ramifice/__init__.py CHANGED
@@ -15,6 +15,7 @@
15
15
  """Ramifice - ORM-like API MongoDB for Python language."""
16
16
 
17
17
  __all__ = (
18
+ "NamedTuple",
18
19
  "model",
19
20
  "translations",
20
21
  "Migration",
@@ -23,6 +24,8 @@ __all__ = (
23
24
 
24
25
  import logging
25
26
 
27
+ from xloft import NamedTuple
28
+
26
29
  from ramifice.models.decorator import model
27
30
  from ramifice.utils import translations
28
31
  from ramifice.utils.migration import Migration
ramifice/models/model.py CHANGED
@@ -9,6 +9,7 @@ import orjson
9
9
  from babel.dates import format_date, format_datetime
10
10
  from bson.objectid import ObjectId
11
11
  from dateutil.parser import parse
12
+ from xloft import NamedTuple
12
13
 
13
14
  from ramifice.fields import DateTimeField, IDField
14
15
  from ramifice.utils import translations
@@ -190,12 +191,14 @@ class Model(metaclass=ABCMeta):
190
191
  self.__dict__[name].value = value
191
192
 
192
193
  # --------------------------------------------------------------------------
193
- def get_clean_data(self) -> tuple[dict[str, Any], dict[str, str]]:
194
+ def get_clean_data(self) -> tuple[NamedTuple, NamedTuple]:
194
195
  """Get clean data."""
195
196
  clean_data: dict[str, Any] = {}
197
+ error_map: dict[str, Any] = {}
196
198
 
197
199
  for name, data in self.__dict__.items():
198
200
  if not callable(data):
199
201
  clean_data[name] = data.value
202
+ error_map[name] = None
200
203
 
201
- return (clean_data, {})
204
+ return (NamedTuple(**clean_data), NamedTuple(**error_map))
@@ -4,10 +4,12 @@ __all__ = ("AddValidMixin",)
4
4
 
5
5
  from abc import ABCMeta
6
6
 
7
+ from xloft import NamedTuple
8
+
7
9
 
8
10
  class AddValidMixin(metaclass=ABCMeta):
9
11
  """Ramifice - Contains an abstract method for additional validation of fields."""
10
12
 
11
- async def add_validation(self) -> dict[str, str]:
13
+ async def add_validation(self) -> NamedTuple:
12
14
  """Ramifice - Additional validation of fields."""
13
- return {}
15
+ return NamedTuple()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.8.17
3
+ Version: 0.8.19
4
4
  Summary: ORM-pseudo-like API MongoDB for Python language.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/ramifice
6
6
  Project-URL: Documentation, https://kebasyaty.github.io/ramifice/
@@ -8,7 +8,7 @@ Project-URL: Repository, https://github.com/kebasyaty/ramifice
8
8
  Project-URL: Source, https://github.com/kebasyaty/ramifice
9
9
  Project-URL: Bug Tracker, https://github.com/kebasyaty/ramifice/issues
10
10
  Project-URL: Changelog, https://github.com/kebasyaty/ramifice/blob/v0/CHANGELOG.md
11
- Author-email: Gennady Kostyunin <kebasyaty@gmail.com>
11
+ Author-email: kebasyaty <kebasyaty@gmail.com>
12
12
  License-Expression: MIT
13
13
  License-File: LICENSE
14
14
  Keywords: mongo,mongodb,orm,pymongo,ramifice
@@ -35,6 +35,7 @@ Requires-Dist: python-dateutil>=2.9.0.post0
35
35
  Requires-Dist: python-slugify>=8.0.4
36
36
  Requires-Dist: pyyaml>=6.0.2
37
37
  Requires-Dist: termcolor>=3.1.0
38
+ Requires-Dist: xloft>=0.1.6
38
39
  Description-Content-Type: text/markdown
39
40
 
40
41
  <div align="center">
@@ -137,7 +138,12 @@ from datetime import datetime
137
138
  import pprint
138
139
 
139
140
  from pymongo import AsyncMongoClient
140
- from ramifice import model, translations, Migration
141
+ from ramifice import (
142
+ NamedTuple,
143
+ model,
144
+ translations,
145
+ Migration,
146
+ )
141
147
  from ramifice.fields import (
142
148
  ImageField,
143
149
  PasswordField,
@@ -189,19 +195,20 @@ class User:
189
195
  )
190
196
 
191
197
  # Optional method
192
- async def add_validation(self) -> dict[str, str]:
198
+ async def add_validation(self) -> NamedTuple:
193
199
  """Additional validation of fields."""
194
200
  gettext = translations.gettext
195
- cd, err_map = self.get_clean_data()
201
+ cd, err = self.get_clean_data()
196
202
 
197
203
  # Check username
198
- if re.match(r"^[a-zA-Z0-9_]+$", cd["username"]) is None:
199
- err_map["username"] = gettext("Allowed chars: %s") % "a-z A-Z 0-9 _"
204
+ if re.match(r"^[a-zA-Z0-9_]+$", cd.username) is None:
205
+ err.update("username", gettext("Allowed chars: %s") % "a-z A-Z 0-9 _")
200
206
 
201
207
  # Check password
202
- if cd["_id"] is None and (cd["password"] != cd["сonfirm_password"]):
203
- err_map["password"] = gettext("Passwords do not match!")
204
- return err_map
208
+ if cd._id is None and (cd.password != cdonfirm_password):
209
+ err.update("password", gettext("Passwords do not match!"))
210
+
211
+ return err
205
212
 
206
213
 
207
214
  async def main():
@@ -1,4 +1,4 @@
1
- ramifice/__init__.py,sha256=Xejr_t4cimFFNKS6xXvAeLRue1vTB5kZWGeYbHXDUDw,1116
1
+ ramifice/__init__.py,sha256=RHncMLg027UkR-Pbgdg_7jCJg7BDu2-6VJDY1_USln8,1167
2
2
  ramifice/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  ramifice/commons/__init__.py,sha256=F5tnz0bz7IcwOT9wkPmyWL7cDDUI1BUVSfC73G56dfs,567
4
4
  ramifice/commons/general.py,sha256=HuErflr-dZ2pWhaSy81IGllFfGxlj8yrdnaAEGUtK3M,5554
@@ -45,7 +45,7 @@ ramifice/fields/general/number_group.py,sha256=jspiA9hWiU_hNhXbTku2rZG3UezrhEVBG
45
45
  ramifice/fields/general/text_group.py,sha256=hYVX4-ipD2_eyj-WpHIHnFrpQevySaVd4twffUsrOLo,1164
46
46
  ramifice/models/__init__.py,sha256=y5jRhSzcPuEVUWr1u--o1GyjFb7irlf5Rn2gPvQ3IPg,26
47
47
  ramifice/models/decorator.py,sha256=PX6b8DTP_Qz1SjyPcZ1vGDS4AGRZ6ZD8z8y6497j-DM,6685
48
- ramifice/models/model.py,sha256=ufBWkAHvZjP3kN9x-VMPVq7k6vHhxcTvECV-BvaP6dc,7750
48
+ ramifice/models/model.py,sha256=M-pYUqzOhvzZEc2tfPy5fNDdrtIC2mFvajV3q2CpOfc,7887
49
49
  ramifice/paladins/__init__.py,sha256=I2FzvCrp6upv_GPLfDqaVLwIT6-3Dp_K9i51tFUXDuc,673
50
50
  ramifice/paladins/check.py,sha256=L7mYsN5qp6ZlGiyPBQK1jw4GN03aIh8QpbbdK6-n6S4,6968
51
51
  ramifice/paladins/delete.py,sha256=Ynew5zvEBRJNmss5I8hSIp7KgBHpSvDEJCwOfMH5MUU,3723
@@ -74,11 +74,11 @@ ramifice/utils/tools.py,sha256=LZyA715HnkNO7TcBu4Ia29A6Ko3n-F2BRULzIyNKt9o,3279
74
74
  ramifice/utils/translations.py,sha256=Jh0nzwcn3bhUU2TjPAQboe3_pkVyhYQYdeINyC5SQo8,4701
75
75
  ramifice/utils/unit.py,sha256=ToBeu92tzOY32fuzLdxScNeYXvGIDr0nx7yTv2DShVo,2604
76
76
  ramifice/utils/mixins/__init__.py,sha256=fTsjH8h4OGvFC4zGawLLbU2i-c2OBdPftC3A-ZT5Pbw,379
77
- ramifice/utils/mixins/add_valid.py,sha256=00eIBlgsUU1TfDo1rUQT5zw7_Iv9IubORTbzuKoVB5o,425
77
+ ramifice/utils/mixins/add_valid.py,sha256=Yxo8LfJMxcAsY-ooZV1cLwFsfjxV5MPR0ebnWpyo4oE,463
78
78
  ramifice/utils/mixins/hooks.py,sha256=h8coNstWWHI4VwPgpjx0NWTj93-5NDAGtav0VFh-fk4,1031
79
79
  ramifice/utils/mixins/indexing.py,sha256=WVLxmkLKg-C_LHn2hq6LJuOkSr9eS-XUUvCMgK-pKYo,387
80
80
  ramifice/utils/mixins/json_converter.py,sha256=qBqFYol3Pbq1kX33EWB6FsYUL3AGSdYNtQE97HQ9jy4,1225
81
- ramifice-0.8.17.dist-info/METADATA,sha256=gXiqJfKJX6s5dpHEir2eZeU82lhZPdUP9Osf74Ba6BI,20884
82
- ramifice-0.8.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
- ramifice-0.8.17.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
- ramifice-0.8.17.dist-info/RECORD,,
81
+ ramifice-0.8.19.dist-info/METADATA,sha256=ay65vtUG10Pxqbqt6LvxNE-z1FyPdM2bcshWE6x5P14,20918
82
+ ramifice-0.8.19.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
+ ramifice-0.8.19.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
+ ramifice-0.8.19.dist-info/RECORD,,