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,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective integer field with static of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceIntMultField",)
7
7
 
8
+ import logging
9
+
8
10
  from ramifice.fields.general.choice_group import ChoiceGroup
9
11
  from ramifice.fields.general.field import Field
10
12
  from ramifice.utils import constants
11
13
  from ramifice.utils.mixins.json_converter import JsonMixin
12
14
 
15
+ logger = logging.getLogger(__name__)
16
+
13
17
 
14
18
  class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective integer field with static of elements.
18
22
  With multiple choice.
@@ -55,46 +59,50 @@ class ChoiceIntMultField(Field, ChoiceGroup, JsonMixin):
55
59
  self.choices = choices
56
60
 
57
61
  if constants.DEBUG:
58
- if choices is not None:
59
- if not isinstance(choices, list):
60
- raise AssertionError("Parameter `choices` - Not а `list` type!")
61
- if len(choices) == 0:
62
- raise AssertionError(
63
- "The `choices` parameter should not contain an empty list!"
64
- )
65
- if default is not None:
66
- if not isinstance(default, list):
67
- raise AssertionError("Parameter `default` - Not а `list` type!")
68
- if len(default) == 0:
69
- raise AssertionError(
70
- "The `default` parameter should not contain an empty list!"
71
- )
72
- if choices is not None and not self.has_value():
73
- raise AssertionError(
74
- "Parameter `default` does not coincide with "
75
- + "list of permissive values in `choicees`."
76
- )
77
- if not isinstance(label, str):
78
- raise AssertionError("Parameter `default` - Not а `str` type!")
79
- if not isinstance(disabled, bool):
80
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
81
- if not isinstance(hide, bool):
82
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
83
- if not isinstance(ignored, bool):
84
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
85
- if not isinstance(ignored, bool):
86
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
87
- if not isinstance(hint, str):
88
- raise AssertionError("Parameter `hint` - Not а `str` type!")
89
- if warning is not None and not isinstance(warning, list):
90
- raise AssertionError("Parameter `warning` - Not а `list` type!")
91
- if not isinstance(required, bool):
92
- raise AssertionError("Parameter `required` - Not а `bool` type!")
93
- if not isinstance(readonly, bool):
94
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
62
+ try:
63
+ if choices is not None:
64
+ if not isinstance(choices, list):
65
+ raise AssertionError("Parameter `choices` - Not а `list` type!")
66
+ if len(choices) == 0:
67
+ raise AssertionError(
68
+ "The `choices` parameter should not contain an empty list!"
69
+ )
70
+ if default is not None:
71
+ if not isinstance(default, list):
72
+ raise AssertionError("Parameter `default` - Not а `list` type!")
73
+ if len(default) == 0:
74
+ raise AssertionError(
75
+ "The `default` parameter should not contain an empty list!"
76
+ )
77
+ if choices is not None and not self.has_value():
78
+ raise AssertionError(
79
+ "Parameter `default` does not coincide with "
80
+ + "list of permissive values in `choicees`."
81
+ )
82
+ if not isinstance(label, str):
83
+ raise AssertionError("Parameter `default` - Not а `str` type!")
84
+ if not isinstance(disabled, bool):
85
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
86
+ if not isinstance(hide, bool):
87
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
88
+ if not isinstance(ignored, bool):
89
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
90
+ if not isinstance(ignored, bool):
91
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
92
+ if not isinstance(hint, str):
93
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
94
+ if warning is not None and not isinstance(warning, list):
95
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
96
+ if not isinstance(required, bool):
97
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
98
+ if not isinstance(readonly, bool):
99
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
100
+ except AssertionError as err:
101
+ logger.error(str(err))
102
+ raise err
95
103
 
96
104
  def has_value(self, is_migrate: bool = False) -> bool:
97
- """Does the field value match the possible options in choices."""
105
+ """Ramifice - Does the field value match the possible options in choices."""
98
106
  value = self.value
99
107
  if value is None:
100
108
  value = self.default
@@ -1,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective text field with dynamic addition of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceTextDynField",)
7
7
 
8
+ import logging
9
+
8
10
  from ramifice.fields.general.choice_group import ChoiceGroup
9
11
  from ramifice.fields.general.field import Field
10
12
  from ramifice.utils import constants
11
13
  from ramifice.utils.mixins.json_converter import JsonMixin
12
14
 
15
+ logger = logging.getLogger(__name__)
16
+
13
17
 
14
18
  class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective text field with dynamic addition of elements.
18
22
  For simulate relationship Many-to-One.
@@ -31,24 +35,28 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
31
35
  readonly: bool = False,
32
36
  ):
33
37
  if constants.DEBUG:
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(required, bool):
49
- raise AssertionError("Parameter `required` - Not а `bool` type!")
50
- if not isinstance(readonly, bool):
51
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
38
+ try:
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(required, bool):
54
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
55
+ if not isinstance(readonly, bool):
56
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
57
+ except AssertionError as err:
58
+ logger.error(str(err))
59
+ raise err
52
60
 
53
61
  Field.__init__(
54
62
  self,
@@ -72,7 +80,7 @@ class ChoiceTextDynField(Field, ChoiceGroup, JsonMixin):
72
80
  self.choices: list[list[str]] | None = None
73
81
 
74
82
  def has_value(self, is_migrate: bool = False) -> bool:
75
- """Does the field value match the possible options in choices."""
83
+ """Ramifice - Does the field value match the possible options in choices."""
76
84
  if is_migrate:
77
85
  return True
78
86
  value = self.value
@@ -1,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective text field with static of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceTextField",)
7
7
 
8
+ import logging
9
+
8
10
  from ramifice.fields.general.choice_group import ChoiceGroup
9
11
  from ramifice.fields.general.field import Field
10
12
  from ramifice.utils import constants
11
13
  from ramifice.utils.mixins.json_converter import JsonMixin
12
14
 
15
+ logger = logging.getLogger(__name__)
16
+
13
17
 
14
18
  class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective text field with static of elements.
18
22
  With a single choice.
@@ -54,46 +58,50 @@ class ChoiceTextField(Field, ChoiceGroup, JsonMixin):
54
58
  self.choices = choices
55
59
 
56
60
  if constants.DEBUG:
57
- if choices is not None:
58
- if not isinstance(choices, list):
59
- raise AssertionError("Parameter `choices` - Not а `list` type!")
60
- if len(choices) == 0:
61
- raise AssertionError(
62
- "The `choices` parameter should not contain an empty list!"
63
- )
64
- if default is not None:
65
- if not isinstance(default, str):
61
+ try:
62
+ if choices is not None:
63
+ if not isinstance(choices, list):
64
+ raise AssertionError("Parameter `choices` - Not а `list` type!")
65
+ if len(choices) == 0:
66
+ raise AssertionError(
67
+ "The `choices` parameter should not contain an empty list!"
68
+ )
69
+ if default is not None:
70
+ if not isinstance(default, str):
71
+ raise AssertionError("Parameter `default` - Not а `str` type!")
72
+ if len(default) == 0:
73
+ raise AssertionError(
74
+ "The `default` parameter should not contain an empty string!"
75
+ )
76
+ if choices is not None and not self.has_value():
77
+ raise AssertionError(
78
+ "Parameter `default` does not coincide with "
79
+ + "list of permissive values in `choicees`."
80
+ )
81
+ if not isinstance(label, str):
66
82
  raise AssertionError("Parameter `default` - Not а `str` type!")
67
- if len(default) == 0:
68
- raise AssertionError(
69
- "The `default` parameter should not contain an empty string!"
70
- )
71
- if choices is not None and not self.has_value():
72
- raise AssertionError(
73
- "Parameter `default` does not coincide with "
74
- + "list of permissive values in `choicees`."
75
- )
76
- if not isinstance(label, str):
77
- raise AssertionError("Parameter `default` - Not а `str` type!")
78
- if not isinstance(disabled, bool):
79
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
80
- if not isinstance(hide, bool):
81
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
82
- if not isinstance(ignored, bool):
83
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
84
- if not isinstance(ignored, bool):
85
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
86
- if not isinstance(hint, str):
87
- raise AssertionError("Parameter `hint` - Not а `str` type!")
88
- if warning is not None and not isinstance(warning, list):
89
- raise AssertionError("Parameter `warning` - Not а `list` type!")
90
- if not isinstance(required, bool):
91
- raise AssertionError("Parameter `required` - Not а `bool` type!")
92
- if not isinstance(readonly, bool):
93
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
83
+ if not isinstance(disabled, bool):
84
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
85
+ if not isinstance(hide, bool):
86
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
87
+ if not isinstance(ignored, bool):
88
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
89
+ if not isinstance(ignored, bool):
90
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
91
+ if not isinstance(hint, str):
92
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
93
+ if warning is not None and not isinstance(warning, list):
94
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
95
+ if not isinstance(required, bool):
96
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
97
+ if not isinstance(readonly, bool):
98
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
99
+ except AssertionError as err:
100
+ logger.error(str(err))
101
+ raise err
94
102
 
95
103
  def has_value(self, is_migrate: bool = False) -> bool:
96
- """Does the field value match the possible options in choices."""
104
+ """Ramifice - Does the field value match the possible options in choices."""
97
105
  value = self.value
98
106
  if value is None:
99
107
  value = self.default
@@ -1,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective text field with dynamic addition of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceTextMultDynField",)
7
7
 
8
+ import logging
9
+
8
10
  from ramifice.fields.general.choice_group import ChoiceGroup
9
11
  from ramifice.fields.general.field import Field
10
12
  from ramifice.utils import constants
11
13
  from ramifice.utils.mixins.json_converter import JsonMixin
12
14
 
15
+ logger = logging.getLogger(__name__)
16
+
13
17
 
14
18
  class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective text field with dynamic addition of elements.
18
22
  For simulate relationship Many-to-Many.
@@ -30,24 +34,28 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
30
34
  readonly: bool = False,
31
35
  ):
32
36
  if constants.DEBUG:
33
- if not isinstance(label, str):
34
- raise AssertionError("Parameter `default` - Not а `str` type!")
35
- if not isinstance(disabled, bool):
36
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
37
- if not isinstance(hide, bool):
38
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
39
- if not isinstance(ignored, bool):
40
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
41
- if not isinstance(ignored, bool):
42
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
43
- if not isinstance(hint, str):
44
- raise AssertionError("Parameter `hint` - Not а `str` type!")
45
- if warning is not None and not isinstance(warning, list):
46
- raise AssertionError("Parameter `warning` - Not а `list` type!")
47
- if not isinstance(required, bool):
48
- raise AssertionError("Parameter `required` - Not а `bool` type!")
49
- if not isinstance(readonly, bool):
50
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
37
+ try:
38
+ if not isinstance(label, str):
39
+ raise AssertionError("Parameter `default` - Not а `str` type!")
40
+ if not isinstance(disabled, bool):
41
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
42
+ if not isinstance(hide, bool):
43
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
44
+ if not isinstance(ignored, bool):
45
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
46
+ if not isinstance(ignored, bool):
47
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
48
+ if not isinstance(hint, str):
49
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
50
+ if warning is not None and not isinstance(warning, list):
51
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
52
+ if not isinstance(required, bool):
53
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
54
+ if not isinstance(readonly, bool):
55
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
56
+ except AssertionError as err:
57
+ logger.error(str(err))
58
+ raise err
51
59
 
52
60
  Field.__init__(
53
61
  self,
@@ -72,7 +80,7 @@ class ChoiceTextMultDynField(Field, ChoiceGroup, JsonMixin):
72
80
  self.choices: list[list[str]] | None = None
73
81
 
74
82
  def has_value(self, is_migrate: bool = False) -> bool:
75
- """Does the field value match the possible options in choices."""
83
+ """Ramifice - Does the field value match the possible options in choices."""
76
84
  if is_migrate:
77
85
  return True
78
86
  value = self.value
@@ -1,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective text field with static of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceTextMultField",)
7
7
 
8
+ import logging
9
+
8
10
  from ramifice.fields.general.choice_group import ChoiceGroup
9
11
  from ramifice.fields.general.field import Field
10
12
  from ramifice.utils import constants
11
13
  from ramifice.utils.mixins.json_converter import JsonMixin
12
14
 
15
+ logger = logging.getLogger(__name__)
16
+
13
17
 
14
18
  class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective text field with static of elements.
18
22
  With multiple choice.
@@ -55,46 +59,50 @@ class ChoiceTextMultField(Field, ChoiceGroup, JsonMixin):
55
59
  self.choices = choices
56
60
 
57
61
  if constants.DEBUG:
58
- if choices is not None:
59
- if not isinstance(choices, list):
60
- raise AssertionError("Parameter `choices` - Not а `list` type!")
61
- if len(choices) == 0:
62
- raise AssertionError(
63
- "The `choices` parameter should not contain an empty list!"
64
- )
65
- if default is not None:
66
- if not isinstance(default, list):
67
- raise AssertionError("Parameter `default` - Not а `list` type!")
68
- if len(default) == 0:
69
- raise AssertionError(
70
- "The `default` parameter should not contain an empty list!"
71
- )
72
- if choices is not None and not self.has_value():
73
- raise AssertionError(
74
- "Parameter `default` does not coincide with "
75
- + "list of permissive values in `choicees`."
76
- )
77
- if not isinstance(label, str):
78
- raise AssertionError("Parameter `default` - Not а `str` type!")
79
- if not isinstance(disabled, bool):
80
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
81
- if not isinstance(hide, bool):
82
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
83
- if not isinstance(ignored, bool):
84
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
85
- if not isinstance(ignored, bool):
86
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
87
- if not isinstance(hint, str):
88
- raise AssertionError("Parameter `hint` - Not а `str` type!")
89
- if warning is not None and not isinstance(warning, list):
90
- raise AssertionError("Parameter `warning` - Not а `list` type!")
91
- if not isinstance(required, bool):
92
- raise AssertionError("Parameter `required` - Not а `bool` type!")
93
- if not isinstance(readonly, bool):
94
- raise AssertionError("Parameter `readonly` - Not а `bool` type!")
62
+ try:
63
+ if choices is not None:
64
+ if not isinstance(choices, list):
65
+ raise AssertionError("Parameter `choices` - Not а `list` type!")
66
+ if len(choices) == 0:
67
+ raise AssertionError(
68
+ "The `choices` parameter should not contain an empty list!"
69
+ )
70
+ if default is not None:
71
+ if not isinstance(default, list):
72
+ raise AssertionError("Parameter `default` - Not а `list` type!")
73
+ if len(default) == 0:
74
+ raise AssertionError(
75
+ "The `default` parameter should not contain an empty list!"
76
+ )
77
+ if choices is not None and not self.has_value():
78
+ raise AssertionError(
79
+ "Parameter `default` does not coincide with "
80
+ + "list of permissive values in `choicees`."
81
+ )
82
+ if not isinstance(label, str):
83
+ raise AssertionError("Parameter `default` - Not а `str` type!")
84
+ if not isinstance(disabled, bool):
85
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
86
+ if not isinstance(hide, bool):
87
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
88
+ if not isinstance(ignored, bool):
89
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
90
+ if not isinstance(ignored, bool):
91
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
92
+ if not isinstance(hint, str):
93
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
94
+ if warning is not None and not isinstance(warning, list):
95
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
96
+ if not isinstance(required, bool):
97
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
98
+ if not isinstance(readonly, bool):
99
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
100
+ except AssertionError as err:
101
+ logger.error(str(err))
102
+ raise err
95
103
 
96
104
  def has_value(self, is_migrate: bool = False) -> bool:
97
- """Does the field value match the possible options in choices."""
105
+ """Ramifice - Does the field value match the possible options in choices."""
98
106
  value = self.value
99
107
  if value is None:
100
108
  value = self.default
@@ -1,15 +1,19 @@
1
- """Field of Model for enter color code."""
1
+ """Ramifice - Field of Model for enter color code."""
2
2
 
3
3
  __all__ = ("ColorField",)
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 ColorField(Field, TextGroup, JsonMixin):
12
- """Field of Model for enter color code.
16
+ """Ramifice - Field of Model for enter color code.
13
17
 
14
18
  Default value is #000000 (black).
15
19
 
@@ -34,37 +38,41 @@ class ColorField(Field, TextGroup, JsonMixin):
34
38
  unique: bool = False,
35
39
  ):
36
40
  if constants.DEBUG:
37
- if default is not None:
38
- if not isinstance(default, str):
41
+ try:
42
+ if default is not None:
43
+ if not isinstance(default, str):
44
+ raise AssertionError("Parameter `default` - Not а `str` type!")
45
+ if len(default) == 0:
46
+ raise AssertionError(
47
+ "The `default` parameter should not contain an empty string!"
48
+ )
49
+ if constants.REGEX["color_code"].match(default) is None:
50
+ raise AssertionError("Parameter `default` - Not а color code!")
51
+ if not isinstance(label, str):
39
52
  raise AssertionError("Parameter `default` - Not а `str` type!")
40
- if len(default) == 0:
41
- raise AssertionError(
42
- "The `default` parameter should not contain an empty string!"
43
- )
44
- if constants.REGEX["color_code"].match(default) is None:
45
- raise AssertionError("Parameter `default` - Not а color code!")
46
- if not isinstance(label, str):
47
- raise AssertionError("Parameter `default` - Not а `str` 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!")
53
+ if not isinstance(disabled, bool):
54
+ raise AssertionError("Parameter `disabled` - Not а `bool` type!")
55
+ if not isinstance(hide, bool):
56
+ raise AssertionError("Parameter `hide` - Not а `bool` type!")
57
+ if not isinstance(ignored, bool):
58
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
59
+ if not isinstance(ignored, bool):
60
+ raise AssertionError("Parameter `ignored` - Not а `bool` type!")
61
+ if not isinstance(hint, str):
62
+ raise AssertionError("Parameter `hint` - Not а `str` type!")
63
+ if warning is not None and not isinstance(warning, list):
64
+ raise AssertionError("Parameter `warning` - Not а `list` type!")
65
+ if not isinstance(placeholder, str):
66
+ raise AssertionError("Parameter `placeholder` - Not а `str` type!")
67
+ if not isinstance(required, bool):
68
+ raise AssertionError("Parameter `required` - Not а `bool` type!")
69
+ if not isinstance(readonly, bool):
70
+ raise AssertionError("Parameter `readonly` - Not а `bool` type!")
71
+ if not isinstance(unique, bool):
72
+ raise AssertionError("Parameter `unique` - Not а `bool` type!")
73
+ except AssertionError as err:
74
+ logger.error(str(err))
75
+ raise err
68
76
 
69
77
  Field.__init__(
70
78
  self,