ramifice 0.8.14__py3-none-any.whl → 0.8.16__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/models/model.py CHANGED
@@ -188,3 +188,12 @@ class Model(metaclass=ABCMeta):
188
188
  elif group == "id":
189
189
  value = ObjectId(value)
190
190
  self.__dict__[name].value = value
191
+
192
+ # --------------------------------------------------------------------------
193
+ def get_clean_data(self) -> dict[str, Any]:
194
+ """Get clean data."""
195
+ clean_data: dict[str, Any] = {}
196
+ for name, data in self.__dict__.items():
197
+ if not callable(data):
198
+ clean_data[name] = data.value
199
+ return clean_data
ramifice/utils/errors.py CHANGED
@@ -4,7 +4,7 @@
4
4
  class RamificeException(Exception):
5
5
  """Ramifice - Root Exception for Ramifice."""
6
6
 
7
- def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] # noqa: D107
7
+ def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def]# noqa: D107
8
8
  super().__init__(*args, **kwargs)
9
9
 
10
10
 
@@ -35,7 +35,7 @@ class DoesNotMatchRegexError(RamificeException):
35
35
  class NoModelsForMigrationError(RamificeException):
36
36
  """Ramifice - Exception raised if no Models for migration."""
37
37
 
38
- def __init__(self): # type: ignore[no-untyped-def] # noqa: D107
38
+ def __init__(self) -> None: # noqa: D107
39
39
  self.message = "No Models for Migration!"
40
40
  super().__init__(self.message)
41
41
 
@@ -43,7 +43,7 @@ class Migration:
43
43
  # Raise the exception if there are no models for migration.
44
44
  if len(self.model_list) == 0:
45
45
  logger.critical("No Models for Migration!")
46
- raise NoModelsForMigrationError() # type: ignore[no-untyped-call]
46
+ raise NoModelsForMigrationError()
47
47
 
48
48
  async def reset(self) -> None:
49
49
  """Ramifice - Reset the condition of the models in a super collection.
@@ -1,5 +1,12 @@
1
1
  """Ramifice - Set of mixins for Models and Fields."""
2
2
 
3
+ __all__ = (
4
+ "AddValidMixin",
5
+ "HooksMixin",
6
+ "IndexMixin",
7
+ "JsonMixin",
8
+ )
9
+
3
10
  from ramifice.utils.mixins.add_valid import AddValidMixin
4
11
  from ramifice.utils.mixins.hooks import HooksMixin
5
12
  from ramifice.utils.mixins.indexing import IndexMixin
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.8.14
3
+ Version: 0.8.16
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/
@@ -62,6 +62,11 @@ Description-Content-Type: text/markdown
62
62
  <a href="https://docs.astral.sh/ruff/" alt="Code style: Ruff"><img src="https://img.shields.io/badge/code%20style-Ruff-FDD835.svg" alt="Code style: Ruff"></a>
63
63
  <a href="https://github.com/kebasyaty/ramifice" alt="PyPI implementation"><img src="https://img.shields.io/pypi/implementation/ramifice" alt="PyPI implementation"></a>
64
64
  <a href="https://github.com/kebasyaty/ramifice" alt="GitHub repository"><img src="https://img.shields.io/badge/--ecebeb?logo=github&logoColor=000000" alt="GitHub repository"></a>
65
+ <br>
66
+ <a href="https://pypi.org/project/ramifice"><img src="https://img.shields.io/pypi/format/ramifice" alt="Format"></a>
67
+ <a href="https://github.com/kebasyaty/ramifice"><img src="https://img.shields.io/github/languages/top/kebasyaty/ramifice" alt="Top"></a>
68
+ <a href="https://github.com/kebasyaty/ramifice"><img src="https://img.shields.io/github/repo-size/kebasyaty/ramifice" alt="Size"></a>
69
+ <a href="https://github.com/kebasyaty/ramifice"><img src="https://img.shields.io/github/last-commit/kebasyaty/ramifice/main" alt="Last commit"></a>
65
70
  </p>
66
71
  <p align="center">
67
72
  Ramifice is built around <a href="https://pypi.org/project/pymongo/" alt="PyMongo">PyMongo</a>.
@@ -127,6 +132,7 @@ It is recommended to look at examples [here](https://github.com/kebasyaty/ramifi
127
132
  ```python
128
133
  import re
129
134
  import asyncio
135
+ from typing import Any
130
136
  from datetime import datetime
131
137
  import pprint
132
138
 
@@ -145,7 +151,7 @@ class User:
145
151
  """Model of User."""
146
152
 
147
153
  def fields(self) -> None:
148
- """For adding fields."""
154
+ """Adding fields."""
149
155
  # For custom translations.
150
156
  gettext = translations.gettext
151
157
  # ngettext = translations.ngettext
@@ -182,23 +188,21 @@ class User:
182
188
  ignored=True,
183
189
  )
184
190
 
185
-
186
- # Optional method.
191
+ # Optional method
187
192
  async def add_validation(self) -> dict[str, str]:
188
193
  """Additional validation of fields."""
189
194
  gettext = translations.gettext
190
195
  error_map: dict[str, str] = {}
191
196
 
192
- # Get clean data.
193
- id = self.id.value
194
- username = self.username.value
195
- password = self.password.value
196
- сonfirm_password = self.сonfirm_password.value
197
+ # Get clean data
198
+ cd: dict[str, Any] = self.get_clean_data()
197
199
 
198
- if re.match(r"^[a-zA-Z0-9_]+$", username) is None:
200
+ # Check username
201
+ if re.match(r"^[a-zA-Z0-9_]+$", cd["username"]) is None:
199
202
  error_map["username"] = gettext("Allowed chars: %s") % "a-z A-Z 0-9 _"
200
203
 
201
- if id is None and (password != сonfirm_password):
204
+ # Check password
205
+ if cd["id"] is None and (cd["password"] != cd["сonfirm_password"]):
202
206
  error_map["password"] = gettext("Passwords do not match!")
203
207
  return error_map
204
208
 
@@ -250,6 +254,9 @@ async def main():
250
254
  # (if necessary)
251
255
  # await User.collection().drop()
252
256
 
257
+ # Close connection.
258
+ await client.close()
259
+
253
260
 
254
261
  if __name__ == "__main__":
255
262
  asyncio.run(main())
@@ -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=m19E7h3Fv2F7oDotc1z_n_NglFN7KmXOrNL0r4Jg_y4,7352
48
+ ramifice/models/model.py,sha256=Q2FG0zBNCIPEQZXLEj_l2kB-6LT0acFKoBVU7hYiDPE,7717
49
49
  ramifice/paladins/__init__.py,sha256=I2FzvCrp6upv_GPLfDqaVLwIT6-3Dp_K9i51tFUXDuc,673
50
50
  ramifice/paladins/check.py,sha256=mxvnHR9EG7eQrGOE7wph1lCUq3jf2RF0Ovhhtz7W3g8,6974
51
51
  ramifice/paladins/delete.py,sha256=Ynew5zvEBRJNmss5I8hSIp7KgBHpSvDEJCwOfMH5MUU,3723
@@ -67,18 +67,18 @@ ramifice/paladins/groups/slug_group.py,sha256=QCO0ry0-E7bO9tsD4NajPMMbB0chGmuLyz
67
67
  ramifice/paladins/groups/text_group.py,sha256=2CyhZxQgFDv-uGRKIxgngB15_BfgPmhxp4N_X7WXsSQ,4538
68
68
  ramifice/utils/__init__.py,sha256=wdOon9X-38jYpgOy1qyN-u7IzbGEXXuXudnzj5xFQGI,54
69
69
  ramifice/utils/constants.py,sha256=VFvzFaOfzzhfoLMrI9nH9Dz_P5ktI8cOdqTINFHUEo4,2624
70
- ramifice/utils/errors.py,sha256=S23nvSwxkNR7W5ByE8HssQSrSfWoEY_Ftn4iOtCU68c,2977
70
+ ramifice/utils/errors.py,sha256=L_eZttzoLvv5_ukCan7vTmCbYcSbuGfOvfd4q4Cy17s,2953
71
71
  ramifice/utils/fixtures.py,sha256=R6lHvNp5hvA6Bryom2XNu3CvT-zwXpBGH8AZa3gRC1Q,3357
72
- ramifice/utils/migration.py,sha256=ZOAiv-9hJbmm5zZt69G3Y4kMGV4EyG4sDbwR0Ta0WAo,11562
72
+ ramifice/utils/migration.py,sha256=IZ3MFJD2n61uJ0Nl90Ll28GJwjUJf_2IOVbATTHDS_A,11529
73
73
  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
- ramifice/utils/mixins/__init__.py,sha256=1W6HoabjN73crpzJ_rmhI10KM9C2RbPZn5Em6Gi9Aig,283
76
+ ramifice/utils/mixins/__init__.py,sha256=fTsjH8h4OGvFC4zGawLLbU2i-c2OBdPftC3A-ZT5Pbw,379
77
77
  ramifice/utils/mixins/add_valid.py,sha256=vYq4wGdpfA4iLMts7G0NvDALZBwupOScsajDFWCmmYg,472
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.14.dist-info/METADATA,sha256=l8x1wfwuS1w3fEOaVN5_aQEVZufoWWkgO8yeQA_dBUc,20361
82
- ramifice-0.8.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
- ramifice-0.8.14.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
- ramifice-0.8.14.dist-info/RECORD,,
81
+ ramifice-0.8.16.dist-info/METADATA,sha256=ySscCHH2SOY5PCObHgagtPdTrzdwQSeQNYCaj-8GRxU,20961
82
+ ramifice-0.8.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
+ ramifice-0.8.16.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
84
+ ramifice-0.8.16.dist-info/RECORD,,