ramifice 0.8.10__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 +58 -51
  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 +36 -35
  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.10.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.10.dist-info/RECORD +0 -84
  83. {ramifice-0.8.10.dist-info → ramifice-0.8.12.dist-info}/WHEEL +0 -0
  84. {ramifice-0.8.10.dist-info → ramifice-0.8.12.dist-info}/licenses/LICENSE +0 -0
ramifice/__init__.py CHANGED
@@ -12,9 +12,24 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- """ORM-like API MongoDB for Python language."""
15
+ """Ramifice - ORM-like API MongoDB for Python language."""
16
+
17
+ __all__ = (
18
+ "model",
19
+ "translations",
20
+ "Migration",
21
+ "Unit",
22
+ )
23
+
24
+ import logging
16
25
 
17
26
  from ramifice.models.decorator import model
18
27
  from ramifice.utils import translations
19
28
  from ramifice.utils.migration import Migration
20
29
  from ramifice.utils.unit import Unit
30
+
31
+ logging.basicConfig(
32
+ level=logging.INFO,
33
+ datefmt="%Y-%m-%d %H:%M:%S",
34
+ format="[%(asctime)s.%(msecs)03d] %(module)10s:%(lineno)-3d %(levelname)-7s - %(message)s",
35
+ )
@@ -1,4 +1,4 @@
1
- """Commons - Model class methods."""
1
+ """Ramifice - Commons - Model class methods."""
2
2
 
3
3
  __all__ = ("QCommonsMixin",)
4
4
 
@@ -16,7 +16,7 @@ class QCommonsMixin(
16
16
  IndexMixin,
17
17
  UnitMixin,
18
18
  ):
19
- """Commons - Model class methods."""
19
+ """Ramifice - Commons - Model class methods."""
20
20
 
21
21
  def __init__(self) -> None: # noqa: D107
22
22
  super().__init__()
@@ -1,4 +1,4 @@
1
- """General purpose query methods."""
1
+ """Ramifice - General purpose query methods."""
2
2
 
3
3
  __all__ = ("GeneralMixin",)
4
4
 
@@ -13,14 +13,14 @@ from ramifice.utils import constants, translations
13
13
 
14
14
 
15
15
  class GeneralMixin:
16
- """General purpose query methods."""
16
+ """Ramifice - General purpose query methods."""
17
17
 
18
18
  @classmethod
19
19
  def from_mongo_doc(
20
20
  cls,
21
21
  mongo_doc: dict[str, Any],
22
22
  ) -> Any:
23
- """Create object instance from Mongo document."""
23
+ """Ramifice - Create object instance from Mongo document."""
24
24
  obj: Any = cls()
25
25
  lang: str = translations.CURRENT_LOCALE
26
26
  for name, data in mongo_doc.items():
@@ -41,7 +41,7 @@ class GeneralMixin:
41
41
  comment: Any | None = None,
42
42
  **kwargs,
43
43
  ) -> int:
44
- """Gets an estimate of the count of documents in a collection using collection metadata."""
44
+ """Ramifice - Gets an estimate of the count of documents in a collection using collection metadata."""
45
45
  # Get collection for current model.
46
46
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
47
47
  #
@@ -58,7 +58,7 @@ class GeneralMixin:
58
58
  comment: Any | None = None,
59
59
  **kwargs,
60
60
  ) -> int:
61
- """Gets an estimate of the count of documents in a collection using collection metadata."""
61
+ """Ramifice - Gets an estimate of the count of documents in a collection using collection metadata."""
62
62
  # Get collection for current model.
63
63
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
64
64
  # Correcting filter.
@@ -81,7 +81,7 @@ class GeneralMixin:
81
81
  comment: Any | None = None,
82
82
  **kwargs,
83
83
  ) -> AsyncCommandCursor:
84
- """Runs an aggregation framework pipeline."""
84
+ """Ramifice - Runs an aggregation framework pipeline."""
85
85
  # Get collection for current model.
86
86
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
87
87
  # Correcting filter.
@@ -106,7 +106,7 @@ class GeneralMixin:
106
106
  hint: Any | None = None,
107
107
  **kwargs,
108
108
  ) -> list[Any]:
109
- """Finds the distinct values for a specified field across a single collection.
109
+ """Ramifice - Finds the distinct values for a specified field across a single collection.
110
110
 
111
111
  Returns an array of unique values for specified field of collection.
112
112
  """
@@ -127,7 +127,7 @@ class GeneralMixin:
127
127
 
128
128
  @classmethod
129
129
  def collection_name(cls) -> str:
130
- """Get collection name."""
130
+ """Ramifice - Get collection name."""
131
131
  # Get collection for current model.
132
132
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
133
133
  #
@@ -135,7 +135,7 @@ class GeneralMixin:
135
135
 
136
136
  @classmethod
137
137
  def collection_full_name(cls) -> str:
138
- """The full name of this AsyncCollection.
138
+ """Ramifice - The full name of this AsyncCollection.
139
139
 
140
140
  The full name is of the form database_name.collection_name.
141
141
  """
@@ -146,7 +146,7 @@ class GeneralMixin:
146
146
 
147
147
  @classmethod
148
148
  def database(cls) -> AsyncDatabase:
149
- """Get AsyncBatabase for the current Model."""
149
+ """Ramifice - Get AsyncBatabase for the current Model."""
150
150
  # Get collection for current model.
151
151
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
152
152
  #
@@ -154,7 +154,7 @@ class GeneralMixin:
154
154
 
155
155
  @classmethod
156
156
  def collection(cls) -> AsyncCollection:
157
- """Get AsyncCollection for the current Model."""
157
+ """Ramifice - Get AsyncCollection for the current Model."""
158
158
  # Get collection for current model.
159
159
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
160
160
  #
@@ -1,4 +1,4 @@
1
- """Indexation documents of collection."""
1
+ """Ramifice - Indexation documents of collection."""
2
2
 
3
3
  __all__ = ("IndexMixin",)
4
4
 
@@ -10,7 +10,7 @@ from ramifice.utils import constants
10
10
 
11
11
 
12
12
  class IndexMixin:
13
- """Indexation documents of collection."""
13
+ """Ramifice - Indexation documents of collection."""
14
14
 
15
15
  @classmethod
16
16
  async def create_index( # type: ignore[no-untyped-def]
@@ -20,7 +20,7 @@ class IndexMixin:
20
20
  comment: Any | None = None,
21
21
  **kwargs,
22
22
  ) -> str:
23
- """Creates an index on this collection."""
23
+ """Ramifice - Creates an index on this collection."""
24
24
  # Get collection for current model.
25
25
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
26
26
  # Create index.
@@ -40,7 +40,7 @@ class IndexMixin:
40
40
  comment: Any | None = None,
41
41
  **kwargs,
42
42
  ) -> None:
43
- """Drops the specified index on this collection."""
43
+ """Ramifice - Drops the specified index on this collection."""
44
44
  # Get collection for current model.
45
45
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
46
46
  # Delete index.
@@ -59,7 +59,7 @@ class IndexMixin:
59
59
  comment: Any | None = None,
60
60
  **kwargs,
61
61
  ) -> list[str]:
62
- """Create one or more indexes on this collection."""
62
+ """Ramifice - Create one or more indexes on this collection."""
63
63
  # Get collection for current model.
64
64
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
65
65
  # Create indexes.
@@ -78,7 +78,7 @@ class IndexMixin:
78
78
  comment: Any | None = None,
79
79
  **kwargs,
80
80
  ) -> None:
81
- """Drops all indexes on this collection."""
81
+ """Ramifice - Drops all indexes on this collection."""
82
82
  # Get collection for current model.
83
83
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
84
84
  # Delete indexes.
@@ -90,7 +90,7 @@ class IndexMixin:
90
90
  session: Any | None = None,
91
91
  comment: Any | None = None,
92
92
  ) -> Any:
93
- """Get information on this collection’s indexes."""
93
+ """Ramifice - Get information on this collection’s indexes."""
94
94
  # Get collection for current model.
95
95
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
96
96
  # Get information.
@@ -103,7 +103,7 @@ class IndexMixin:
103
103
  session: Any | None = None,
104
104
  comment: Any | None = None,
105
105
  ) -> Any:
106
- """Get a cursor over the index documents for this collection."""
106
+ """Ramifice - Get a cursor over the index documents for this collection."""
107
107
  # Get collection for current model.
108
108
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
109
109
  # Get cursor.
ramifice/commons/many.py CHANGED
@@ -1,7 +1,8 @@
1
- """Queries like `find many`."""
1
+ """Ramifice - Queries like `find many`."""
2
2
 
3
3
  __all__ = ("ManyMixin",)
4
4
 
5
+ import logging
5
6
  from typing import Any
6
7
 
7
8
  import orjson
@@ -17,9 +18,11 @@ from ramifice.commons.tools import (
17
18
  from ramifice.utils import constants, translations
18
19
  from ramifice.utils.errors import PanicError
19
20
 
21
+ logger = logging.getLogger(__name__)
22
+
20
23
 
21
24
  class ManyMixin:
22
- """Queries like `find many`."""
25
+ """Ramifice - Queries like `find many`."""
23
26
 
24
27
  @classmethod
25
28
  async def find_many(
@@ -46,7 +49,7 @@ class ManyMixin:
46
49
  session: Any | None = None,
47
50
  allow_disk_use: Any | None = None,
48
51
  ) -> list[dict[str, Any]]:
49
- """Find documents."""
52
+ """Ramifice - Find documents."""
50
53
  # Get collection for current model.
51
54
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
52
55
  # Correcting filter.
@@ -107,7 +110,7 @@ class ManyMixin:
107
110
  session: Any | None = None,
108
111
  allow_disk_use: Any | None = None,
109
112
  ) -> list[dict[str, Any]]:
110
- """Find documents and convert to a raw documents.
113
+ """Ramifice - Find documents and convert to a raw documents.
111
114
 
112
115
  Special changes:
113
116
  _id to str
@@ -184,7 +187,7 @@ class ManyMixin:
184
187
  session: Any | None = None,
185
188
  allow_disk_use: Any | None = None,
186
189
  ) -> str | None:
187
- """Find documents and convert to a json string."""
190
+ """Ramifice - Find documents and convert to a json string."""
188
191
  # Get collection for current model.
189
192
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
190
193
  # Correcting filter.
@@ -239,7 +242,7 @@ class ManyMixin:
239
242
  let: Any | None = None,
240
243
  comment: Any | None = None,
241
244
  ) -> DeleteResult:
242
- """Find documents matching with Model."""
245
+ """Ramifice - Find documents matching with Model."""
243
246
  # Raises a panic if the Model cannot be removed.
244
247
  if not cls.META["is_delete_doc"]:
245
248
  msg = (
@@ -247,6 +250,7 @@ class ManyMixin:
247
250
  + "META param: `is_delete_doc` (False) => "
248
251
  + "Documents of this Model cannot be removed from the database!"
249
252
  )
253
+ logger.error(msg)
250
254
  raise PanicError(msg)
251
255
  # Get collection for current model.
252
256
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
ramifice/commons/one.py CHANGED
@@ -1,7 +1,8 @@
1
- """Requests like `find one`."""
1
+ """Ramifice - Requests like `find one`."""
2
2
 
3
3
  __all__ = ("OneMixin",)
4
4
 
5
+ import logging
5
6
  from typing import Any
6
7
 
7
8
  from pymongo.asynchronous.collection import AsyncCollection
@@ -15,9 +16,11 @@ from ramifice.commons.tools import (
15
16
  from ramifice.utils import constants, translations
16
17
  from ramifice.utils.errors import PanicError
17
18
 
19
+ logger = logging.getLogger(__name__)
20
+
18
21
 
19
22
  class OneMixin:
20
- """Requests like `find one`."""
23
+ """Ramifice - Requests like `find one`."""
21
24
 
22
25
  @classmethod
23
26
  async def find_one(
@@ -26,7 +29,7 @@ class OneMixin:
26
29
  *args: tuple,
27
30
  **kwargs: dict[str, Any],
28
31
  ) -> dict[str, Any] | None:
29
- """Find a single document."""
32
+ """Ramifice - Find a single document."""
30
33
  # Get collection for current model.
31
34
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
32
35
  # Correcting filter.
@@ -48,7 +51,7 @@ class OneMixin:
48
51
  *args: tuple,
49
52
  **kwargs: dict[str, Any],
50
53
  ) -> dict[str, Any] | None:
51
- """Find a single document and converting to raw document."""
54
+ """Ramifice - Find a single document and converting to raw document."""
52
55
  # Get collection for current model.
53
56
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
54
57
  # Correcting filter.
@@ -75,7 +78,7 @@ class OneMixin:
75
78
  *args: tuple,
76
79
  **kwargs: dict[str, Any],
77
80
  ) -> Any | None:
78
- """Find a single document and convert it to a Model instance."""
81
+ """Ramifice - Find a single document and convert it to a Model instance."""
79
82
  # Get collection for current model.
80
83
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
81
84
  # Correcting filter.
@@ -96,7 +99,7 @@ class OneMixin:
96
99
  *args: tuple,
97
100
  **kwargs: dict[str, Any],
98
101
  ) -> str | None:
99
- """Find a single document and convert it to a JSON string."""
102
+ """Ramifice - Find a single document and convert it to a JSON string."""
100
103
  # Get collection for current model.
101
104
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
102
105
  # Correcting filter.
@@ -121,7 +124,7 @@ class OneMixin:
121
124
  let: Any | None = None,
122
125
  comment: Any | None = None,
123
126
  ) -> DeleteResult:
124
- """Find a single document and delete it."""
127
+ """Ramifice - Find a single document and delete it."""
125
128
  # Raises a panic if the Model cannot be removed.
126
129
  if not cls.META["is_delete_doc"]:
127
130
  msg = (
@@ -129,6 +132,7 @@ class OneMixin:
129
132
  + "META param: `is_delete_doc` (False) => "
130
133
  + "Documents of this Model cannot be removed from the database!"
131
134
  )
135
+ logger.error(msg)
132
136
  raise PanicError(msg)
133
137
  # Get collection for current model.
134
138
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
@@ -158,7 +162,7 @@ class OneMixin:
158
162
  comment: Any | None = None,
159
163
  **kwargs: dict[str, Any],
160
164
  ) -> dict[str, Any] | None:
161
- """Find a single document and delete it, return original."""
165
+ """Ramifice - Find a single document and delete it, return original."""
162
166
  # Raises a panic if the Model cannot be removed.
163
167
  if not cls.META["is_delete_doc"]:
164
168
  msg = (
@@ -166,6 +170,7 @@ class OneMixin:
166
170
  + "META param: `is_delete_doc` (False) => "
167
171
  + "Documents of this Model cannot be removed from the database!"
168
172
  )
173
+ logger.error(msg)
169
174
  raise PanicError(msg)
170
175
  # Get collection for current model.
171
176
  collection: AsyncCollection = constants.MONGO_DATABASE[cls.META["collection_name"]]
ramifice/commons/tools.py CHANGED
@@ -1,4 +1,4 @@
1
- """Tool of Commons - A set of auxiliary methods."""
1
+ """Ramifice - Tool of Commons - A set of auxiliary methods."""
2
2
 
3
3
  __all__ = (
4
4
  "correct_mongo_filter",
@@ -15,7 +15,7 @@ from ramifice.utils import translations
15
15
 
16
16
 
17
17
  def correct_mongo_filter(cls_model: Any, filter: Any) -> Any:
18
- """Correcting filter of request.
18
+ """Ramifice - Correcting filter of request.
19
19
 
20
20
  Corrects `TextField` fields that require localization of translation.
21
21
  """
@@ -33,7 +33,7 @@ def password_to_none(
33
33
  field_name_and_type: dict[str, str],
34
34
  mongo_doc: dict[str, Any],
35
35
  ) -> dict[str, Any]:
36
- """Create object instance from Mongo document."""
36
+ """Ramifice - Create object instance from Mongo document."""
37
37
  for f_name, t_name in field_name_and_type.items():
38
38
  if "PasswordField" == t_name:
39
39
  mongo_doc[f_name] = None
@@ -45,7 +45,7 @@ def mongo_doc_to_raw_doc(
45
45
  mongo_doc: dict[str, Any],
46
46
  lang: str,
47
47
  ) -> dict[str, Any]:
48
- """Convert the Mongo document to the raw document.
48
+ """Ramifice - Convert the Mongo document to the raw document.
49
49
 
50
50
  Special changes:
51
51
  _id to str
@@ -1,10 +1,11 @@
1
- """Units Management.
1
+ """Ramifice - Units Management.
2
2
 
3
3
  Management for `choices` parameter in dynamic field types.
4
4
  """
5
5
 
6
6
  __all__ = ("UnitMixin",)
7
7
 
8
+ import logging
8
9
  from typing import Any
9
10
 
10
11
  from pymongo.asynchronous.collection import AsyncCollection
@@ -13,16 +14,18 @@ from ramifice.utils import constants, translations
13
14
  from ramifice.utils.errors import PanicError
14
15
  from ramifice.utils.unit import Unit
15
16
 
17
+ logger = logging.getLogger(__name__)
18
+
16
19
 
17
20
  class UnitMixin:
18
- """Units Management.
21
+ """Ramifice - Units Management.
19
22
 
20
23
  Management for `choices` parameter in dynamic field types.
21
24
  """
22
25
 
23
26
  @classmethod
24
27
  async def unit_manager(cls: Any, unit: Unit) -> None:
25
- """Units Management.
28
+ """Ramifice - Units Management.
26
29
 
27
30
  Management for `choices` parameter in dynamic field types.
28
31
  """
@@ -37,14 +40,18 @@ class UnitMixin:
37
40
  )
38
41
  # Check the presence of a Model state.
39
42
  if model_state is None:
40
- raise PanicError("Error: Model State - Not found!")
43
+ msg = "Error: Model State - Not found!"
44
+ logger.error(msg)
45
+ raise PanicError(msg)
41
46
  # Get language list.
42
47
  lang_list = translations.LANGUAGES
43
48
  # Get clean fields of Unit.
44
49
  unit_field: str = unit.field
45
50
  title = unit.title
46
51
  if len(title) != len(lang_list):
47
- raise PanicError("Unit.title => There are no translations for some languages!")
52
+ msg = "Unit.title => There are no translations for some languages!"
53
+ logger.error(msg)
54
+ raise PanicError(msg)
48
55
  title = {lang: title[lang] for lang in lang_list}
49
56
  target_value = unit.value
50
57
  # Get dynamic field data.
@@ -65,6 +72,7 @@ class UnitMixin:
65
72
  "Error: It is impossible to add unit - "
66
73
  + f"Unit `{title[main_lang]}: {target_value}` is exists!"
67
74
  )
75
+ logger.error(msg)
68
76
  raise PanicError(msg)
69
77
  choices.append({"title": title, "value": target_value})
70
78
  else:
@@ -74,6 +82,7 @@ class UnitMixin:
74
82
  # Delete Unit from Model State.
75
83
  if choices is None:
76
84
  msg = "Error: It is not possible to delete Unit - Units is not exists!"
85
+ logger.error(msg)
77
86
  raise PanicError(msg)
78
87
  if not is_unit_exists:
79
88
  main_lang = translations.DEFAULT_LOCALE
@@ -81,6 +90,7 @@ class UnitMixin:
81
90
  "Error: It is not possible to delete Unit."
82
91
  + f"Unit `{title[main_lang]}: {target_value}` is not exists!"
83
92
  )
93
+ logger.error(msg)
84
94
  raise PanicError(msg)
85
95
  choices = [item for item in choices if item["value"] != target_value]
86
96
  model_state["data_dynamic_fields"][unit_field] = choices or None
@@ -1,4 +1,4 @@
1
- """Available field types."""
1
+ """Ramifice - Available field types."""
2
2
 
3
3
  from ramifice.fields.bool_field import BooleanField
4
4
  from ramifice.fields.choice_float_dyn_field import ChoiceFloatDynField
@@ -1,14 +1,18 @@
1
- """Field of Model for enter boolean value."""
1
+ """Ramifice - Field of Model for enter boolean value."""
2
2
 
3
3
  __all__ = ("BooleanField",)
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 BooleanField(Field, JsonMixin):
11
- """Field of Model for enter boolean value."""
15
+ """Ramifice - Field of Model for enter boolean value."""
12
16
 
13
17
  def __init__( # noqa: D107
14
18
  self,
@@ -21,22 +25,26 @@ class BooleanField(Field, JsonMixin):
21
25
  default: bool = False,
22
26
  ):
23
27
  if constants.DEBUG:
24
- if default is not None and not isinstance(default, bool):
25
- raise AssertionError("Parameter `default` - Not а `bool` type!")
26
- if not isinstance(label, str):
27
- raise AssertionError("Parameter `default` - Not а `str` type!")
28
- if not isinstance(disabled, bool):
29
- raise AssertionError("Parameter `disabled` - Not а `bool` type!")
30
- if not isinstance(hide, bool):
31
- raise AssertionError("Parameter `hide` - Not а `bool` type!")
32
- if not isinstance(ignored, bool):
33
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
34
- if not isinstance(ignored, bool):
35
- raise AssertionError("Parameter `ignored` - Not а `bool` type!")
36
- if not isinstance(hint, str):
37
- raise AssertionError("Parameter `hint` - Not а `str` type!")
38
- if warning is not None and not isinstance(warning, list):
39
- raise AssertionError("Parameter `warning` - Not а `list` type!")
28
+ try:
29
+ if default is not None and not isinstance(default, bool):
30
+ raise AssertionError("Parameter `default` - Not а `bool` type!")
31
+ if not isinstance(label, str):
32
+ raise AssertionError("Parameter `default` - Not а `str` type!")
33
+ if not isinstance(disabled, bool):
34
+ raise AssertionError("Parameter `disabled` - Not а `bool` 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
+ except AssertionError as err:
46
+ logger.error(str(err))
47
+ raise err
40
48
 
41
49
  Field.__init__(
42
50
  self,
@@ -1,18 +1,22 @@
1
- """Field of Model.
1
+ """Ramifice - Field of Model.
2
2
 
3
3
  Type of selective float field with dynamic addition of elements.
4
4
  """
5
5
 
6
6
  __all__ = ("ChoiceFloatDynField",)
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 ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
15
- """Field of Model.
19
+ """Ramifice - Field of Model.
16
20
 
17
21
  Type of selective integer field with dynamic addition of elements.
18
22
  For simulate relationship Many-to-One.
@@ -31,24 +35,28 @@ class ChoiceFloatDynField(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 ChoiceFloatDynField(Field, ChoiceGroup, JsonMixin):
72
80
  self.choices: list[list[float | 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