ramifice 0.8.32__py3-none-any.whl → 0.8.34__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 +2 -0
- ramifice/commons/__init__.py +2 -0
- ramifice/commons/general.py +2 -0
- ramifice/commons/indexes.py +6 -6
- ramifice/commons/many.py +2 -0
- ramifice/commons/one.py +2 -0
- ramifice/commons/tools.py +7 -5
- ramifice/commons/unit_manager.py +2 -0
- ramifice/fields/__init__.py +2 -0
- ramifice/fields/bool_field.py +2 -0
- ramifice/fields/choice_float_dyn_field.py +2 -0
- ramifice/fields/choice_float_field.py +2 -0
- ramifice/fields/choice_float_mult_dyn_field.py +2 -0
- ramifice/fields/choice_float_mult_field.py +2 -0
- ramifice/fields/choice_int_dyn_field.py +2 -0
- ramifice/fields/choice_int_field.py +2 -0
- ramifice/fields/choice_int_mult_dyn_field.py +2 -0
- ramifice/fields/choice_int_mult_field.py +2 -0
- ramifice/fields/choice_text_dyn_field.py +2 -0
- ramifice/fields/choice_text_field.py +2 -0
- ramifice/fields/choice_text_mult_dyn_field.py +2 -0
- ramifice/fields/choice_text_mult_field.py +2 -0
- ramifice/fields/color_field.py +2 -0
- ramifice/fields/date_field.py +6 -6
- ramifice/fields/date_time_field.py +6 -6
- ramifice/fields/email_field.py +2 -0
- ramifice/fields/file_field.py +4 -2
- ramifice/fields/float_field.py +2 -0
- ramifice/fields/general/choice_group.py +2 -0
- ramifice/fields/general/date_group.py +2 -0
- ramifice/fields/general/field.py +2 -0
- ramifice/fields/general/file_group.py +2 -0
- ramifice/fields/general/number_group.py +2 -0
- ramifice/fields/general/text_group.py +2 -0
- ramifice/fields/id_field.py +2 -0
- ramifice/fields/image_field.py +5 -3
- ramifice/fields/integer_field.py +2 -0
- ramifice/fields/ip_field.py +2 -0
- ramifice/fields/password_field.py +5 -3
- ramifice/fields/phone_field.py +3 -1
- ramifice/fields/slug_field.py +2 -0
- ramifice/fields/text_field.py +3 -1
- ramifice/fields/url_field.py +2 -0
- ramifice/models/decorator.py +4 -2
- ramifice/models/model.py +2 -1
- ramifice/paladins/__init__.py +2 -0
- ramifice/paladins/add_valid.py +2 -0
- ramifice/paladins/check.py +2 -0
- ramifice/paladins/delete.py +2 -0
- ramifice/paladins/groups/__init__.py +2 -0
- ramifice/paladins/groups/bool_group.py +2 -0
- ramifice/paladins/groups/choice_group.py +2 -0
- ramifice/paladins/groups/date_group.py +7 -4
- ramifice/paladins/groups/file_group.py +20 -16
- ramifice/paladins/groups/id_group.py +2 -0
- ramifice/paladins/groups/img_group.py +20 -16
- ramifice/paladins/groups/num_group.py +8 -2
- ramifice/paladins/groups/pass_group.py +3 -1
- ramifice/paladins/groups/slug_group.py +2 -0
- ramifice/paladins/groups/text_group.py +5 -1
- ramifice/paladins/hooks.py +2 -0
- ramifice/paladins/indexing.py +2 -0
- ramifice/paladins/password.py +4 -3
- ramifice/paladins/refrash.py +2 -0
- ramifice/paladins/save.py +2 -0
- ramifice/paladins/tools.py +2 -0
- ramifice/paladins/validation.py +2 -0
- ramifice/utils/constants.py +2 -0
- ramifice/utils/errors.py +5 -3
- ramifice/utils/fixtures.py +4 -1
- ramifice/utils/migration.py +2 -0
- ramifice/utils/mixins.py +2 -0
- ramifice/utils/tools.py +5 -9
- ramifice/utils/translations.py +4 -2
- ramifice/utils/unit.py +2 -0
- {ramifice-0.8.32.dist-info → ramifice-0.8.34.dist-info}/METADATA +4 -4
- ramifice-0.8.34.dist-info/RECORD +83 -0
- ramifice-0.8.32.dist-info/RECORD +0 -83
- {ramifice-0.8.32.dist-info → ramifice-0.8.34.dist-info}/WHEEL +0 -0
- {ramifice-0.8.32.dist-info → ramifice-0.8.34.dist-info}/licenses/LICENSE +0 -0
ramifice/__init__.py
CHANGED
@@ -21,6 +21,8 @@ a simplified alternative (Types of selective fields with dynamic addition of ele
|
|
21
21
|
The project is more concentrated for web development or for applications with a graphic interface.
|
22
22
|
"""
|
23
23
|
|
24
|
+
from __future__ import annotations
|
25
|
+
|
24
26
|
__all__ = (
|
25
27
|
"NamedTuple",
|
26
28
|
"to_human_size",
|
ramifice/commons/__init__.py
CHANGED
ramifice/commons/general.py
CHANGED
ramifice/commons/indexes.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Indexation documents of collection."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("IndexMixin",)
|
4
6
|
|
5
7
|
from typing import Any
|
@@ -93,9 +95,8 @@ class IndexMixin:
|
|
93
95
|
"""Get information on this collection’s indexes."""
|
94
96
|
# Get collection for current model.
|
95
97
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
96
|
-
#
|
97
|
-
|
98
|
-
return result
|
98
|
+
#
|
99
|
+
return await collection.index_information(session=session, comment=comment)
|
99
100
|
|
100
101
|
@classmethod
|
101
102
|
async def list_indexes(
|
@@ -106,6 +107,5 @@ class IndexMixin:
|
|
106
107
|
"""Get a cursor over the index documents for this collection."""
|
107
108
|
# Get collection for current model.
|
108
109
|
collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
|
109
|
-
#
|
110
|
-
|
111
|
-
return cursor
|
110
|
+
#
|
111
|
+
return await collection.list_indexes(session=session, comment=comment)
|
ramifice/commons/many.py
CHANGED
ramifice/commons/one.py
CHANGED
ramifice/commons/tools.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Tool of Commons - A set of auxiliary methods."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = (
|
4
6
|
"correct_mongo_filter",
|
5
7
|
"password_to_none",
|
@@ -31,7 +33,7 @@ def password_to_none(
|
|
31
33
|
) -> dict[str, Any]:
|
32
34
|
"""Create object instance from Mongo document."""
|
33
35
|
for f_name, t_name in field_name_and_type.items():
|
34
|
-
if "PasswordField"
|
36
|
+
if t_name == "PasswordField":
|
35
37
|
mongo_doc[f_name] = None
|
36
38
|
return mongo_doc
|
37
39
|
|
@@ -44,10 +46,10 @@ def mongo_doc_to_raw_doc(
|
|
44
46
|
"""Convert the Mongo document to the raw document.
|
45
47
|
|
46
48
|
Special changes:
|
47
|
-
_id to str
|
48
|
-
password to None
|
49
|
-
date to str
|
50
|
-
datetime to str
|
49
|
+
- `_id to str`
|
50
|
+
- `password to None`
|
51
|
+
- `date to str`
|
52
|
+
- `datetime to str`
|
51
53
|
"""
|
52
54
|
doc: dict[str, Any] = {}
|
53
55
|
for f_name, f_data in inst_model_dict.items():
|
ramifice/commons/unit_manager.py
CHANGED
ramifice/fields/__init__.py
CHANGED
ramifice/fields/bool_field.py
CHANGED
ramifice/fields/color_field.py
CHANGED
ramifice/fields/date_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for enter date."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("DateField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -52,12 +54,10 @@ class DateField(Field, DateGroup):
|
|
52
54
|
) -> None:
|
53
55
|
if constants.DEBUG:
|
54
56
|
try:
|
55
|
-
if max_date is not None:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
if not isinstance(min_date, datetime):
|
60
|
-
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
57
|
+
if max_date is not None and not isinstance(max_date, datetime):
|
58
|
+
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
59
|
+
if min_date is not None and not isinstance(min_date, datetime):
|
60
|
+
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
61
61
|
if max_date is not None and min_date is not None and max_date <= min_date:
|
62
62
|
raise AssertionError("The `max_date` parameter should be more than the `min_date`!")
|
63
63
|
if default is not None:
|
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for enter date and time."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("DateTimeField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -52,12 +54,10 @@ class DateTimeField(Field, DateGroup):
|
|
52
54
|
) -> None:
|
53
55
|
if constants.DEBUG:
|
54
56
|
try:
|
55
|
-
if max_date is not None:
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
if not isinstance(min_date, datetime):
|
60
|
-
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
57
|
+
if max_date is not None and not isinstance(max_date, datetime):
|
58
|
+
raise AssertionError("Parameter `max_date` - Not а `str` type!")
|
59
|
+
if min_date is not None and not isinstance(min_date, datetime):
|
60
|
+
raise AssertionError("Parameter `min_date` - Not а `str` type!")
|
61
61
|
if max_date is not None and min_date is not None and max_date <= min_date:
|
62
62
|
raise AssertionError("The `max_date` parameter should be more than the `min_date`!")
|
63
63
|
if default is not None:
|
ramifice/fields/email_field.py
CHANGED
ramifice/fields/file_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for upload file."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("FileField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -7,7 +9,7 @@ import uuid
|
|
7
9
|
from base64 import b64decode
|
8
10
|
from datetime import datetime
|
9
11
|
from os import makedirs
|
10
|
-
from os.path import
|
12
|
+
from os.path import exists, getsize
|
11
13
|
from shutil import copyfile
|
12
14
|
|
13
15
|
from anyio import Path, open_file, to_thread
|
@@ -211,7 +213,7 @@ class FileField(Field, FileGroup, JsonMixin):
|
|
211
213
|
file_info["path"] = f_target_path
|
212
214
|
file_info["url"] = f"{MEDIA_URL}/uploads/{self.target_dir}/{date_str}/{f_uuid_name}"
|
213
215
|
# Add original file name.
|
214
|
-
file_info["name"] =
|
216
|
+
file_info["name"] = Path(src_path).name
|
215
217
|
# Add file extension.
|
216
218
|
file_info["extension"] = extension
|
217
219
|
# Add file size (in bytes).
|
ramifice/fields/float_field.py
CHANGED
ramifice/fields/general/field.py
CHANGED
ramifice/fields/id_field.py
CHANGED
ramifice/fields/image_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for upload image."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("ImageField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -7,7 +9,7 @@ import uuid
|
|
7
9
|
from base64 import b64decode
|
8
10
|
from datetime import datetime
|
9
11
|
from os import makedirs
|
10
|
-
from os.path import
|
12
|
+
from os.path import exists, getsize
|
11
13
|
from shutil import copyfile
|
12
14
|
|
13
15
|
from anyio import Path, open_file, to_thread
|
@@ -77,7 +79,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
77
79
|
raise AssertionError("The `thumbnails` parameter should not contain an empty dictionary!")
|
78
80
|
size_name_list = ["lg", "md", "sm", "xs"]
|
79
81
|
curr_size_thumb: int = 0
|
80
|
-
for size_name in thumbnails
|
82
|
+
for size_name in thumbnails:
|
81
83
|
if size_name not in size_name_list:
|
82
84
|
raise AssertionError(
|
83
85
|
f"The `thumbnails` parameter contains an unacceptable size name `{size_name}`!\n"
|
@@ -256,7 +258,7 @@ class ImageField(Field, FileGroup, JsonMixin):
|
|
256
258
|
img_info["path"] = main_img_path
|
257
259
|
img_info["url"] = f"{imgs_dir_url}/{new_original_name}"
|
258
260
|
# Add original image name.
|
259
|
-
img_info["name"] =
|
261
|
+
img_info["name"] = Path(src_path).name
|
260
262
|
# Add image extension.
|
261
263
|
img_info["extension"] = extension
|
262
264
|
# Transform extension to the upper register and delete the point.
|
ramifice/fields/integer_field.py
CHANGED
ramifice/fields/ip_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for enter password."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("PasswordField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -17,9 +19,9 @@ class PasswordField(Field):
|
|
17
19
|
r"""Field of Model for enter password.
|
18
20
|
|
19
21
|
Attention:
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
- `Regular expression:` ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
|
23
|
+
- `Valid characters:` a-z A-Z 0-9 - . _ ! " ` ' # % & , : ; < > = @ { } ~ $ ( ) * + / \\ ? [ ] ^ |
|
24
|
+
- `Number of characters:` from 8 to 256.
|
23
25
|
|
24
26
|
Agrs:
|
25
27
|
label: Text label for a web form field.
|
ramifice/fields/phone_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for enter phone number."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("PhoneField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -18,7 +20,7 @@ class PhoneField(Field, TextGroup, JsonMixin):
|
|
18
20
|
"""Field of Model for enter phone number.
|
19
21
|
|
20
22
|
Attention:
|
21
|
-
|
23
|
+
By default is used validator `phonenumbers.is_valid_number()`.
|
22
24
|
|
23
25
|
Agrs:
|
24
26
|
label: Text label for a web form field.
|
ramifice/fields/slug_field.py
CHANGED
ramifice/fields/text_field.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Field of Model for enter text."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("TextField",)
|
4
6
|
|
5
7
|
import logging
|
@@ -117,7 +119,7 @@ class TextField(Field, JsonMixin):
|
|
117
119
|
value = self.value
|
118
120
|
if isinstance(value, str):
|
119
121
|
return len(value)
|
120
|
-
|
122
|
+
if isinstance(value, dict):
|
121
123
|
count = 0
|
122
124
|
for text in value.values():
|
123
125
|
tmp = len(text)
|
ramifice/fields/url_field.py
CHANGED
ramifice/models/decorator.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
"""Decorator for converting Python classes into Ramifice models."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("model",)
|
4
6
|
|
5
7
|
import logging
|
6
8
|
import re
|
7
|
-
from
|
9
|
+
from pathlib import Path
|
8
10
|
from typing import Any
|
9
11
|
|
10
12
|
from ramifice.commons import QCommonsMixin
|
@@ -58,7 +60,7 @@ def model(
|
|
58
60
|
if fixture_name is not None:
|
59
61
|
fixture_path = f"config/fixtures/{fixture_name}.yml"
|
60
62
|
|
61
|
-
if not
|
63
|
+
if not Path(fixture_path).exists():
|
62
64
|
msg = (
|
63
65
|
f"Model: `{cls.__module__}.{cls.__name__}` > "
|
64
66
|
+ "META param: `fixture_name` => "
|
ramifice/models/model.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"""Converting Python classes into Ramifice Models."""
|
2
2
|
|
3
|
+
from __future__ import annotations
|
4
|
+
|
3
5
|
__all__ = ("Model",)
|
4
6
|
|
5
7
|
from abc import abstractmethod
|
@@ -56,7 +58,6 @@ class Model:
|
|
56
58
|
@abstractmethod
|
57
59
|
def fields(self) -> None:
|
58
60
|
"""Adding fields."""
|
59
|
-
pass
|
60
61
|
|
61
62
|
def model_name(self) -> str:
|
62
63
|
"""Get Model name - Class name."""
|
ramifice/paladins/__init__.py
CHANGED
ramifice/paladins/add_valid.py
CHANGED
ramifice/paladins/check.py
CHANGED
ramifice/paladins/delete.py
CHANGED