orionis 0.286.0__py3-none-any.whl → 0.288.0__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 (86) hide show
  1. orionis/metadata/framework.py +1 -1
  2. orionis/services/environment/contracts/env.py +45 -50
  3. orionis/services/environment/contracts/types.py +70 -0
  4. orionis/services/environment/dot_env.py +204 -182
  5. orionis/services/environment/env.py +68 -85
  6. orionis/services/{standard/exceptions/path_value_exceptions.py → environment/exceptions/environment_value_error.py} +2 -12
  7. orionis/services/environment/exceptions/environment_value_exception.py +23 -0
  8. orionis/services/environment/types.py +578 -0
  9. orionis/services/paths/exceptions/not_found_exceptions.py +15 -12
  10. orionis/services/paths/exceptions/path_value_exceptions.py +13 -10
  11. orionis/services/standard/contracts/std.py +1 -1
  12. orionis/services/standard/exceptions/std_value_exception.py +23 -0
  13. orionis/services/standard/std.py +2 -2
  14. orionis/services/system/contracts/imports.py +27 -7
  15. orionis/services/system/contracts/workers.py +8 -3
  16. orionis/services/system/imports.py +31 -12
  17. orionis/services/system/runtime_imports.py +33 -23
  18. orionis/services/system/workers.py +6 -8
  19. orionis/services/wrapper/dicts/dot_dict.py +82 -41
  20. orionis/test/logs/history.py +3 -5
  21. orionis/unittesting.py +12 -12
  22. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/METADATA +1 -1
  23. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/RECORD +76 -70
  24. tests/example/test_example.py +5 -2
  25. tests/foundation/config/app/{test_app.py → test_foundation_config_app.py} +14 -4
  26. tests/foundation/config/auth/{test_auth.py → test_foundation_config_auth.py} +10 -5
  27. tests/foundation/config/cache/{test_cache.py → test_foundation_config_cache.py} +61 -16
  28. tests/foundation/config/cache/test_foundation_config_cache_file.py +126 -0
  29. tests/foundation/config/cache/test_foundation_config_cache_stores.py +148 -0
  30. tests/foundation/config/cors/test_foundation_config_cors.py +190 -0
  31. tests/foundation/config/database/{test_database.py → test_foundation_config_database.py} +39 -15
  32. tests/foundation/config/database/{test_database_connections.py → test_foundation_config_database_connections.py} +80 -6
  33. tests/foundation/config/database/{test_database_mysql.py → test_foundation_config_database_mysql.py} +139 -16
  34. tests/foundation/config/database/{test_database_oracle.py → test_foundation_config_database_oracle.py} +111 -27
  35. tests/foundation/config/database/{test_database_pgsql.py → test_foundation_config_database_pgsql.py} +97 -27
  36. tests/foundation/config/database/{test_database_sqlite.py → test_foundation_config_database_sqlite.py} +57 -3
  37. tests/foundation/config/exceptions/{test_exceptions_integrity.py → test_foundation_config_exceptions.py} +45 -11
  38. tests/foundation/config/filesystems/{test_filesystems.py → test_foundation_config_filesystems.py} +65 -15
  39. tests/foundation/config/filesystems/{test_filesystems_aws.py → test_foundation_config_filesystems_aws.py} +46 -8
  40. tests/foundation/config/filesystems/{test_filesystems_disks.py → test_foundation_config_filesystems_disks.py} +79 -9
  41. tests/foundation/config/filesystems/{test_filesystems_local.py → test_foundation_config_filesystems_local.py} +67 -19
  42. tests/foundation/config/filesystems/{test_filesystems_public.py → test_foundation_config_filesystems_public.py} +38 -1
  43. tests/foundation/config/logging/test_foundation_config_logging.py +112 -0
  44. tests/foundation/config/logging/{test_logging_channels.py → test_foundation_config_logging_channels.py} +80 -3
  45. tests/foundation/config/logging/{test_logging_chunked.py → test_foundation_config_logging_chunked.py} +86 -13
  46. tests/foundation/config/logging/{test_logging_daily.py → test_foundation_config_logging_daily.py} +80 -13
  47. tests/foundation/config/logging/{test_logging_hourly.py → test_foundation_config_logging_hourly.py} +69 -3
  48. tests/foundation/config/logging/{test_logging_monthly.py → test_foundation_config_logging_monthly.py} +49 -3
  49. tests/foundation/config/logging/{test_logging_stack.py → test_foundation_config_logging_stack.py} +50 -15
  50. tests/foundation/config/logging/{test_logging_weekly.py → test_foundation_config_logging_weekly.py} +93 -3
  51. tests/foundation/config/mail/test_foundation_config_mail.py +145 -0
  52. tests/foundation/config/mail/{test_mail_file.py → test_foundation_config_mail_file.py} +41 -5
  53. tests/foundation/config/mail/test_foundation_config_mail_mailers.py +106 -0
  54. tests/foundation/config/mail/{test_mail_smtp.py → test_foundation_config_mail_smtp.py} +59 -15
  55. tests/foundation/config/queue/test_foundation_config_queue.py +111 -0
  56. tests/foundation/config/queue/{test_queue_brokers.py → test_foundation_config_queue_brokers.py} +28 -11
  57. tests/foundation/config/queue/{test_queue_database.py → test_foundation_config_queue_database.py} +54 -16
  58. tests/foundation/config/root/{test_root_paths.py → test_foundation_config_root_paths.py} +70 -3
  59. tests/foundation/config/session/{test_session.py → test_foundation_config_session.py} +31 -2
  60. tests/foundation/config/startup/{test_config_startup.py → test_foundation_config_startup.py} +91 -21
  61. tests/foundation/config/testing/{test_testing.py → test_foundation_config_testing.py} +69 -1
  62. tests/patterns/singleton/test_patterns_singleton.py +27 -0
  63. tests/services/asynchrony/{test_async_io.py → test_services_asynchrony_coroutine.py} +1 -1
  64. tests/services/environment/test_services_environment.py +93 -0
  65. tests/services/path/{test_resolver.py → test_services_resolver.py} +51 -12
  66. tests/services/standard/{test_std.py → test_services_std.py} +45 -22
  67. tests/services/system/__init__.py +0 -0
  68. tests/services/system/test_services_system_imports.py +101 -0
  69. tests/services/system/test_services_system_workers.py +89 -0
  70. tests/services/wrapper/{test_wrapper_doc_dict.py → test_services_wrapper_docdict.py} +28 -16
  71. tests/testing/test_testing_result.py +57 -20
  72. tests/testing/test_testing_unit.py +110 -41
  73. orionis/services/environment/exceptions/value_exception.py +0 -27
  74. tests/foundation/config/cache/test_cache_file.py +0 -78
  75. tests/foundation/config/cache/test_cache_stores.py +0 -88
  76. tests/foundation/config/cors/test_cors.py +0 -121
  77. tests/foundation/config/logging/test_logging.py +0 -48
  78. tests/foundation/config/mail/test_mail.py +0 -73
  79. tests/foundation/config/mail/test_mail_mailers.py +0 -58
  80. tests/foundation/config/queue/test_queue.py +0 -58
  81. tests/patterns/singleton/test_singleton.py +0 -18
  82. tests/services/environment/test_env.py +0 -155
  83. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/WHEEL +0 -0
  84. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/licenses/LICENCE +0 -0
  85. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/top_level.txt +0 -0
  86. {orionis-0.286.0.dist-info → orionis-0.288.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,578 @@
1
+ from orionis.services.environment.contracts.types import IEnvTypes
2
+ from orionis.services.environment.exceptions.environment_value_error import OrionisEnvironmentValueError
3
+ from orionis.services.environment.exceptions.environment_value_exception import OrionisEnvironmentValueException
4
+
5
+ class EnvTypes(IEnvTypes):
6
+
7
+ # Type class to handle different types of environment variables
8
+ OPTIONS = {
9
+ 'path',
10
+ 'str',
11
+ 'int',
12
+ 'float',
13
+ 'bool',
14
+ 'list',
15
+ 'dict',
16
+ 'tuple',
17
+ 'set'
18
+ }
19
+
20
+ @staticmethod
21
+ def options() -> set:
22
+ """
23
+ Returns the set of valid type hints that can be used with this Type class.
24
+
25
+ Returns
26
+ -------
27
+ set
28
+ A set containing the valid type hints.
29
+ """
30
+ return EnvTypes.OPTIONS
31
+
32
+ def __init__(self, raw):
33
+ """
34
+ Parse a raw string input into a type hint and value string.
35
+
36
+ Parameters
37
+ ----------
38
+ raw : str, optional
39
+ String that may contain a type hint and value separated by a colon (e.g., "int: 42").
40
+ If a colon is present, the part before the colon is treated as the type hint and the part after as the value.
41
+ If no colon is present, the entire string is treated as the value with no type hint.
42
+
43
+ Attributes
44
+ ----------
45
+ __type_hint : str or None
46
+ The extracted type hint in lowercase, or None if not provided.
47
+ __value_str : str or None
48
+ The extracted value string, or None if not provided.
49
+ """
50
+
51
+ # Default values for type hint and value string
52
+ self.__type_hint = None
53
+ self.__value_raw = None
54
+
55
+ # If raw is a string, parse it to extract type hint and value
56
+ if isinstance(raw, str):
57
+
58
+ # Strip whitespace and check for a colon to separate type hint and value
59
+ self.__value_raw = raw.strip()
60
+
61
+ # If a colon is present, split the string into type hint and value
62
+ if ':' in self.__value_raw:
63
+
64
+ # Split the string at the first colon
65
+ type_hint, value_str = raw.split(':', 1)
66
+
67
+ # If the type hint is valid, set it and the value
68
+ if type_hint.strip().lower() in self.OPTIONS:
69
+ self.__type_hint = type_hint.strip().lower()
70
+ self.__value_raw = value_str.strip() if value_str else None
71
+ else:
72
+
73
+ # If raw is not a string, treat it as a value with no type hint
74
+ self.__value_raw = raw
75
+
76
+ def to(self, type_hint: str):
77
+ """
78
+ Set the type hint for the Type instance.
79
+
80
+ Parameters
81
+ ----------
82
+ type_hint : str
83
+ The type hint to set, which must be one of the valid options defined in OPTIONS.
84
+
85
+ Raises
86
+ ------
87
+ OrionisEnvironmentValueError
88
+ If the provided type hint is not one of the valid options.
89
+ """
90
+
91
+ # Validate and set the type hint
92
+ type_hint = type_hint.strip().lower()
93
+ if type_hint not in self.OPTIONS:
94
+ raise OrionisEnvironmentValueError(f"Invalid type hint: {type_hint}. Must be one of {self.OPTIONS}.")
95
+ self.__type_hint = type_hint
96
+
97
+ # Parse the value to the specified type hint
98
+ if self.__type_hint == 'path':
99
+ return self.__toPath()
100
+
101
+ if self.__type_hint == 'str':
102
+ return self.__toStr()
103
+
104
+ if self.__type_hint == 'int':
105
+ return self.__toInt()
106
+
107
+ if self.__type_hint == 'float':
108
+ return self.__toFloat()
109
+
110
+ if self.__type_hint == 'bool':
111
+ return self.__toBool()
112
+
113
+ if self.__type_hint == 'list':
114
+ return self.__toList()
115
+
116
+ if self.__type_hint == 'dict':
117
+ return self.__toDict()
118
+
119
+ if self.__type_hint == 'tuple':
120
+ return self.__toTuple()
121
+
122
+ if self.__type_hint == 'set':
123
+ return self.__toSet()
124
+
125
+ def hasValidTypeHint(self) -> bool:
126
+ """
127
+ Check if the type hint is valid.
128
+
129
+ Returns
130
+ -------
131
+ bool
132
+ True if the type hint is valid (exists in the OPTIONS set), False otherwise.
133
+ """
134
+ return self.__type_hint in self.OPTIONS
135
+
136
+ def explode(self) -> tuple:
137
+ """
138
+ Returns a tuple containing the type hint and value string.
139
+
140
+ Returns
141
+ -------
142
+ tuple
143
+ A tuple (type_hint, value_str) where:
144
+ type_hint : str or None
145
+ The extracted type hint in lowercase, or None if not provided.
146
+ value_str : str or None
147
+ The extracted value string, or None if not provided.
148
+ """
149
+ return self.__type_hint, self.__value_raw
150
+
151
+ def __parsePath(self):
152
+ """
153
+ Returns the value as a string, assuming the type hint is 'path:'.
154
+
155
+ Parameters
156
+ ----------
157
+ None
158
+
159
+ Returns
160
+ -------
161
+ str
162
+ The value string with backslashes replaced by forward slashes, if the type hint is 'path:'.
163
+
164
+ Raises
165
+ ------
166
+ OrionisEnvironmentValueException
167
+ If the value cannot be processed as a path.
168
+ """
169
+ return self.__value_raw.replace('\\', '/').strip()
170
+
171
+ def __toPath(self):
172
+ """
173
+ Converts the internal string value to a formatted path string.
174
+
175
+ Returns
176
+ -------
177
+ str
178
+ A string representing the type hint and the value, with backslashes replaced by forward slashes.
179
+
180
+ Raises
181
+ ------
182
+ OrionisEnvironmentValueError
183
+ If the internal value is not a string.
184
+ """
185
+ if not isinstance(self.__value_raw, str):
186
+ raise OrionisEnvironmentValueError(f"Value must be a string to convert to path, got {type(self.__value_raw).__name__} instead.")
187
+ value = self.__value_raw.replace('\\', '/').strip()
188
+ return f"{self.__type_hint}:{value}"
189
+
190
+ def __parseStr(self):
191
+ """
192
+ Returns the value as a string, assuming the type hint is 'str:'.
193
+
194
+ Returns
195
+ -------
196
+ str
197
+ The value string if the type hint is 'str:', otherwise raises an error.
198
+ """
199
+ return self.__value_raw.strip()
200
+
201
+ def __toStr(self):
202
+ """
203
+ Converts the internal value to a string representation.
204
+
205
+ Returns
206
+ -------
207
+ str
208
+ A string representing the type hint and the value.
209
+
210
+ Raises
211
+ ------
212
+ OrionisEnvironmentValueError
213
+ If the internal value is not a string.
214
+ """
215
+ if not isinstance(self.__value_raw, str):
216
+ raise OrionisEnvironmentValueError(f"Value must be a string to convert to str, got {type(self.__value_raw).__name__} instead.")
217
+ return f"{self.__type_hint}:{self.__value_raw}"
218
+
219
+ def __parseInt(self):
220
+ """
221
+ Returns the value as an integer, assuming the type hint is 'int:'.
222
+
223
+ Parameters
224
+ ----------
225
+ None
226
+
227
+ Returns
228
+ -------
229
+ int
230
+ The value converted to an integer if the type hint is 'int:'.
231
+
232
+ Raises
233
+ ------
234
+ OrionisEnvironmentValueException
235
+ If the value cannot be converted to an integer.
236
+ """
237
+ value = self.__value_raw.strip()
238
+ try:
239
+ return int(value)
240
+ except ValueError as e:
241
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to int: {str(e)}")
242
+
243
+ def __toInt(self):
244
+ """
245
+ Converts the internal value to an integer representation.
246
+
247
+ Returns
248
+ -------
249
+ str
250
+ A string representing the type hint and the value as an integer.
251
+
252
+ Raises
253
+ ------
254
+ OrionisEnvironmentValueError
255
+ If the internal value is not a string or cannot be converted to an integer.
256
+ """
257
+ if not isinstance(self.__value_raw, int):
258
+ raise OrionisEnvironmentValueError(f"Value must be an integer to convert to int, got {type(self.__value_raw).__name__} instead.")
259
+ return f"{self.__type_hint}:{str(self.__value_raw)}"
260
+
261
+ def __parseFloat(self):
262
+ """
263
+ Returns the value as a float, assuming the type hint is 'float:'.
264
+
265
+ Parameters
266
+ ----------
267
+ None
268
+
269
+ Returns
270
+ -------
271
+ float
272
+ The value converted to a float if the type hint is 'float:'.
273
+
274
+ Raises
275
+ ------
276
+ OrionisEnvironmentValueException
277
+ If the value cannot be converted to a float.
278
+ """
279
+ value = self.__value_raw.strip()
280
+ try:
281
+ return float(value)
282
+ except ValueError as e:
283
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to float: {str(e)}")
284
+
285
+ def __toFloat(self):
286
+ """
287
+ Converts the internal value to a float representation.
288
+
289
+ Returns
290
+ -------
291
+ str
292
+ A string representing the type hint and the value as a float.
293
+
294
+ Raises
295
+ ------
296
+ OrionisEnvironmentValueError
297
+ If the internal value is not a string or cannot be converted to a float.
298
+ """
299
+ if not isinstance(self.__value_raw, float):
300
+ raise OrionisEnvironmentValueError(f"Value must be a float to convert to float, got {type(self.__value_raw).__name__} instead.")
301
+ return f"{self.__type_hint}:{str(self.__value_raw)}"
302
+
303
+ def __parseBool(self):
304
+ """
305
+ Returns the value as a boolean, assuming the type hint is 'bool:'.
306
+
307
+ Parameters
308
+ ----------
309
+ None
310
+
311
+ Returns
312
+ -------
313
+ bool
314
+ The value converted to a boolean if the type hint is 'bool:'.
315
+
316
+ Raises
317
+ ------
318
+ OrionisEnvironmentValueException
319
+ If the value cannot be converted to a boolean.
320
+ """
321
+ value = self.__value_raw.strip().lower()
322
+ if value in {'true', '1', 'yes', 'on'}:
323
+ return True
324
+ elif value in {'false', '0', 'no', 'off'}:
325
+ return False
326
+ else:
327
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to bool.")
328
+
329
+ def __toBool(self):
330
+ """
331
+ Converts the internal value to a boolean representation.
332
+
333
+ Returns
334
+ -------
335
+ str
336
+ A string representing the type hint and the value as a boolean.
337
+
338
+ Raises
339
+ ------
340
+ OrionisEnvironmentValueError
341
+ If the internal value is not a boolean.
342
+ """
343
+ if not isinstance(self.__value_raw, bool):
344
+ raise OrionisEnvironmentValueError(f"Value must be a boolean to convert to bool, got {type(self.__value_raw).__name__} instead.")
345
+ return f"{self.__type_hint}:{str(self.__value_raw).lower()}"
346
+
347
+ def __parseList(self):
348
+ """
349
+ Returns the value as a list, assuming the type hint is 'list:'.
350
+
351
+ Returns
352
+ -------
353
+ list
354
+ The value converted to a list if the type hint is 'list:'.
355
+
356
+ Raises
357
+ ------
358
+ OrionisEnvironmentValueException
359
+ If the value cannot be converted to a list.
360
+ """
361
+ import ast
362
+
363
+ value = self.__value_raw.strip()
364
+ try:
365
+ parsed = ast.literal_eval(value)
366
+ if not isinstance(parsed, list):
367
+ raise ValueError("Value is not a list")
368
+ return parsed
369
+ except (ValueError, SyntaxError) as e:
370
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to list: {str(e)}")
371
+
372
+ def __toList(self):
373
+ """
374
+ Converts the internal value to a list representation.
375
+
376
+ Returns
377
+ -------
378
+ str
379
+ A string representing the type hint and the value as a list.
380
+
381
+ Raises
382
+ ------
383
+ OrionisEnvironmentValueError
384
+ If the internal value is not a list.
385
+ """
386
+ if not isinstance(self.__value_raw, list):
387
+ raise OrionisEnvironmentValueError(f"Value must be a list to convert to list, got {type(self.__value_raw).__name__} instead.")
388
+ return f"{self.__type_hint}:{repr(self.__value_raw)}"
389
+
390
+ def __parseDict(self):
391
+ """
392
+ Returns the value as a dict, assuming the type hint is 'dict:'.
393
+
394
+ Parameters
395
+ ----------
396
+ None
397
+
398
+ Returns
399
+ -------
400
+ dict
401
+ The value converted to a dict if the type hint is 'dict:'.
402
+
403
+ Raises
404
+ ------
405
+ OrionisEnvironmentValueException
406
+ If the value cannot be converted to a dict.
407
+ """
408
+ import ast
409
+
410
+ value = self.__value_raw.strip()
411
+ try:
412
+ parsed = ast.literal_eval(value)
413
+ if not isinstance(parsed, dict):
414
+ raise ValueError("Value is not a dict")
415
+ return parsed
416
+ except (ValueError, SyntaxError) as e:
417
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to dict: {str(e)}")
418
+
419
+ def __toDict(self):
420
+ """
421
+ Converts the internal value to a dict representation.
422
+
423
+ Returns
424
+ -------
425
+ str
426
+ A string representing the type hint and the value as a dict.
427
+
428
+ Raises
429
+ ------
430
+ OrionisEnvironmentValueError
431
+ If the internal value is not a dict.
432
+ """
433
+ if not isinstance(self.__value_raw, dict):
434
+ raise OrionisEnvironmentValueError(f"Value must be a dict to convert to dict, got {type(self.__value_raw).__name__} instead.")
435
+ return f"{self.__type_hint}:{repr(self.__value_raw)}"
436
+
437
+ def __parseTuple(self):
438
+ """
439
+ Returns the value as a tuple, assuming the type hint is 'tuple:'.
440
+
441
+ Parameters
442
+ ----------
443
+ None
444
+
445
+ Returns
446
+ -------
447
+ tuple
448
+ The value converted to a tuple if the type hint is 'tuple:'.
449
+
450
+ Raises
451
+ ------
452
+ OrionisEnvironmentValueException
453
+ If the value cannot be converted to a tuple.
454
+ """
455
+ import ast
456
+
457
+ value = self.__value_raw.strip()
458
+ try:
459
+ parsed = ast.literal_eval(value)
460
+ if not isinstance(parsed, tuple):
461
+ raise ValueError("Value is not a tuple")
462
+ return parsed
463
+ except (ValueError, SyntaxError) as e:
464
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to tuple: {str(e)}")
465
+
466
+ def __toTuple(self):
467
+ """
468
+ Converts the internal value to a tuple representation.
469
+
470
+ Returns
471
+ -------
472
+ str
473
+ A string representing the type hint and the value as a tuple.
474
+
475
+ Raises
476
+ ------
477
+ OrionisEnvironmentValueError
478
+ If the internal value is not a tuple.
479
+ """
480
+ if not isinstance(self.__value_raw, tuple):
481
+ raise OrionisEnvironmentValueError(f"Value must be a tuple to convert to tuple, got {type(self.__value_raw).__name__} instead.")
482
+ return f"{self.__type_hint}:{repr(self.__value_raw)}"
483
+
484
+ def __parseSet(self):
485
+ """
486
+ Returns the value as a set, assuming the type hint is 'set:'.
487
+
488
+ Parameters
489
+ ----------
490
+ None
491
+
492
+ Returns
493
+ -------
494
+ set
495
+ The value converted to a set if the type hint is 'set:'.
496
+
497
+ Raises
498
+ ------
499
+ OrionisEnvironmentValueException
500
+ If the value cannot be converted to a set.
501
+ """
502
+ import ast
503
+
504
+ value = self.__value_raw.strip()
505
+ try:
506
+ parsed = ast.literal_eval(value)
507
+ if not isinstance(parsed, set):
508
+ raise ValueError("Value is not a set")
509
+ return parsed
510
+ except (ValueError, SyntaxError) as e:
511
+ raise OrionisEnvironmentValueException(f"Cannot convert '{value}' to set: {str(e)}")
512
+
513
+ def __toSet(self):
514
+ """
515
+ Converts the internal value to a set representation.
516
+
517
+ Returns
518
+ -------
519
+ str
520
+ A string representing the type hint and the value as a set.
521
+
522
+ Raises
523
+ ------
524
+ OrionisEnvironmentValueError
525
+ If the internal value is not a set.
526
+ """
527
+ if not isinstance(self.__value_raw, set):
528
+ raise OrionisEnvironmentValueError(f"Value must be a set to convert to set, got {type(self.__value_raw).__name__} instead.")
529
+ return f"{self.__type_hint}:{repr(self.__value_raw)}"
530
+
531
+ def get(self):
532
+ """
533
+ Returns the value corresponding to the specified type hint.
534
+
535
+ Checks if the provided type hint is valid and then dispatches the call to the appropriate
536
+ method for handling the type.
537
+
538
+ Supported type hints include: 'path:', 'str:', 'int:', 'float:', 'bool:', 'list:', 'dict:', 'tuple:', and 'set:'.
539
+
540
+ Returns
541
+ -------
542
+ Any
543
+ The value converted or processed according to the specified type hint.
544
+
545
+ Raises
546
+ ------
547
+ OrionisEnvironmentValueError
548
+ If the type hint is not one of the supported options.
549
+ """
550
+ if not self.__type_hint in self.OPTIONS:
551
+ raise OrionisEnvironmentValueError(f"Invalid type hint: {self.__type_hint}. Must be one of {self.OPTIONS}.")
552
+
553
+ if self.__type_hint == 'path':
554
+ return self.__parsePath()
555
+
556
+ if self.__type_hint == 'str':
557
+ return self.__parseStr()
558
+
559
+ if self.__type_hint == 'int':
560
+ return self.__parseInt()
561
+
562
+ if self.__type_hint == 'float':
563
+ return self.__parseFloat()
564
+
565
+ if self.__type_hint == 'bool':
566
+ return self.__parseBool()
567
+
568
+ if self.__type_hint == 'list':
569
+ return self.__parseList()
570
+
571
+ if self.__type_hint == 'dict':
572
+ return self.__parseDict()
573
+
574
+ if self.__type_hint == 'tuple':
575
+ return self.__parseTuple()
576
+
577
+ if self.__type_hint == 'set':
578
+ return self.__parseSet()
@@ -1,28 +1,31 @@
1
1
  class OrionisFileNotFoundException(Exception):
2
2
  """
3
- Exception raised when a file is not found in the Orionis framework.
3
+ Exception raised when a specified file is not found.
4
4
 
5
- Args:
6
- msg (str): A detailed message describing the missing file.
7
-
8
- Example:
9
- raise OrionisFileNotFoundException("File 'config.yaml' not found.")
5
+ Parameters
6
+ ----------
7
+ msg : str
8
+ The error message describing the exception.
10
9
  """
11
10
 
12
11
  def __init__(self, msg: str):
13
12
  """
14
- Initializes the exception with a custom error message.
13
+ Initialize the exception with a custom error message.
15
14
 
16
- Args:
17
- msg (str): The error message describing the exception.
15
+ Parameters
16
+ ----------
17
+ msg : str
18
+ The error message describing the exception.
18
19
  """
19
20
  super().__init__(msg)
20
21
 
21
22
  def __str__(self) -> str:
22
23
  """
23
- Return a string representation of the exception, including the class name and the first argument.
24
+ Return a string representation of the exception.
24
25
 
25
- Returns:
26
- str: A formatted string with the exception class name and the first argument.
26
+ Returns
27
+ -------
28
+ str
29
+ A formatted string with the exception class name and the first argument.
27
30
  """
28
31
  return f"{self.__class__.__name__}: {self.args[0]}"
@@ -2,19 +2,20 @@ class OrionisPathValueException(Exception):
2
2
  """
3
3
  Exception raised when a file is not found in the Orionis framework.
4
4
 
5
- Args:
6
- msg (str): A detailed message describing the missing file.
7
-
8
- Example:
9
- raise OrionisFileNotFoundException("File 'config.yaml' not found.")
5
+ Parameters
6
+ ----------
7
+ msg : str
8
+ A detailed message describing the missing file.
10
9
  """
11
10
 
12
11
  def __init__(self, msg: str):
13
12
  """
14
- Initializes the exception with a custom error message.
13
+ Initialize the exception with a custom error message.
15
14
 
16
- Args:
17
- msg (str): The error message describing the exception.
15
+ Parameters
16
+ ----------
17
+ msg : str
18
+ The error message describing the exception.
18
19
  """
19
20
  super().__init__(msg)
20
21
 
@@ -22,7 +23,9 @@ class OrionisPathValueException(Exception):
22
23
  """
23
24
  Return a string representation of the exception, including the class name and the first argument.
24
25
 
25
- Returns:
26
- str: A formatted string with the exception class name and the first argument.
26
+ Returns
27
+ -------
28
+ str
29
+ A formatted string with the exception class name and the first argument.
27
30
  """
28
31
  return f"{self.__class__.__name__}: {self.args[0]}"
@@ -110,7 +110,7 @@ class IStdClass(ABC):
110
110
 
111
111
  @classmethod
112
112
  @abstractmethod
113
- def from_dict(cls, dictionary: Dict[str, Any]) -> 'IStdClass':
113
+ def fromDict(cls, dictionary: Dict[str, Any]) -> 'IStdClass':
114
114
  """
115
115
  Creates an instance from a dictionary.
116
116
 
@@ -0,0 +1,23 @@
1
+ class OrionisStdValueException(Exception):
2
+
3
+ def __init__(self, msg: str):
4
+ """
5
+ Initialize the exception with a custom error message.
6
+
7
+ Parameters
8
+ ----------
9
+ msg : str
10
+ The error message describing the exception.
11
+ """
12
+ super().__init__(msg)
13
+
14
+ def __str__(self) -> str:
15
+ """
16
+ Return a string representation of the exception, including the class name and the first argument.
17
+
18
+ Returns
19
+ -------
20
+ str
21
+ A formatted string with the exception class name and the first argument.
22
+ """
23
+ return f"{self.__class__.__name__}: {self.args[0]}"