ramifice 0.3.16__py3-none-any.whl → 0.3.18__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.
Files changed (34) hide show
  1. ramifice/fields/bool_field.py +2 -2
  2. ramifice/fields/choice_float_dyn_field.py +2 -2
  3. ramifice/fields/choice_float_field.py +2 -2
  4. ramifice/fields/choice_float_mult_dyn_field.py +2 -2
  5. ramifice/fields/choice_float_mult_field.py +2 -2
  6. ramifice/fields/choice_int_dyn_field.py +2 -2
  7. ramifice/fields/choice_int_field.py +2 -2
  8. ramifice/fields/choice_int_mult_dyn_field.py +2 -2
  9. ramifice/fields/choice_int_mult_field.py +2 -2
  10. ramifice/fields/choice_text_dyn_field.py +2 -2
  11. ramifice/fields/choice_text_field.py +2 -2
  12. ramifice/fields/choice_text_mult_dyn_field.py +2 -2
  13. ramifice/fields/choice_text_mult_field.py +2 -2
  14. ramifice/fields/color_field.py +6 -7
  15. ramifice/fields/date_field.py +2 -3
  16. ramifice/fields/date_time_field.py +2 -3
  17. ramifice/fields/email_field.py +4 -5
  18. ramifice/fields/file_field.py +4 -4
  19. ramifice/fields/float_field.py +2 -2
  20. ramifice/fields/id_field.py +2 -2
  21. ramifice/fields/image_field.py +16 -12
  22. ramifice/fields/integer_field.py +2 -2
  23. ramifice/fields/ip_field.py +4 -5
  24. ramifice/fields/password_field.py +5 -6
  25. ramifice/fields/phone_field.py +5 -6
  26. ramifice/fields/slug_field.py +2 -2
  27. ramifice/fields/text_field.py +2 -2
  28. ramifice/fields/url_field.py +4 -5
  29. ramifice/paladins/groups/img_group.py +3 -0
  30. ramifice/utilities.py +11 -16
  31. {ramifice-0.3.16.dist-info → ramifice-0.3.18.dist-info}/METADATA +3 -3
  32. {ramifice-0.3.16.dist-info → ramifice-0.3.18.dist-info}/RECORD +34 -34
  33. {ramifice-0.3.16.dist-info → ramifice-0.3.18.dist-info}/WHEEL +0 -0
  34. {ramifice-0.3.16.dist-info → ramifice-0.3.18.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,7 @@
1
1
  """Field of Model for enter boolean value."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG
5
5
  from .general.field import Field
6
6
 
7
7
 
@@ -18,7 +18,7 @@ class BooleanField(Field, JsonMixin):
18
18
  warning: list[str] | None = None,
19
19
  default: bool = False,
20
20
  ):
21
- if DEBUG:
21
+ if store.DEBUG:
22
22
  if default is not None and not isinstance(default, bool):
23
23
  raise AssertionError("Parameter `default` - Not а `bool` type!")
24
24
  if not isinstance(label, str):
@@ -3,8 +3,8 @@
3
3
  Type of selective float field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -28,7 +28,7 @@ class ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
28
28
  required: bool = False,
29
29
  readonly: bool = False,
30
30
  ):
31
- if DEBUG:
31
+ if store.DEBUG:
32
32
  if not isinstance(label, str):
33
33
  raise AssertionError("Parameter `default` - Not а `str` type!")
34
34
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective float field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -51,7 +51,7 @@ class ChoiceFloatField(Field, ChoiceGroup, JsonMixin):
51
51
  self.default = default
52
52
  self.choices = choices
53
53
 
54
- if DEBUG:
54
+ if store.DEBUG:
55
55
  if choices is not None and not isinstance(choices, dict):
56
56
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
57
57
  if default is not None and not isinstance(default, float):
@@ -3,8 +3,8 @@
3
3
  Type of selective float field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -27,7 +27,7 @@ class ChoiceFloatMultDynField(Field, ChoiceGroup, JsonMixin):
27
27
  required: bool = False,
28
28
  readonly: bool = False,
29
29
  ):
30
- if DEBUG:
30
+ if store.DEBUG:
31
31
  if not isinstance(label, str):
32
32
  raise AssertionError("Parameter `default` - Not а `str` type!")
33
33
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective float field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -52,7 +52,7 @@ class ChoiceFloatMultField(Field, ChoiceGroup, JsonMixin):
52
52
  self.default = default
53
53
  self.choices = choices
54
54
 
55
- if DEBUG:
55
+ if store.DEBUG:
56
56
  if choices is not None:
57
57
  if not isinstance(choices, dict):
58
58
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
@@ -3,8 +3,8 @@
3
3
  Type of selective integer field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -28,7 +28,7 @@ class ChoiceIntDynField(Field, ChoiceGroup, JsonMixin):
28
28
  required: bool = False,
29
29
  readonly: bool = False,
30
30
  ):
31
- if DEBUG:
31
+ if store.DEBUG:
32
32
  if not isinstance(label, str):
33
33
  raise AssertionError("Parameter `default` - Not а `str` type!")
34
34
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective integer field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -51,7 +51,7 @@ class ChoiceIntField(Field, ChoiceGroup, JsonMixin):
51
51
  self.default = default
52
52
  self.choices = choices
53
53
 
54
- if DEBUG:
54
+ if store.DEBUG:
55
55
  if choices is not None and not isinstance(choices, dict):
56
56
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
57
57
  if default is not None and not isinstance(default, int):
@@ -3,8 +3,8 @@
3
3
  Type of selective integer field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -27,7 +27,7 @@ class ChoiceIntMultDynField(Field, ChoiceGroup, JsonMixin):
27
27
  required: bool = False,
28
28
  readonly: bool = False,
29
29
  ):
30
- if DEBUG:
30
+ if store.DEBUG:
31
31
  if not isinstance(label, str):
32
32
  raise AssertionError("Parameter `default` - Not а `str` type!")
33
33
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective integer field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -52,7 +52,7 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
52
52
  self.default = default
53
53
  self.choices = choices
54
54
 
55
- if DEBUG:
55
+ if store.DEBUG:
56
56
  if choices is not None:
57
57
  if not isinstance(choices, dict):
58
58
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
@@ -3,8 +3,8 @@
3
3
  Type of selective text field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -28,7 +28,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
28
28
  required: bool = False,
29
29
  readonly: bool = False,
30
30
  ):
31
- if DEBUG:
31
+ if store.DEBUG:
32
32
  if not isinstance(label, str):
33
33
  raise AssertionError("Parameter `default` - Not а `str` type!")
34
34
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective text field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -51,7 +51,7 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
51
51
  self.default = default
52
52
  self.choices = choices
53
53
 
54
- if DEBUG:
54
+ if store.DEBUG:
55
55
  if choices is not None and not isinstance(choices, dict):
56
56
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
57
57
  if default is not None:
@@ -3,8 +3,8 @@
3
3
  Type of selective text field with dynamic addition of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -27,7 +27,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
27
27
  required: bool = False,
28
28
  readonly: bool = False,
29
29
  ):
30
- if DEBUG:
30
+ if store.DEBUG:
31
31
  if not isinstance(label, str):
32
32
  raise AssertionError("Parameter `default` - Not а `str` type!")
33
33
  if not isinstance(disabled, bool):
@@ -3,8 +3,8 @@
3
3
  Type of selective text field with static of elements.
4
4
  """
5
5
 
6
+ from .. import store
6
7
  from ..mixins import JsonMixin
7
- from ..store import DEBUG
8
8
  from .general.choice_group import ChoiceGroup
9
9
  from .general.field import Field
10
10
 
@@ -52,7 +52,7 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
52
52
  self.default = default
53
53
  self.choices = choices
54
54
 
55
- if DEBUG:
55
+ if store.DEBUG:
56
56
  if choices is not None:
57
57
  if not isinstance(choices, dict):
58
58
  raise AssertionError("Parameter `choices` - Not а `dict` type!")
@@ -1,7 +1,7 @@
1
1
  """Field of Model for enter color code."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG, REGEX
5
5
  from .general.field import Field
6
6
  from .general.text_group import TextGroup
7
7
 
@@ -31,7 +31,7 @@ class ColorField(Field, TextGroup, JsonMixin):
31
31
  readonly: bool = False,
32
32
  unique: bool = False,
33
33
  ):
34
- if DEBUG:
34
+ if store.DEBUG:
35
35
  if default is not None:
36
36
  if not isinstance(default, str):
37
37
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -39,7 +39,7 @@ class ColorField(Field, TextGroup, JsonMixin):
39
39
  raise AssertionError(
40
40
  "The `default` parameter should not contain an empty string!"
41
41
  )
42
- if REGEX["color_code"].match(default) is None:
42
+ if store.REGEX["color_code"].match(default) is None:
43
43
  raise AssertionError("Parameter `default` - Not а color code!")
44
44
  if not isinstance(label, str):
45
45
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -89,8 +89,7 @@ class ColorField(Field, TextGroup, JsonMixin):
89
89
 
90
90
  def is_valid(self, value: str | None = None) -> bool:
91
91
  """Validate Color code."""
92
- flag = True
93
92
  color_code = str(value or self.value or self.default)
94
- if REGEX["color_code"].match(color_code) is None:
95
- flag = False
96
- return flag
93
+ if store.REGEX["color_code"].match(color_code) is None:
94
+ return False
95
+ return True
@@ -7,8 +7,7 @@ from typing import Any
7
7
  from babel.dates import format_date
8
8
  from dateutil.parser import parse
9
9
 
10
- from .. import translations
11
- from ..store import DEBUG
10
+ from .. import store, translations
12
11
  from .general.date_group import DateGroup
13
12
  from .general.field import Field
14
13
 
@@ -31,7 +30,7 @@ class DateField(Field, DateGroup):
31
30
  max_date: datetime | None = None,
32
31
  min_date: datetime | None = None,
33
32
  ):
34
- if DEBUG:
33
+ if store.DEBUG:
35
34
  if max_date is not None:
36
35
  if not isinstance(max_date, datetime):
37
36
  raise AssertionError("Parameter `max_date` - Not а `str` type!")
@@ -7,8 +7,7 @@ from typing import Any
7
7
  from babel.dates import format_datetime
8
8
  from dateutil.parser import parse
9
9
 
10
- from .. import translations
11
- from ..store import DEBUG
10
+ from .. import store, translations
12
11
  from .general.date_group import DateGroup
13
12
  from .general.field import Field
14
13
 
@@ -31,7 +30,7 @@ class DateTimeField(Field, DateGroup):
31
30
  max_date: datetime | None = None,
32
31
  min_date: datetime | None = None,
33
32
  ):
34
- if DEBUG:
33
+ if store.DEBUG:
35
34
  if max_date is not None:
36
35
  if not isinstance(max_date, datetime):
37
36
  raise AssertionError("Parameter `max_date` - Not а `str` type!")
@@ -2,8 +2,8 @@
2
2
 
3
3
  from email_validator import EmailNotValidError, validate_email
4
4
 
5
+ from .. import store
5
6
  from ..mixins import JsonMixin
6
- from ..store import DEBUG
7
7
  from .general.field import Field
8
8
  from .general.text_group import TextGroup
9
9
 
@@ -25,7 +25,7 @@ class EmailField(Field, TextGroup, JsonMixin):
25
25
  readonly: bool = False,
26
26
  unique: bool = False,
27
27
  ):
28
- if DEBUG:
28
+ if store.DEBUG:
29
29
  if default is not None:
30
30
  if not isinstance(default, str):
31
31
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -86,9 +86,8 @@ class EmailField(Field, TextGroup, JsonMixin):
86
86
  def is_valid(self, value: str | None = None) -> bool:
87
87
  """Validate Email address."""
88
88
  email = str(value or self.value or self.default)
89
- flag = True
90
89
  try:
91
90
  validate_email(email, check_deliverability=True)
92
91
  except EmailNotValidError:
93
- flag = False
94
- return flag
92
+ return False
93
+ return True
@@ -8,9 +8,9 @@ from datetime import datetime
8
8
  from pathlib import Path
9
9
  from typing import Any
10
10
 
11
+ from .. import store
11
12
  from ..errors import FileHasNoExtensionError
12
13
  from ..mixins import JsonMixin
13
- from ..store import DEBUG, FILE_INFO_DICT
14
14
  from .general.field import Field
15
15
  from .general.file_group import FileGroup
16
16
 
@@ -34,7 +34,7 @@ class FileField(Field, FileGroup, JsonMixin):
34
34
  target_dir: str = "files",
35
35
  accept: str = "",
36
36
  ):
37
- if DEBUG:
37
+ if store.DEBUG:
38
38
  if default is not None:
39
39
  if not isinstance(default, str):
40
40
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -102,7 +102,7 @@ class FileField(Field, FileGroup, JsonMixin):
102
102
  """ # noqa: D205
103
103
  base64_str = base64_str or None
104
104
  filename = filename or None
105
- file_info = FILE_INFO_DICT.copy()
105
+ file_info = store.FILE_INFO_DICT.copy()
106
106
  file_info["is_new_file"] = True
107
107
  file_info["is_delete"] = is_delete
108
108
 
@@ -154,7 +154,7 @@ class FileField(Field, FileGroup, JsonMixin):
154
154
  ) -> None:
155
155
  """Get file information and copy the file to the target directory."""
156
156
  src_path = src_path or None
157
- file_info = FILE_INFO_DICT.copy()
157
+ file_info = store.FILE_INFO_DICT.copy()
158
158
  file_info["is_new_file"] = True
159
159
  file_info["is_delete"] = is_delete
160
160
 
@@ -1,7 +1,7 @@
1
1
  """Field of Model for enter (float) number."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG
5
5
  from .general.field import Field
6
6
  from .general.number_group import NumberGroup
7
7
 
@@ -27,7 +27,7 @@ class FloatField(Field, NumberGroup, JsonMixin):
27
27
  step: float = 1.0,
28
28
  input_type: str = "number", # number | range
29
29
  ):
30
- if DEBUG:
30
+ if store.DEBUG:
31
31
  if input_type not in ["number", "range"]:
32
32
  raise AssertionError(
33
33
  "Parameter `input_type` - Invalid input type! "
@@ -5,7 +5,7 @@ from typing import Any
5
5
 
6
6
  from bson.objectid import ObjectId
7
7
 
8
- from ..store import DEBUG
8
+ from .. import store
9
9
  from .general.field import Field
10
10
 
11
11
 
@@ -33,7 +33,7 @@ class IDField(Field):
33
33
  readonly: bool = False,
34
34
  unique: bool = False,
35
35
  ):
36
- if DEBUG:
36
+ if store.DEBUG:
37
37
  if not isinstance(label, str):
38
38
  raise AssertionError("Parameter `default` - Not а `str` type!")
39
39
  if not isinstance(disabled, bool):
@@ -10,9 +10,9 @@ from typing import Any
10
10
 
11
11
  from PIL import Image
12
12
 
13
+ from .. import store
13
14
  from ..errors import FileHasNoExtensionError
14
15
  from ..mixins import JsonMixin
15
- from ..store import DEBUG, IMG_INFO_DICT
16
16
  from .general.field import Field
17
17
  from .general.file_group import FileGroup
18
18
 
@@ -41,7 +41,7 @@ class ImageField(Field, FileGroup, JsonMixin):
41
41
  # True - high quality and low performance for thumbnails.
42
42
  high_quality: bool = False,
43
43
  ):
44
- if DEBUG:
44
+ if store.DEBUG:
45
45
  if default is not None:
46
46
  if not isinstance(default, str):
47
47
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -135,13 +135,14 @@ class ImageField(Field, FileGroup, JsonMixin):
135
135
  base64_str: str | None = None,
136
136
  filename: str | None = None,
137
137
  is_delete: bool = False,
138
+ add_wh: bool = False,
138
139
  ) -> None:
139
140
  """Convert base64 to a image,
140
141
  get image information and save in the target directory.
141
142
  """ # noqa: D205
142
143
  base64_str = base64_str or None
143
144
  filename = filename or None
144
- img_info = IMG_INFO_DICT.copy()
145
+ img_info = store.IMG_INFO_DICT.copy()
145
146
  img_info["is_new_img"] = True
146
147
  img_info["is_delete"] = is_delete
147
148
 
@@ -180,10 +181,11 @@ class ImageField(Field, FileGroup, JsonMixin):
180
181
  img_info["path"] = main_img_path
181
182
  img_info["url"] = f"{imgs_dir_url}/{new_original_name}"
182
183
  # Add width and height.
183
- with Image.open(main_img_path) as img:
184
- width, height = img.size
185
- img_info["width"] = width
186
- img_info["height"] = height
184
+ if add_wh:
185
+ with Image.open(main_img_path) as img:
186
+ width, height = img.size
187
+ img_info["width"] = width
188
+ img_info["height"] = height
187
189
  # Add original image name.
188
190
  img_info["name"] = filename
189
191
  # Add image extension.
@@ -208,10 +210,11 @@ class ImageField(Field, FileGroup, JsonMixin):
208
210
  self,
209
211
  src_path: str | None = None,
210
212
  is_delete: bool = False,
213
+ add_wh: bool = False,
211
214
  ) -> None:
212
215
  """Get image information and copy the image to the target directory."""
213
216
  src_path = src_path or None
214
- img_info = IMG_INFO_DICT.copy()
217
+ img_info = store.IMG_INFO_DICT.copy()
215
218
  img_info["is_new_img"] = True
216
219
  img_info["is_delete"] = is_delete
217
220
 
@@ -242,10 +245,11 @@ class ImageField(Field, FileGroup, JsonMixin):
242
245
  img_info["path"] = main_img_path
243
246
  img_info["url"] = f"{imgs_dir_url}/{new_original_name}"
244
247
  # Add width and height.
245
- with Image.open(main_img_path) as img:
246
- width, height = img.size
247
- img_info["width"] = width
248
- img_info["height"] = height
248
+ if add_wh:
249
+ with Image.open(main_img_path) as img:
250
+ width, height = img.size
251
+ img_info["width"] = width
252
+ img_info["height"] = height
249
253
  # Add original image name.
250
254
  img_info["name"] = os.path.basename(src_path)
251
255
  # Add image extension.
@@ -1,7 +1,7 @@
1
1
  """Field of Model for enter (int) number."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG
5
5
  from .general.field import Field
6
6
  from .general.number_group import NumberGroup
7
7
 
@@ -27,7 +27,7 @@ class IntegerField(Field, NumberGroup, JsonMixin):
27
27
  step: int = 1,
28
28
  input_type: str = "number", # number | range
29
29
  ):
30
- if DEBUG:
30
+ if store.DEBUG:
31
31
  if input_type not in ["number", "range"]:
32
32
  raise AssertionError(
33
33
  "Parameter `input_type` - Invalid input type! "
@@ -2,8 +2,8 @@
2
2
 
3
3
  import ipaddress
4
4
 
5
+ from .. import store
5
6
  from ..mixins import JsonMixin
6
- from ..store import DEBUG
7
7
  from .general.field import Field
8
8
  from .general.text_group import TextGroup
9
9
 
@@ -25,7 +25,7 @@ class IPField(Field, TextGroup, JsonMixin):
25
25
  readonly: bool = False,
26
26
  unique: bool = False,
27
27
  ):
28
- if DEBUG:
28
+ if store.DEBUG:
29
29
  if default is not None:
30
30
  if not isinstance(default, str):
31
31
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -85,10 +85,9 @@ class IPField(Field, TextGroup, JsonMixin):
85
85
 
86
86
  def is_valid(self, value: str | None = None) -> bool:
87
87
  """Validate IP address."""
88
- flag = True
89
88
  address = str(value or self.value or self.default)
90
89
  try:
91
90
  ipaddress.ip_address(address)
92
91
  except ValueError:
93
- flag = False
94
- return flag
92
+ return False
93
+ return True
@@ -3,7 +3,7 @@
3
3
  import json
4
4
  from typing import Any
5
5
 
6
- from ..store import DEBUG, REGEX
6
+ from .. import store
7
7
  from .general.field import Field
8
8
 
9
9
 
@@ -26,7 +26,7 @@ class PasswordField(Field):
26
26
  placeholder: str = "",
27
27
  required: bool = False,
28
28
  ):
29
- if DEBUG:
29
+ if store.DEBUG:
30
30
  if not isinstance(label, str):
31
31
  raise AssertionError("Parameter `default` - Not а `str` type!")
32
32
  if not isinstance(hide, bool):
@@ -63,11 +63,10 @@ class PasswordField(Field):
63
63
 
64
64
  def is_valid(self, value: str | None = None) -> bool:
65
65
  """Validate Password."""
66
- flag = True
67
66
  password = str(value or self.value)
68
- if not REGEX["password"].match(password):
69
- flag = False
70
- return flag
67
+ if not store.REGEX["password"].match(password):
68
+ return False
69
+ return True
71
70
 
72
71
  def to_dict(self) -> dict[str, Any]:
73
72
  """Convert object instance to a dictionary."""
@@ -2,8 +2,8 @@
2
2
 
3
3
  import phonenumbers
4
4
 
5
+ from .. import store
5
6
  from ..mixins import JsonMixin
6
- from ..store import DEBUG
7
7
  from .general.field import Field
8
8
  from .general.text_group import TextGroup
9
9
 
@@ -28,7 +28,7 @@ class PhoneField(Field, TextGroup, JsonMixin):
28
28
  readonly: bool = False,
29
29
  unique: bool = False,
30
30
  ):
31
- if DEBUG:
31
+ if store.DEBUG:
32
32
  if default is not None:
33
33
  if not isinstance(default, str):
34
34
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -90,12 +90,11 @@ class PhoneField(Field, TextGroup, JsonMixin):
90
90
 
91
91
  def is_valid(self, value: str | None = None) -> bool:
92
92
  """Validate Phone number."""
93
- flag = True
94
93
  number = str(value or self.value or self.default)
95
94
  try:
96
95
  phone = phonenumbers.parse(number)
97
96
  if not phonenumbers.is_valid_number(phone):
98
- flag = False
97
+ return False
99
98
  except phonenumbers.phonenumberutil.NumberParseException:
100
- flag = False
101
- return flag
99
+ return False
100
+ return True
@@ -1,7 +1,7 @@
1
1
  """Field of Model for automatic generation of string `slug`."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG
5
5
  from .general.field import Field
6
6
  from .general.text_group import TextGroup
7
7
 
@@ -24,7 +24,7 @@ class SlugField(Field, TextGroup, JsonMixin):
24
24
  readonly: bool = False,
25
25
  slug_sources: list[str] = ["_id"],
26
26
  ):
27
- if DEBUG:
27
+ if store.DEBUG:
28
28
  if not isinstance(label, str):
29
29
  raise AssertionError("Parameter `default` - Not а `str` type!")
30
30
  if not isinstance(disabled, bool):
@@ -1,7 +1,7 @@
1
1
  """Field of Model for enter text."""
2
2
 
3
+ from .. import store
3
4
  from ..mixins import JsonMixin
4
- from ..store import DEBUG
5
5
  from .general.field import Field
6
6
  from .general.text_group import TextGroup
7
7
 
@@ -26,7 +26,7 @@ class TextField(Field, TextGroup, JsonMixin):
26
26
  unique: bool = False,
27
27
  maxlength: int = 256,
28
28
  ):
29
- if DEBUG:
29
+ if store.DEBUG:
30
30
  if not isinstance(maxlength, int):
31
31
  raise AssertionError("Parameter `maxlength` - Not а `int` type!")
32
32
  if default is not None:
@@ -2,8 +2,8 @@
2
2
 
3
3
  from urllib.parse import urlparse
4
4
 
5
+ from .. import store
5
6
  from ..mixins import JsonMixin
6
- from ..store import DEBUG
7
7
  from .general.field import Field
8
8
  from .general.text_group import TextGroup
9
9
 
@@ -39,7 +39,7 @@ class URLField(Field, TextGroup, JsonMixin):
39
39
  readonly: bool = False,
40
40
  unique: bool = False,
41
41
  ):
42
- if DEBUG:
42
+ if store.DEBUG:
43
43
  if default is not None:
44
44
  if not isinstance(default, str):
45
45
  raise AssertionError("Parameter `default` - Not а `str` type!")
@@ -98,9 +98,8 @@ class URLField(Field, TextGroup, JsonMixin):
98
98
 
99
99
  def is_valid(self, value: str | None = None) -> bool:
100
100
  """Validate URL address."""
101
- flag = True
102
101
  url = str(value or self.value or self.default)
103
102
  result = urlparse(url)
104
103
  if not result.scheme or not result.netloc:
105
- flag = False
106
- return flag
104
+ return False
105
+ return True
@@ -87,6 +87,9 @@ class ImgGroupMixin:
87
87
  ext_upper = value["ext_upper"]
88
88
  # Get image file.
89
89
  with Image.open(path) as img:
90
+ width, height = img.size
91
+ value["width"] = width
92
+ value["height"] = height
90
93
  resample = (
91
94
  Image.Resampling.LANCZOS # High quality and low performance.
92
95
  if params["field_data"].high_quality
ramifice/utilities.py CHANGED
@@ -40,51 +40,46 @@ def normal_email(email: str) -> str | None:
40
40
 
41
41
  def is_email(email: str) -> bool:
42
42
  """Validate Email address."""
43
- flag = True
44
43
  try:
45
44
  validate_email(str(email), check_deliverability=True)
46
45
  except EmailNotValidError:
47
- flag = False
48
- return flag
46
+ return False
47
+ return True
49
48
 
50
49
 
51
50
  def is_url(url: str) -> bool:
52
51
  """Validate URL address."""
53
- flag = True
54
52
  result = urlparse(str(url))
55
53
  if not result.scheme or not result.netloc:
56
- flag = False
57
- return flag
54
+ return False
55
+ return True
58
56
 
59
57
 
60
58
  def is_ip(address: str | int) -> bool:
61
59
  """Validate IP address."""
62
- flag = True
63
60
  try:
64
61
  ipaddress.ip_address(str(address))
65
62
  except ValueError:
66
- flag = False
67
- return flag
63
+ return False
64
+ return True
68
65
 
69
66
 
70
67
  def is_color(color_code: str) -> bool:
71
68
  """Validate Color code."""
72
- flag = True
73
69
  if REGEX["color_code"].match(str(color_code)) is None:
74
- flag = False
75
- return flag
70
+ return False
71
+ return True
76
72
 
77
73
 
78
74
  def is_phone(number: str) -> bool:
79
75
  """Validate Phone number."""
80
- flag = True
81
76
  try:
82
77
  phone = phonenumbers.parse(str(number))
83
78
  if not phonenumbers.is_valid_number(phone):
84
- flag = False
79
+ return False
85
80
  except phonenumbers.phonenumberutil.NumberParseException:
86
- flag = False
87
- return flag
81
+ return False
82
+ return True
88
83
 
89
84
 
90
85
  def is_mongo_id(oid: Any) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ramifice
3
- Version: 0.3.16
3
+ Version: 0.3.18
4
4
  Summary: ORM-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/
@@ -286,7 +286,7 @@ See the documentation [here](https://kebasyaty.github.io/ramifice/ "here").
286
286
  </tr>
287
287
  <tr>
288
288
  <td align="left">fixture_name</td>
289
- <td align="left">no</td>
289
+ <td align="left">None</td>
290
290
  <td align="left">
291
291
  The name of the fixture in the <b>config/fixtures</b> directory (without extension).
292
292
  <br>
@@ -463,7 +463,7 @@ unit = Unit(
463
463
  is_delete=False, # True - if you need to remove the item of choice.
464
464
  # by default = False (add item to choice)
465
465
  )
466
- User.unit_manager(unit)
466
+ await User.unit_manager(unit)
467
467
  ```
468
468
 
469
469
  ## Instance methods
@@ -12,7 +12,7 @@ ramifice/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  ramifice/store.py,sha256=Kqd2Zw7Wj2vnn_0eE6KmIOkWJRhDc6AZ0ZyqxENBetQ,2730
13
13
  ramifice/translations.py,sha256=GNGE0ULAA0aOY5pTxUd3MQW-nVaKvp6BeXWEcsR0s0o,4048
14
14
  ramifice/types.py,sha256=ljo6VscUGWEJ4Km4JYo8GEfxd1YK1CUbS8CfHp_MlEA,2390
15
- ramifice/utilities.py,sha256=cX-qnNsGhP3ltA7wnhm5V8K5_FUKq2LpD-c5YdOHLJM,2527
15
+ ramifice/utilities.py,sha256=c662nwFcWXSXNYfwqDnGlLWpA01KaK79GwTdApqtMh8,2442
16
16
  ramifice/commons/__init__.py,sha256=LHCsdpl4z8W-xUvAlOr1ad0ras9hspvCpuce4SAdfP0,472
17
17
  ramifice/commons/general.py,sha256=fTnIRA3IGbi0lMKBCgeqkI7BGJWTbZVu0nOJYoNRSRU,4571
18
18
  ramifice/commons/indexes.py,sha256=ABNRXeWZSreAE4_EDlsTN9aS8QiZbzhsatUJFn2EuOo,3849
@@ -21,34 +21,34 @@ ramifice/commons/one.py,sha256=XKWYYZn7SZ4At_yhjPSM1zXMoQzvt8wSM0F8kgWxhNU,5631
21
21
  ramifice/commons/tools.py,sha256=1oJHgb_WpWwoGtMcGQ-ta1oUMJLyN8QxuMbY83Sk36o,2220
22
22
  ramifice/commons/units.py,sha256=sYlRThKQPdBDJB3togJz8qyASpQ7gNZndbudUGDQEwE,4402
23
23
  ramifice/fields/__init__.py,sha256=yRfX7Tvpuh27Ggcx5u9e1RRYK7Wu59EVJYxxetmuP1w,1290
24
- ramifice/fields/bool_field.py,sha256=RUoHeU6L2wX5YfGyzsZBxg3OVlu3tP6eNhzWnHsU_G0,2041
25
- ramifice/fields/choice_float_dyn_field.py,sha256=GdHbfP3A6bpH5D_91m7K_SiqkzaYuafgeVeBWLyo8A0,2987
26
- ramifice/fields/choice_float_field.py,sha256=F7ubmvpb-8wEQ9fa3Z1gb7SYlyZ-4WWLiOFDpOnYYbY,3618
27
- ramifice/fields/choice_float_mult_dyn_field.py,sha256=AnwyfQQJIPtU-lPVMjlfl4pkFhMFwWhY0IfkKDrQu5c,3050
28
- ramifice/fields/choice_float_mult_field.py,sha256=ZGL3qk9xi9SsqnDVpjuuEAkT5PA4BuYHr0B-v7Arcsw,4175
29
- ramifice/fields/choice_int_dyn_field.py,sha256=D2o44g6IedRrnRgsIZmA4t1kodRj20gjyhXJLBasnZo,2981
30
- ramifice/fields/choice_int_field.py,sha256=87tC0gUO2swtbjF2E6PA8OR2p6RZi8bMAmoZE-G_kKI,3606
31
- ramifice/fields/choice_int_mult_dyn_field.py,sha256=WvEJfMU1jQTcJ8D0u57-Sp_ff_Q_ddHahtMZwtpGbSc,3046
32
- ramifice/fields/choice_int_mult_field.py,sha256=GqMPvSWDSzwZL2vSRGvLAZUwkvvppKgv_mB32TMEusU,4169
33
- ramifice/fields/choice_text_dyn_field.py,sha256=H81HyDfUKJ8usOkBZ_O_ZTCFNcRVgbQ6a9AY_k0ySYQ,2977
34
- ramifice/fields/choice_text_field.py,sha256=kSHFn-Y3ynuHx1pfY7KDIcy-R3kUDFUKwCUNRD4dSXo,3811
35
- ramifice/fields/choice_text_mult_dyn_field.py,sha256=TpcgwZGDr7oRGTbfgbSfyp-Hvpj-2tBD7jg3rVAwxq8,3042
36
- ramifice/fields/choice_text_mult_field.py,sha256=MaWXyGTfJ-TEmrHvt_r_tbYfRDmJPMpKL-fMaHkk4DQ,4165
37
- ramifice/fields/color_field.py,sha256=qotqccFHp0rn9jwbwbXwlb3gHD63Am1nmFfKTg2haQo,3781
38
- ramifice/fields/date_field.py,sha256=IvNs4tg02I7O7auO3PQxE3iRvqGdn3DDnK2TA509FWU,5219
39
- ramifice/fields/date_time_field.py,sha256=7T3QtWZ-859BOwBa0Y6O4NfSXuA4fJKE-4wes98tAKE,5254
40
- ramifice/fields/email_field.py,sha256=EgQc9sBL323zxzzmU4pXCWPjD45_dU_QQABwOSRwkjM,3740
41
- ramifice/fields/file_field.py,sha256=JGay_W-Z9JDgpCZVuvhl3ckm2y8cUqg_KL-KQIkpAlg,7943
42
- ramifice/fields/float_field.py,sha256=Gq3w2zjn3Gy_IJev9aeb-Mh3uo67iNJhYlDdPZ6zJ4Q,4554
43
- ramifice/fields/id_field.py,sha256=fE4hkmBgugbr41l2_lo-1CRqpviS3WrQEALoERlDcEE,4125
44
- ramifice/fields/image_field.py,sha256=2XvBne-UWmCRto-icSR_QOAwyiPAsSKb5KzUXUDl6yU,12161
45
- ramifice/fields/integer_field.py,sha256=phSAaDG-jHUEdegbMtJXfFxAGiw4Tbs0DtLF8K5jVoM,4530
46
- ramifice/fields/ip_field.py,sha256=X9VMHscdlGmaYAWd_BWItvS7KdJoI1GOiEiWpmjwpWg,3621
47
- ramifice/fields/password_field.py,sha256=Bu9Vod1YY5pyvMFxnKcOhBq2-qmHDGzr0jH0-Qqea1o,3472
48
- ramifice/fields/phone_field.py,sha256=fxh-3-6PCpB9tfsp5bEsPdib8au_ysYYWUOIgFSaO34,4026
49
- ramifice/fields/slug_field.py,sha256=Sw5Oh_6GrOhM7JaIX8lB3tFUAN4VsdxX-6Ksuw8QSHE,2654
50
- ramifice/fields/text_field.py,sha256=tgp2-gSzcRKDiITOR7PlCGlYWyF_oscxpW8NeUTd-BM,3970
51
- ramifice/fields/url_field.py,sha256=WYtLoNg2qFOtCgBdWPeMt3Kvq9ySEsNn6oEAKk8b9LA,4268
24
+ ramifice/fields/bool_field.py,sha256=Jvzm6Kvepkr3myE1zBMV3bhVyVWI4nTaRV4d6LVmDYY,2042
25
+ ramifice/fields/choice_float_dyn_field.py,sha256=advKW92aetPjv_QMdouGygrPoMYLsA4ED36MpTlOt-4,2988
26
+ ramifice/fields/choice_float_field.py,sha256=shvUvb952qjvWW4Ta1uKwEu0eCulABkPR5KUfYxx0wg,3619
27
+ ramifice/fields/choice_float_mult_dyn_field.py,sha256=zCREf9neu1uJ9a2IA22QXE92K41rypX_XBDpcTzCVrI,3051
28
+ ramifice/fields/choice_float_mult_field.py,sha256=7si2Uf_nyMUCkfjg6tZf-EjlCCG_6hBXGbEr6dEz-PU,4176
29
+ ramifice/fields/choice_int_dyn_field.py,sha256=gwo64SipoJzJ9EY4vK4VKigABfBFDT55Ya-Xt0M3wEw,2982
30
+ ramifice/fields/choice_int_field.py,sha256=M4t9clnkQ_m8G7x6IhBetW3mjyjL1jVYAdndvFPOvMo,3607
31
+ ramifice/fields/choice_int_mult_dyn_field.py,sha256=JVjo5l-rqd_MVibU2Cwjs0-u2zNIjCU7ai8EIf7brko,3047
32
+ ramifice/fields/choice_int_mult_field.py,sha256=W1NNpP8yxeEtl6gHPtcguOtRM9OXH9XDDq9Y5V2xb4Q,4170
33
+ ramifice/fields/choice_text_dyn_field.py,sha256=FyXeaTOfg3YfpgZ5TjXGGvFe2LasmbsMV9dK5kXtF3c,2978
34
+ ramifice/fields/choice_text_field.py,sha256=oy_yB_0cuWNM2CWZAC9ZMzkMtkyb7ViCvB3YcWJG41Y,3812
35
+ ramifice/fields/choice_text_mult_dyn_field.py,sha256=L-pmeIMa8Vh8O6G7f1TnmEI26dlyHbSOc2fPKN6tJoU,3043
36
+ ramifice/fields/choice_text_mult_field.py,sha256=1R1z7hzmdhhlEBoltxL67KwrId6WEapEuCxMI-O46_Q,4166
37
+ ramifice/fields/color_field.py,sha256=sjVSoJU6TIZ66wzPx0WRl5zQsx-kINMMuxa_pSUpW6M,3766
38
+ ramifice/fields/date_field.py,sha256=Vlaxgp3WeDNMwbnQcTGu8kyQ7gc7M-7sFBPfzu-4MVw,5205
39
+ ramifice/fields/date_time_field.py,sha256=VpLeYJHs0df45fz4gnprtn7aipVFKGY4n02eRep7in0,5240
40
+ ramifice/fields/email_field.py,sha256=wOM07nQ5fOSOTydQhg3b4dV_95F1bd97peQ_XAnV0MY,3720
41
+ ramifice/fields/file_field.py,sha256=-1oxKg8Bs6lqNB2wIEldGBck5YwwgoDtCks2z1vHnww,7940
42
+ ramifice/fields/float_field.py,sha256=4l7gzg46qQ7ZbXS6Z8GUhiUBR26rXChvO_uFx-lbUds,4555
43
+ ramifice/fields/id_field.py,sha256=5wlY2j051TB2GPsw0iQkFiQBV_Y_o1W_QnCtBlaDuYQ,4126
44
+ ramifice/fields/image_field.py,sha256=EX7J-qon60_FJDE3_pnink6pa5vTRGspj8v_Rk8JEt4,12301
45
+ ramifice/fields/integer_field.py,sha256=Gnm5IBSvWtCLGbg5pOSAdKa5xLzqXgiigVbzw8zcjas,4531
46
+ ramifice/fields/ip_field.py,sha256=D7xR3A-O049TQ_pEEKVTLsKF5cdr5O7ULyz4Pj3-cwQ,3601
47
+ ramifice/fields/password_field.py,sha256=5BlZZ4mXM0CAYDHguwsK8KFnvkOOmr8R0yowHByNVD4,3451
48
+ ramifice/fields/phone_field.py,sha256=ymMbeWq3QI15BzsVUfuuhlHfqtaE_6AvyKkX4PG3zNk,4006
49
+ ramifice/fields/slug_field.py,sha256=t-9ckQ6ki7lNis7U05t4MDd0cE_cdm29es8zfRlHfSs,2655
50
+ ramifice/fields/text_field.py,sha256=AFkXCEI_4QjBdyYtp1DClwaCLkwjKurmLcrDtxhSGxc,3971
51
+ ramifice/fields/url_field.py,sha256=2TbaSfNdD5nxgoVXNgeN0vrpYltmglPHukLWKv2psxc,4248
52
52
  ramifice/fields/general/__init__.py,sha256=5OE0TwPQjvpB3lBPuEwKrhjR_1ehOWxB98OJP_n32MA,20
53
53
  ramifice/fields/general/choice_group.py,sha256=TBJblwH8mB71wd1z2jcSs28H-zx3JZVBfkk4YCE1-pI,916
54
54
  ramifice/fields/general/date_group.py,sha256=RKockc_X1bYAbpzxTzXdc0kxgx51MK0bjko_j34ixWU,1169
@@ -70,12 +70,12 @@ ramifice/paladins/groups/choice_group.py,sha256=OJeZjpnqKnSF1_bechtNepCCPjmp54x1
70
70
  ramifice/paladins/groups/date_group.py,sha256=-IS9pAHXdWK7tO9KQ2UyG1uf7TA43DKYCOCtOM2_tZ0,3844
71
71
  ramifice/paladins/groups/file_group.py,sha256=oQ61TCGoRF8kArOY0F2IXXUTOiRyyu0oh3F1reV8rmU,3298
72
72
  ramifice/paladins/groups/id_group.py,sha256=tK3OL1pr-V8PHPyS7vmjmJi_sRU669EvkY_Fc4sRHzg,1352
73
- ramifice/paladins/groups/img_group.py,sha256=Yi2LG-RK_0NV5at8L8i_OYp--XDzqh66bw3xA9v2HeE,5779
73
+ ramifice/paladins/groups/img_group.py,sha256=X8JDvxr1khNfsuPUXRn_1PoZnrjk_TKTklwujB8Rc9A,5927
74
74
  ramifice/paladins/groups/num_group.py,sha256=Jvb-lwHxapQybbLerC4t-_yO8N7Coo1fIlZ9eAGHcGs,2508
75
75
  ramifice/paladins/groups/pass_group.py,sha256=SEKpR2voNQtmywugDXJKY4XqPTL91CrJ87h0QNMqQqs,1952
76
76
  ramifice/paladins/groups/slug_group.py,sha256=_IRil2PwpY7cH7WaExNksKz61kQjvc27blrEufgUB30,2323
77
77
  ramifice/paladins/groups/text_group.py,sha256=nYZGwAIsJD-tX8RBtFlWvngO9RU4V0CnREUhxvV2UDo,3493
78
- ramifice-0.3.16.dist-info/METADATA,sha256=e2_MkRAQOyshI5iKiXLLcjPQA2UfLmZ5LCJ4jJHEC7I,18896
79
- ramifice-0.3.16.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
80
- ramifice-0.3.16.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
81
- ramifice-0.3.16.dist-info/RECORD,,
78
+ ramifice-0.3.18.dist-info/METADATA,sha256=lojHKf4q5Rrxj4vXJxOfqmNnmZu0JRXalEJxAhoBNAU,18904
79
+ ramifice-0.3.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
80
+ ramifice-0.3.18.dist-info/licenses/LICENSE,sha256=LrEL0aTZx90HDwFUQCJutORiDjJL9AnuVvCtspXIqt4,1095
81
+ ramifice-0.3.18.dist-info/RECORD,,