orionis 0.223.0__py3-none-any.whl → 0.224.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.
orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.223.0"
8
+ VERSION = "0.224.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Optional
3
+
4
+ class IResolver(ABC):
5
+ """
6
+ Interface for a utility class that resolves file and directory paths relative to a base path.
7
+ """
8
+
9
+ @abstractmethod
10
+ def __init__(self, root_path: Optional[str] = None):
11
+ """
12
+ Initializes the resolver with an optional root path.
13
+
14
+ Parameters
15
+ ----------
16
+ root_path : str, optional
17
+ The root directory to resolve relative paths from.
18
+ """
19
+ pass
20
+
21
+ @abstractmethod
22
+ def relativePath(self, relative_path: str):
23
+ """
24
+ Resolves a relative path into an absolute one and validates its existence.
25
+
26
+ Parameters
27
+ ----------
28
+ relative_path : str
29
+ The relative path to resolve.
30
+
31
+ Returns
32
+ -------
33
+ ResolverInterface
34
+ The instance itself for method chaining.
35
+
36
+ Raises
37
+ ------
38
+ FileNotFoundError
39
+ If the resolved path does not exist.
40
+ ValueError
41
+ If the resolved path is neither a file nor a directory.
42
+ """
43
+ pass
44
+
45
+ @abstractmethod
46
+ def toString(self) -> str:
47
+ """
48
+ Returns the resolved path as a string.
49
+
50
+ Returns
51
+ -------
52
+ str
53
+ The resolved path.
54
+ """
55
+ pass
56
+
57
+ @abstractmethod
58
+ def __str__(self) -> str:
59
+ """
60
+ Returns the resolved path as a string (for print or str()).
61
+
62
+ Returns
63
+ -------
64
+ str
65
+ The resolved path.
66
+ """
67
+ pass
@@ -0,0 +1,83 @@
1
+ import os
2
+ from pathlib import Path
3
+ from orionis.luminate.support.paths.contracts.resolver import IResolver
4
+
5
+ class Resolver(IResolver):
6
+ """
7
+ A utility class for resolving file and directory paths relative to the project's root directory.
8
+ """
9
+
10
+ def __init__(self, root_path: str = None):
11
+ """
12
+ Initializes the Resolver instance with the project's root directory.
13
+
14
+ Parameters
15
+ ----------
16
+ root_path : str, optional
17
+ The root directory of the project. If not provided, it defaults to the current working directory.
18
+ """
19
+ self.base_path = Path(root_path).resolve() if root_path else Path(os.getcwd()).resolve()
20
+ self.resolved_path = None
21
+
22
+ def relativePath(self, relative_path: str) -> 'Resolver':
23
+ """
24
+ Resolves a given relative path to an absolute path and validates its existence.
25
+
26
+ This method combines the project's root directory with the provided relative path,
27
+ resolves it to an absolute path, and ensures it exists as either a directory or a file.
28
+
29
+ Parameters
30
+ ----------
31
+ relative_path : str
32
+ The relative path to a directory or file to be resolved.
33
+
34
+ Returns
35
+ -------
36
+ Resolver
37
+ The current instance of the Resolver class with the resolved path.
38
+
39
+ Raises
40
+ ------
41
+ FileNotFoundError
42
+ If the resolved path does not exist.
43
+ ValueError
44
+ If the resolved path is neither a valid directory nor a file.
45
+ """
46
+ # Combine the base path with the relative path and resolve it
47
+ resolved_path = (self.base_path / relative_path).resolve()
48
+
49
+ # Validate that the path exists
50
+ if not resolved_path.exists():
51
+ raise FileNotFoundError(f"The requested path does not exist: {resolved_path}")
52
+
53
+ # Validate that the path is either a directory or a file
54
+ if not (resolved_path.is_dir() or resolved_path.is_file()):
55
+ raise ValueError(f"The requested path is neither a valid directory nor a file: {resolved_path}")
56
+
57
+ # Store the resolved path in the instance variable
58
+ self.resolved_path = resolved_path
59
+
60
+ # Return the current instance
61
+ return self
62
+
63
+ def toString(self) -> str:
64
+ """
65
+ Returns the string representation of the resolved path.
66
+
67
+ Returns
68
+ -------
69
+ str
70
+ The resolved path as a string.
71
+ """
72
+ return str(self.resolved_path)
73
+
74
+ def __str__(self) -> str:
75
+ """
76
+ Returns the string representation of the resolved path.
77
+
78
+ Returns
79
+ -------
80
+ str
81
+ The resolved path as a string.
82
+ """
83
+ return str(self.resolved_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.223.0
3
+ Version: 0.224.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -1,6 +1,6 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/console.py,sha256=4gYWxf0fWYgJ4RKwARvnTPh06FL3GJ6SAZ7R2NzOICw,1342
3
- orionis/framework.py,sha256=3CtL5RE88aY3ytj57zC1hrhgUabiCYcqG9djYM5up1k,1458
3
+ orionis/framework.py,sha256=3F5KZQ8W8qdPtBHjubSoVCZkgsoMLL27SKYH_ao6JwA,1458
4
4
  orionis/installer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orionis/installer/manager.py,sha256=Li4TVziRXWfum02xNG4JHwbnLk-u8xzHjdqKz-D894k,2755
6
6
  orionis/installer/output.py,sha256=7O9qa2xtXMB_4ZvVi-Klneom9YazwygAd_4uYAoxhbU,8548
@@ -162,6 +162,7 @@ orionis/luminate/support/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
162
162
  orionis/luminate/support/adapters/dot_dict.py,sha256=FVHfBuAGTTVMjNG01Fix645fRNKKUMmNx61pYkxPL5c,1253
163
163
  orionis/luminate/support/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
164
  orionis/luminate/support/asynchrony/async_io.py,sha256=IkgVrJnnvNExkhy9brfZpTq2EXptyg3ZB2_ZSH9xDe8,1591
165
+ orionis/luminate/support/asynchrony/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
166
  orionis/luminate/support/asynchrony/contracts/async_coroutine.py,sha256=lwtDa6r7I6qbxzKr5MyJtMRaYW6e5j2dbymEPNaNIEo,614
166
167
  orionis/luminate/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
168
  orionis/luminate/support/inspection/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
@@ -181,6 +182,10 @@ orionis/luminate/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
181
182
  orionis/luminate/support/parsers/exception_parser.py,sha256=6MTeql76c1Muh9Nn-jz2jJdzb9_F7SLdoFjqBD5F8lY,3642
182
183
  orionis/luminate/support/parsers/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
184
  orionis/luminate/support/parsers/contracts/exception_parser.py,sha256=HcWN7nJrvD7xLREPKEnBhyG30IkkAB7Bx_hGpcfb0ZE,912
185
+ orionis/luminate/support/paths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
186
+ orionis/luminate/support/paths/resolver.py,sha256=hsJCY0kvYGqSGuiZL-IdVp2YShiaOvbWKcbwqTHc9X0,2829
187
+ orionis/luminate/support/paths/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
188
+ orionis/luminate/support/paths/contracts/resolver.py,sha256=v7uTgByE2nQS2ZM_b1rtMzY6HH03MNKfAYQoTswPf9o,1627
184
189
  orionis/luminate/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
185
190
  orionis/luminate/support/patterns/singleton.py,sha256=b3U0nubKSQWyal5wTXADVPtOztkaTk-M8Zwy-bje1L0,1425
186
191
  orionis/luminate/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -234,13 +239,15 @@ tests/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
234
239
  tests/support/parsers/test_exception_parser.py,sha256=s-ZRbxyr9bs5uis2SM0IN-vCc-AJhWqRnEMIVgeEFXE,2363
235
240
  tests/support/parsers/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
236
241
  tests/support/parsers/fakes/fake_custom_error.py,sha256=BD8tQPhmIYFYVcaeMpEQ6uK1d6pcU4EGbwRkVfCZp7c,802
242
+ tests/support/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
243
+ tests/support/path/test_resolver.py,sha256=VkHeHu87Hmmq4_mHB6jM8OsjxDyWgB-5E7KGAn-dRe0,1258
237
244
  tests/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
238
245
  tests/support/patterns/test_singleton.py,sha256=U5uwpgGcP7-fIazsnFLwg30mmc24S62udhVIHuL-scY,634
239
246
  tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
240
247
  tests/support/standard/test_std.py,sha256=bJ5LV_OKEEZa_Bk3PTk9Kapk6qECLzcKf0hfR_x2QqM,2042
241
- orionis-0.223.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
242
- orionis-0.223.0.dist-info/METADATA,sha256=J342L_1JSvDAMScCxwplIcVB-v1fh2A_ZiJIj-syD4Q,3003
243
- orionis-0.223.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
244
- orionis-0.223.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
245
- orionis-0.223.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
246
- orionis-0.223.0.dist-info/RECORD,,
248
+ orionis-0.224.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
249
+ orionis-0.224.0.dist-info/METADATA,sha256=VRshDyImo10teazzW8pRZqjFDyKlT0pbXPJArTE2hKM,3003
250
+ orionis-0.224.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
251
+ orionis-0.224.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
252
+ orionis-0.224.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
253
+ orionis-0.224.0.dist-info/RECORD,,
File without changes
@@ -0,0 +1,33 @@
1
+ from orionis.luminate.support.paths.resolver import Resolver
2
+ from orionis.luminate.test.test_case import TestCase
3
+
4
+ class TestsResolver(TestCase):
5
+
6
+ async def testFileNotFound(self):
7
+ """
8
+ Test the Resolver class for a non-existent file path.
9
+ """
10
+ file_path = "non_existent_file.txt"
11
+ with self.assertRaises(FileNotFoundError):
12
+ Resolver().relativePath(file_path)
13
+
14
+ async def testValidFilePath(self):
15
+ """
16
+ Test the Resolver class for a valid file path.
17
+ """
18
+ path = Resolver().relativePath('orionis/luminate/test/test_suite.py').toString()
19
+ self.assertTrue(path.endswith('test_suite.py'))
20
+
21
+ async def testOtherBasePath(self):
22
+ """
23
+ Test the Resolver class for a different base path.
24
+ """
25
+ path = Resolver('orionis/luminate/test').relativePath('test_suite.py').toString()
26
+ self.assertTrue(path.endswith('test_suite.py'))
27
+
28
+ async def testEqualOutputString(self):
29
+ """
30
+ Test the Resolver class for a string representation of the resolved path.
31
+ """
32
+ path = Resolver().relativePath('orionis/luminate/test/test_suite.py')
33
+ self.assertEqual(path.toString(), str(path))