ramifice 0.8.11__py3-none-any.whl → 0.8.12__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 (84) hide show
  1. ramifice/__init__.py +16 -1
  2. ramifice/commons/__init__.py +2 -2
  3. ramifice/commons/general.py +11 -11
  4. ramifice/commons/indexes.py +8 -8
  5. ramifice/commons/many.py +10 -6
  6. ramifice/commons/one.py +13 -8
  7. ramifice/commons/tools.py +4 -4
  8. ramifice/commons/unit_manager.py +15 -5
  9. ramifice/fields/__init__.py +1 -1
  10. ramifice/fields/bool_field.py +26 -18
  11. ramifice/fields/choice_float_dyn_field.py +29 -21
  12. ramifice/fields/choice_float_field.py +41 -33
  13. ramifice/fields/choice_float_mult_dyn_field.py +29 -21
  14. ramifice/fields/choice_float_mult_field.py +48 -40
  15. ramifice/fields/choice_int_dyn_field.py +29 -21
  16. ramifice/fields/choice_int_field.py +41 -33
  17. ramifice/fields/choice_int_mult_dyn_field.py +29 -21
  18. ramifice/fields/choice_int_mult_field.py +48 -40
  19. ramifice/fields/choice_text_dyn_field.py +29 -21
  20. ramifice/fields/choice_text_field.py +47 -39
  21. ramifice/fields/choice_text_mult_dyn_field.py +29 -21
  22. ramifice/fields/choice_text_mult_field.py +48 -40
  23. ramifice/fields/color_field.py +40 -32
  24. ramifice/fields/date_field.py +49 -40
  25. ramifice/fields/date_time_field.py +49 -40
  26. ramifice/fields/email_field.py +42 -34
  27. ramifice/fields/file_field.py +45 -35
  28. ramifice/fields/float_field.py +56 -47
  29. ramifice/fields/general/__init__.py +1 -1
  30. ramifice/fields/general/choice_group.py +2 -2
  31. ramifice/fields/general/date_group.py +2 -2
  32. ramifice/fields/general/field.py +2 -2
  33. ramifice/fields/general/file_group.py +2 -2
  34. ramifice/fields/general/number_group.py +2 -2
  35. ramifice/fields/general/text_group.py +3 -3
  36. ramifice/fields/id_field.py +35 -28
  37. ramifice/fields/image_field.py +67 -57
  38. ramifice/fields/integer_field.py +56 -47
  39. ramifice/fields/ip_field.py +41 -34
  40. ramifice/fields/password_field.py +29 -22
  41. ramifice/fields/phone_field.py +44 -36
  42. ramifice/fields/slug_field.py +30 -22
  43. ramifice/fields/text_field.py +43 -35
  44. ramifice/fields/url_field.py +40 -33
  45. ramifice/models/__init__.py +1 -1
  46. ramifice/models/decorator.py +33 -11
  47. ramifice/models/model.py +16 -16
  48. ramifice/paladins/__init__.py +2 -2
  49. ramifice/paladins/check.py +8 -3
  50. ramifice/paladins/delete.py +9 -3
  51. ramifice/paladins/groups/__init__.py +1 -1
  52. ramifice/paladins/groups/bool_group.py +3 -3
  53. ramifice/paladins/groups/choice_group.py +3 -3
  54. ramifice/paladins/groups/date_group.py +3 -3
  55. ramifice/paladins/groups/file_group.py +3 -3
  56. ramifice/paladins/groups/id_group.py +3 -3
  57. ramifice/paladins/groups/img_group.py +3 -3
  58. ramifice/paladins/groups/num_group.py +3 -3
  59. ramifice/paladins/groups/pass_group.py +3 -3
  60. ramifice/paladins/groups/slug_group.py +8 -3
  61. ramifice/paladins/groups/text_group.py +3 -3
  62. ramifice/paladins/password.py +11 -4
  63. ramifice/paladins/refrash.py +7 -3
  64. ramifice/paladins/save.py +9 -3
  65. ramifice/paladins/tools.py +11 -6
  66. ramifice/paladins/validation.py +4 -4
  67. ramifice/utils/__init__.py +1 -1
  68. ramifice/utils/constants.py +1 -1
  69. ramifice/utils/errors.py +7 -7
  70. ramifice/utils/fixtures.py +7 -2
  71. ramifice/utils/migration.py +18 -9
  72. ramifice/utils/mixins/__init__.py +1 -1
  73. ramifice/utils/mixins/add_valid.py +3 -3
  74. ramifice/utils/mixins/hooks.py +8 -8
  75. ramifice/utils/mixins/indexing.py +3 -3
  76. ramifice/utils/mixins/json_converter.py +6 -6
  77. ramifice/utils/tools.py +12 -12
  78. ramifice/utils/translations.py +8 -4
  79. ramifice/utils/unit.py +8 -3
  80. {ramifice-0.8.11.dist-info → ramifice-0.8.12.dist-info}/METADATA +1 -1
  81. ramifice-0.8.12.dist-info/RECORD +84 -0
  82. ramifice-0.8.11.dist-info/RECORD +0 -84
  83. {ramifice-0.8.11.dist-info → ramifice-0.8.12.dist-info}/WHEEL +0 -0
  84. {ramifice-0.8.11.dist-info → ramifice-0.8.12.dist-info}/licenses/LICENSE +0 -0
@@ -1,15 +1,20 @@
1
- """Field of Model for enter (int) number."""
1
+ """Ramifice - Field of Model for enter (int) number."""
2
2
 
3
3
  __all__ = ("IntegerField",)
4
4
 
5
+ import logging
6
+ from typing import Literal
7
+
5
8
  from ramifice.fields.general.field import Field
6
9
  from ramifice.fields.general.number_group import NumberGroup
7
10
  from ramifice.utils import constants
8
11
  from ramifice.utils.mixins.json_converter import JsonMixin
9
12
 
13
+ logger = logging.getLogger(__name__)
14
+
10
15
 
11
16
  class IntegerField(Field, NumberGroup, JsonMixin):
12
- """Field of Model for enter (int) number."""
17
+ """Ramifice - Field of Model for enter (int) number."""
13
18
 
14
19
  def __init__( # noqa: D107
15
20
  self,
@@ -27,53 +32,57 @@ class IntegerField(Field, NumberGroup, JsonMixin):
27
32
  max_number: int | None = None,
28
33
  min_number: int | None = None,
29
34
  step: int = 1,
30
- input_type: str = "number", # number | range
35
+ input_type: Literal["number", "range"] = "number",
31
36
  ):
32
37
  if constants.DEBUG:
33
- if input_type not in ["number", "range"]:
34
- raise AssertionError(
35
- "Parameter `input_type` - Invalid input type! "
36
- + "The permissible value of `number` or `range`."
37
- )
38
- if max_number is not None and not isinstance(max_number, int):
39
- raise AssertionError("Parameter `max_number` - Not а number `int` type!")
40
- if min_number is not None and not isinstance(min_number, int):
41
- raise AssertionError("Parameter `min_number` - Not а number `int` type!")
42
- if not isinstance(step, int):
43
- raise AssertionError("Parameter `step` - Not а number `int` type!")
44
- if max_number is not None and min_number is not None and max_number <= min_number:
45
- raise AssertionError(
46
- "The `max_number` parameter should be more than the `min_number`!"
47
- )
48
- if default is not None:
49
- if not isinstance(default, int):
50
- raise AssertionError("Parameter `default` - Not а number `int` type!")
51
- if max_number is not None and default > max_number:
52
- raise AssertionError("Parameter `default` is more `max_number`!")
53
- if max_number is not None and default < min_number: # type: ignore
54
- raise AssertionError("Parameter `default` is less `min_number`!")
55
- if not isinstance(label, str):
56
- raise AssertionError("Parameter `default` - Not а `str` type!")
57
- if not isinstance(disabled, bool):
58
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
59
- if not isinstance(hide, bool):
60
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
61
- if not isinstance(ignored, bool):
62
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
63
- if not isinstance(ignored, bool):
64
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
65
- if not isinstance(hint, str):
66
- raise AssertionError("Parameter `hint` - Not а `str` type!")
67
- if warning is not None and not isinstance(warning, list):
68
- raise AssertionError("Parameter `warning` - Not а `list` type!")
69
- if not isinstance(placeholder, str):
70
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
71
- if not isinstance(required, bool):
72
- raise AssertionError("Parameter `required` - Not а `bool` type!")
73
- if not isinstance(readonly, bool):
74
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
75
- if not isinstance(unique, bool):
76
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
38
+ try:
39
+ if input_type not in ["number", "range"]:
40
+ raise AssertionError(
41
+ "Parameter `input_type` - Invalid input type! "
42
+ + "The permissible value of `number` or `range`."
43
+ )
44
+ if max_number is not None and not isinstance(max_number, int):
45
+ raise AssertionError("Parameter `max_number` - Not а number `int` type!")
46
+ if min_number is not None and not isinstance(min_number, int):
47
+ raise AssertionError("Parameter `min_number` - Not а number `int` type!")
48
+ if not isinstance(step, int):
49
+ raise AssertionError("Parameter `step` - Not а number `int` type!")
50
+ if max_number is not None and min_number is not None and max_number <= min_number:
51
+ raise AssertionError(
52
+ "The `max_number` parameter should be more than the `min_number`!"
53
+ )
54
+ if default is not None:
55
+ if not isinstance(default, int):
56
+ raise AssertionError("Parameter `default` - Not а number `int` type!")
57
+ if max_number is not None and default > max_number:
58
+ raise AssertionError("Parameter `default` is more `max_number`!")
59
+ if max_number is not None and default < min_number: # type: ignore
60
+ raise AssertionError("Parameter `default` is less `min_number`!")
61
+ if not isinstance(label, str):
62
+ raise AssertionError("Parameter `default` - Not а `str` type!")
63
+ if not isinstance(disabled, bool):
64
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
65
+ if not isinstance(hide, bool):
66
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
67
+ if not isinstance(ignored, bool):
68
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
69
+ if not isinstance(ignored, bool):
70
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
71
+ if not isinstance(hint, str):
72
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
73
+ if warning is not None and not isinstance(warning, list):
74
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
75
+ if not isinstance(placeholder, str):
76
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
77
+ if not isinstance(required, bool):
78
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
79
+ if not isinstance(readonly, bool):
80
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
81
+ if not isinstance(unique, bool):
82
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
83
+ except AssertionError as err:
84
+ logger.error(str(err))
85
+ raise err
77
86
 
78
87
  Field.__init__(
79
88
  self,
@@ -1,17 +1,20 @@
1
- """Field of Model for enter IP address."""
1
+ """Ramifice - Field of Model for enter IP address."""
2
2
 
3
3
  __all__ = ("IPField",)
4
4
 
5
5
  import ipaddress
6
+ import logging
6
7
 
7
8
  from ramifice.fields.general.field import Field
8
9
  from ramifice.fields.general.text_group import TextGroup
9
10
  from ramifice.utils import constants
10
11
  from ramifice.utils.mixins.json_converter import JsonMixin
11
12
 
13
+ logger = logging.getLogger(__name__)
14
+
12
15
 
13
16
  class IPField(Field, TextGroup, JsonMixin):
14
- """Field of Model for enter IP address."""
17
+ """Ramifice - Field of Model for enter IP address."""
15
18
 
16
19
  def __init__( # noqa: D107
17
20
  self,
@@ -28,39 +31,43 @@ class IPField(Field, TextGroup, JsonMixin):
28
31
  unique: bool = False,
29
32
  ):
30
33
  if constants.DEBUG:
31
- if default is not None:
32
- if not isinstance(default, str):
34
+ try:
35
+ if default is not None:
36
+ if not isinstance(default, str):
37
+ raise AssertionError("Parameter `default` - Not а `str` type!")
38
+ if len(default) == 0:
39
+ raise AssertionError(
40
+ "The `default` parameter should not contain an empty string!"
41
+ )
42
+ try:
43
+ ipaddress.ip_address(default)
44
+ except ValueError:
45
+ raise AssertionError("Parameter `default` - Invalid IP address!")
46
+ if not isinstance(label, str):
33
47
  raise AssertionError("Parameter `default` - Not а `str` type!")
34
- if len(default) == 0:
35
- raise AssertionError(
36
- "The `default` parameter should not contain an empty string!"
37
- )
38
- try:
39
- ipaddress.ip_address(default)
40
- except ValueError:
41
- raise AssertionError("Parameter `default` - Invalid IP address!")
42
- if not isinstance(label, str):
43
- raise AssertionError("Parameter `default` - Not а `str` type!")
44
- if not isinstance(disabled, bool):
45
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
46
- if not isinstance(hide, bool):
47
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
48
- if not isinstance(ignored, bool):
49
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
50
- if not isinstance(ignored, bool):
51
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
52
- if not isinstance(hint, str):
53
- raise AssertionError("Parameter `hint` - Not а `str` type!")
54
- if warning is not None and not isinstance(warning, list):
55
- raise AssertionError("Parameter `warning` - Not а `list` type!")
56
- if not isinstance(placeholder, str):
57
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
58
- if not isinstance(required, bool):
59
- raise AssertionError("Parameter `required` - Not а `bool` type!")
60
- if not isinstance(readonly, bool):
61
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
62
- if not isinstance(unique, bool):
63
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
48
+ if not isinstance(disabled, bool):
49
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
50
+ if not isinstance(hide, bool):
51
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
52
+ if not isinstance(ignored, bool):
53
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
54
+ if not isinstance(ignored, bool):
55
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
56
+ if not isinstance(hint, str):
57
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
58
+ if warning is not None and not isinstance(warning, list):
59
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
60
+ if not isinstance(placeholder, str):
61
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
62
+ if not isinstance(required, bool):
63
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
64
+ if not isinstance(readonly, bool):
65
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
66
+ if not isinstance(unique, bool):
67
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
68
+ except AssertionError as err:
69
+ logger.error(str(err))
70
+ raise err
64
71
 
65
72
  Field.__init__(
66
73
  self,
@@ -1,7 +1,8 @@
1
- """Field of Model for enter password."""
1
+ """Ramifice - Field of Model for enter password."""
2
2
 
3
3
  __all__ = ("PasswordField",)
4
4
 
5
+ import logging
5
6
  from typing import Any
6
7
 
7
8
  import orjson
@@ -9,9 +10,11 @@ import orjson
9
10
  from ramifice.fields.general.field import Field
10
11
  from ramifice.utils import constants
11
12
 
13
+ logger = logging.getLogger(__name__)
14
+
12
15
 
13
16
  class PasswordField(Field):
14
- r"""Field of Model for enter password.
17
+ r"""Ramifice - Field of Model for enter password.
15
18
 
16
19
  Warning:
17
20
  Regular expression: ^[-._!"`'#%&,:;<>=@{}~$()*+/\\?[]^|a-zA-Z0-9]{8,256}$
@@ -30,22 +33,26 @@ class PasswordField(Field):
30
33
  required: bool = False,
31
34
  ):
32
35
  if constants.DEBUG:
33
- if not isinstance(label, str):
34
- raise AssertionError("Parameter `default` - Not а `str` type!")
35
- if not isinstance(hide, bool):
36
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
37
- if not isinstance(ignored, bool):
38
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
39
- if not isinstance(ignored, bool):
40
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
41
- if not isinstance(hint, str):
42
- raise AssertionError("Parameter `hint` - Not а `str` type!")
43
- if warning is not None and not isinstance(warning, list):
44
- raise AssertionError("Parameter `warning` - Not а `list` type!")
45
- if not isinstance(placeholder, str):
46
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
47
- if not isinstance(required, bool):
48
- raise AssertionError("Parameter `required` - Not а `bool` type!")
36
+ try:
37
+ if not isinstance(label, str):
38
+ raise AssertionError("Parameter `default` - Not а `str` type!")
39
+ if not isinstance(hide, bool):
40
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
41
+ if not isinstance(ignored, bool):
42
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
43
+ if not isinstance(ignored, bool):
44
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
45
+ if not isinstance(hint, str):
46
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
47
+ if warning is not None and not isinstance(warning, list):
48
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
49
+ if not isinstance(placeholder, str):
50
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
51
+ if not isinstance(required, bool):
52
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
53
+ except AssertionError as err:
54
+ logger.error(str(err))
55
+ raise err
49
56
 
50
57
  Field.__init__(
51
58
  self,
@@ -65,7 +72,7 @@ class PasswordField(Field):
65
72
  self.required = required
66
73
 
67
74
  def to_dict(self) -> dict[str, Any]:
68
- """Convert object instance to a dictionary."""
75
+ """Ramifice - Convert object instance to a dictionary."""
69
76
  json_dict: dict[str, Any] = {}
70
77
  for name, data in self.__dict__.items():
71
78
  if not callable(data):
@@ -73,12 +80,12 @@ class PasswordField(Field):
73
80
  return json_dict
74
81
 
75
82
  def to_json(self) -> str:
76
- """Convert object instance to a JSON string."""
83
+ """Ramifice - Convert object instance to a JSON string."""
77
84
  return orjson.dumps(self.to_dict()).decode("utf-8")
78
85
 
79
86
  @classmethod
80
87
  def from_dict(cls, json_dict: dict[str, Any]) -> Any:
81
- """Convert JSON string to a object instance."""
88
+ """Ramifice - Convert JSON string to a object instance."""
82
89
  obj = cls()
83
90
  for name, data in json_dict.items():
84
91
  obj.__dict__[name] = data
@@ -86,6 +93,6 @@ class PasswordField(Field):
86
93
 
87
94
  @classmethod
88
95
  def from_json(cls, json_str: str) -> Any:
89
- """Convert JSON string to a object instance."""
96
+ """Ramifice - Convert JSON string to a object instance."""
90
97
  json_dict = orjson.loads(json_str)
91
98
  return cls.from_dict(json_dict)
@@ -1,7 +1,9 @@
1
- """Field of Model for enter phone number."""
1
+ """Ramifice - Field of Model for enter phone number."""
2
2
 
3
3
  __all__ = ("PhoneField",)
4
4
 
5
+ import logging
6
+
5
7
  import phonenumbers
6
8
 
7
9
  from ramifice.fields.general.field import Field
@@ -9,9 +11,11 @@ from ramifice.fields.general.text_group import TextGroup
9
11
  from ramifice.utils import constants
10
12
  from ramifice.utils.mixins.json_converter import JsonMixin
11
13
 
14
+ logger = logging.getLogger(__name__)
15
+
12
16
 
13
17
  class PhoneField(Field, TextGroup, JsonMixin):
14
- """Field of Model for enter phone number.
18
+ """Ramifice - Field of Model for enter phone number.
15
19
 
16
20
  WARNING: By default is used validator `phonenumbers.is_valid_number()`.
17
21
  """
@@ -31,41 +35,45 @@ class PhoneField(Field, TextGroup, JsonMixin):
31
35
  unique: bool = False,
32
36
  ):
33
37
  if constants.DEBUG:
34
- if default is not None:
35
- if not isinstance(default, str):
38
+ try:
39
+ if default is not None:
40
+ if not isinstance(default, str):
41
+ raise AssertionError("Parameter `default` - Not а `str` type!")
42
+ if len(default) == 0:
43
+ raise AssertionError(
44
+ "The `default` parameter should not contain an empty string!"
45
+ )
46
+ try:
47
+ phone_default = phonenumbers.parse(default)
48
+ if not phonenumbers.is_valid_number(phone_default):
49
+ raise AssertionError()
50
+ except phonenumbers.phonenumberutil.NumberParseException:
51
+ raise AssertionError("Parameter `default` - Invalid Phone number!")
52
+ if not isinstance(label, str):
36
53
  raise AssertionError("Parameter `default` - Not а `str` type!")
37
- if len(default) == 0:
38
- raise AssertionError(
39
- "The `default` parameter should not contain an empty string!"
40
- )
41
- try:
42
- phone_default = phonenumbers.parse(default)
43
- if not phonenumbers.is_valid_number(phone_default):
44
- raise AssertionError()
45
- except phonenumbers.phonenumberutil.NumberParseException:
46
- raise AssertionError("Parameter `default` - Invalid Phone number!")
47
- if not isinstance(label, str):
48
- raise AssertionError("Parameter `default` - Not а `str` type!")
49
- if not isinstance(disabled, bool):
50
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
51
- if not isinstance(hide, bool):
52
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
53
- if not isinstance(ignored, bool):
54
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
55
- if not isinstance(ignored, bool):
56
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
57
- if not isinstance(hint, str):
58
- raise AssertionError("Parameter `hint` - Not а `str` type!")
59
- if warning is not None and not isinstance(warning, list):
60
- raise AssertionError("Parameter `warning` - Not а `list` type!")
61
- if not isinstance(placeholder, str):
62
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
63
- if not isinstance(required, bool):
64
- raise AssertionError("Parameter `required` - Not а `bool` type!")
65
- if not isinstance(readonly, bool):
66
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
67
- if not isinstance(unique, bool):
68
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
54
+ if not isinstance(disabled, bool):
55
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
56
+ if not isinstance(hide, bool):
57
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
58
+ if not isinstance(ignored, bool):
59
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
60
+ if not isinstance(ignored, bool):
61
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
62
+ if not isinstance(hint, str):
63
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
64
+ if warning is not None and not isinstance(warning, list):
65
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
66
+ if not isinstance(placeholder, str):
67
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
68
+ if not isinstance(required, bool):
69
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
70
+ if not isinstance(readonly, bool):
71
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
72
+ if not isinstance(unique, bool):
73
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
74
+ except AssertionError as err:
75
+ logger.error(str(err))
76
+ raise err
69
77
 
70
78
  Field.__init__(
71
79
  self,
@@ -1,15 +1,19 @@
1
- """Field of Model for automatic generation of string `slug`."""
1
+ """Ramifice - Field of Model for automatic generation of string `slug`."""
2
2
 
3
3
  __all__ = ("SlugField",)
4
4
 
5
+ import logging
6
+
5
7
  from ramifice.fields.general.field import Field
6
8
  from ramifice.fields.general.text_group import TextGroup
7
9
  from ramifice.utils import constants
8
10
  from ramifice.utils.mixins.json_converter import JsonMixin
9
11
 
12
+ logger = logging.getLogger(__name__)
13
+
10
14
 
11
15
  class SlugField(Field, TextGroup, JsonMixin):
12
- """Field of Model for automatic generation of string `slug`.
16
+ """Ramifice - Field of Model for automatic generation of string `slug`.
13
17
 
14
18
  Convenient to use for Url addresses.
15
19
  """
@@ -27,26 +31,30 @@ class SlugField(Field, TextGroup, JsonMixin):
27
31
  slug_sources: list[str] = ["_id"],
28
32
  ):
29
33
  if constants.DEBUG:
30
- if not isinstance(label, str):
31
- raise AssertionError("Parameter `default` - Not а `str` type!")
32
- if not isinstance(disabled, bool):
33
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
34
- if not isinstance(hide, bool):
35
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
36
- if not isinstance(ignored, bool):
37
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
38
- if not isinstance(ignored, bool):
39
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
40
- if not isinstance(hint, str):
41
- raise AssertionError("Parameter `hint` - Not а `str` type!")
42
- if warning is not None and not isinstance(warning, list):
43
- raise AssertionError("Parameter `warning` - Not а `list` type!")
44
- if not isinstance(placeholder, str):
45
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
46
- if not isinstance(readonly, bool):
47
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
48
- if not isinstance(slug_sources, list):
49
- raise AssertionError("Parameter `slug_sources` - Not а `list` type!")
34
+ try:
35
+ if not isinstance(label, str):
36
+ raise AssertionError("Parameter `default` - Not а `str` type!")
37
+ if not isinstance(disabled, bool):
38
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
39
+ if not isinstance(hide, bool):
40
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
41
+ if not isinstance(ignored, bool):
42
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
43
+ if not isinstance(ignored, bool):
44
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
45
+ if not isinstance(hint, str):
46
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
47
+ if warning is not None and not isinstance(warning, list):
48
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
49
+ if not isinstance(placeholder, str):
50
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
51
+ if not isinstance(readonly, bool):
52
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
53
+ if not isinstance(slug_sources, list):
54
+ raise AssertionError("Parameter `slug_sources` - Not а `list` type!")
55
+ except AssertionError as err:
56
+ logger.error(str(err))
57
+ raise err
50
58
 
51
59
  Field.__init__(
52
60
  self,
@@ -1,14 +1,18 @@
1
- """Field of Model for enter text."""
1
+ """Ramifice - Field of Model for enter text."""
2
2
 
3
3
  __all__ = ("TextField",)
4
4
 
5
+ import logging
6
+
5
7
  from ramifice.fields.general.field import Field
6
8
  from ramifice.utils import constants
7
9
  from ramifice.utils.mixins.json_converter import JsonMixin
8
10
 
11
+ logger = logging.getLogger(__name__)
12
+
9
13
 
10
14
  class TextField(Field, JsonMixin):
11
- """Field of Model for enter text."""
15
+ """Ramifice - Field of Model for enter text."""
12
16
 
13
17
  def __init__( # noqa: D107
14
18
  self,
@@ -29,38 +33,42 @@ class TextField(Field, JsonMixin):
29
33
  multi_language: bool = False,
30
34
  ):
31
35
  if constants.DEBUG:
32
- if not isinstance(maxlength, int):
33
- raise AssertionError("Parameter `maxlength` - Not а `int` type!")
34
- if not isinstance(label, str):
35
- raise AssertionError("Parameter `default` - Not а `str` type!")
36
- if not isinstance(disabled, bool):
37
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
38
- if not isinstance(hide, bool):
39
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
40
- if not isinstance(ignored, bool):
41
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
42
- if not isinstance(ignored, bool):
43
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
44
- if not isinstance(hint, str):
45
- raise AssertionError("Parameter `hint` - Not а `str` type!")
46
- if warning is not None and not isinstance(warning, list):
47
- raise AssertionError("Parameter `warning` - Not а `list` type!")
48
- if not isinstance(placeholder, str):
49
- raise AssertionError("Parameter `placeholder` - Not а `str` type!")
50
- if not isinstance(required, bool):
51
- raise AssertionError("Parameter `required` - Not а `bool` type!")
52
- if not isinstance(readonly, bool):
53
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
54
- if not isinstance(unique, bool):
55
- raise AssertionError("Parameter `unique` - Not а `bool` type!")
56
- if not isinstance(textarea, bool):
57
- raise AssertionError("Parameter `textarea` - Not а `bool` type!")
58
- if not isinstance(use_editor, bool):
59
- raise AssertionError("Parameter `use_editor` - Not а `bool` type!")
60
- if not isinstance(maxlength, int):
61
- raise AssertionError("Parameter `maxlength` - Not а `int` type!")
62
- if not isinstance(multi_language, bool):
63
- raise AssertionError("Parameter `multi_language` - Not а `int` type!")
36
+ try:
37
+ if not isinstance(maxlength, int):
38
+ raise AssertionError("Parameter `maxlength` - Not а `int` type!")
39
+ if not isinstance(label, str):
40
+ raise AssertionError("Parameter `default` - Not а `str` type!")
41
+ if not isinstance(disabled, bool):
42
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
43
+ if not isinstance(hide, bool):
44
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
45
+ if not isinstance(ignored, bool):
46
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
47
+ if not isinstance(ignored, bool):
48
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
49
+ if not isinstance(hint, str):
50
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
51
+ if warning is not None and not isinstance(warning, list):
52
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
53
+ if not isinstance(placeholder, str):
54
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
55
+ if not isinstance(required, bool):
56
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
57
+ if not isinstance(readonly, bool):
58
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
59
+ if not isinstance(unique, bool):
60
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
61
+ if not isinstance(textarea, bool):
62
+ raise AssertionError("Parameter `textarea` - Not а `bool` type!")
63
+ if not isinstance(use_editor, bool):
64
+ raise AssertionError("Parameter `use_editor` - Not а `bool` type!")
65
+ if not isinstance(maxlength, int):
66
+ raise AssertionError("Parameter `maxlength` - Not а `int` type!")
67
+ if not isinstance(multi_language, bool):
68
+ raise AssertionError("Parameter `multi_language` - Not а `int` type!")
69
+ except AssertionError as err:
70
+ logger.error(str(err))
71
+ raise err
64
72
 
65
73
  Field.__init__(
66
74
  self,
@@ -88,7 +96,7 @@ class TextField(Field, JsonMixin):
88
96
  self.multi_language = multi_language
89
97
 
90
98
  def __len__(self) -> int:
91
- """Return length of field `value`."""
99
+ """Ramifice - Return length of field `value`."""
92
100
  value = self.value
93
101
  if isinstance(value, str):
94
102
  return len(value)