orionis 0.443.0__py3-none-any.whl → 0.445.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/console/args/argument.py +343 -0
- orionis/console/args/enums/actions.py +43 -0
- orionis/console/commands/version.py +19 -4
- orionis/foundation/application.py +0 -2
- orionis/foundation/providers/testing_provider.py +39 -2
- orionis/metadata/framework.py +1 -1
- orionis/test/core/unit_test.py +134 -5
- orionis/test/kernel.py +30 -83
- orionis/test/validators/workers.py +2 -2
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/METADATA +1 -1
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/RECORD +19 -27
- tests/example/test_example.py +163 -173
- orionis/foundation/providers/path_resolver_provider.py +0 -43
- orionis/services/paths/contracts/__init__.py +0 -0
- orionis/services/paths/contracts/resolver.py +0 -51
- orionis/services/paths/exceptions/__init__.py +0 -7
- orionis/services/paths/exceptions/exception.py +0 -19
- orionis/services/paths/exceptions/file.py +0 -19
- orionis/services/paths/resolver.py +0 -95
- orionis/support/facades/path_resolver.py +0 -15
- tests/services/path/__init__.py +0 -0
- tests/services/path/test_services_resolver.py +0 -112
- /orionis/console/{arguments → args}/__init__.py +0 -0
- /orionis/{services/paths → console/args/enums}/__init__.py +0 -0
- /orionis/console/{arguments → args}/parser.py +0 -0
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/WHEEL +0 -0
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/top_level.txt +0 -0
- {orionis-0.443.0.dist-info → orionis-0.445.0.dist-info}/zip-safe +0 -0
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from orionis.services.paths.contracts.resolver import IResolver
|
|
4
|
-
from orionis.services.paths.exceptions import (
|
|
5
|
-
OrionisFileNotFoundException,
|
|
6
|
-
OrionisPathValueException
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
class Resolver(IResolver):
|
|
10
|
-
|
|
11
|
-
def __init__(self, root_path: str = None):
|
|
12
|
-
"""
|
|
13
|
-
Initializes the Resolver instance with the project's root directory.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
root_path : str, optional
|
|
18
|
-
The root directory of the project. If not provided, it defaults to the current working directory.
|
|
19
|
-
"""
|
|
20
|
-
self.base_path = Path(root_path).resolve() if root_path else Path(os.getcwd()).resolve()
|
|
21
|
-
self.resolved_path = None
|
|
22
|
-
|
|
23
|
-
def relativePath(self, relative_path: str) -> 'Resolver':
|
|
24
|
-
"""
|
|
25
|
-
Resolves a given relative path to an absolute path and validates its existence.
|
|
26
|
-
|
|
27
|
-
This method combines the project's root directory with the provided relative path,
|
|
28
|
-
resolves it to an absolute path, and ensures it exists as either a directory or a file.
|
|
29
|
-
|
|
30
|
-
Parameters
|
|
31
|
-
----------
|
|
32
|
-
relative_path : str
|
|
33
|
-
The relative path to a directory or file to be resolved.
|
|
34
|
-
|
|
35
|
-
Returns
|
|
36
|
-
-------
|
|
37
|
-
Resolver
|
|
38
|
-
The current instance of the Resolver class with the resolved path.
|
|
39
|
-
|
|
40
|
-
Raises
|
|
41
|
-
------
|
|
42
|
-
OrionisFileNotFoundException
|
|
43
|
-
If the resolved path does not exist.
|
|
44
|
-
OrionisPathValueException
|
|
45
|
-
If the resolved path is neither a valid directory nor a file.
|
|
46
|
-
"""
|
|
47
|
-
# Combine the base path with the relative path and resolve it
|
|
48
|
-
resolved_path = (self.base_path / relative_path).resolve()
|
|
49
|
-
|
|
50
|
-
# Validate that the path exists
|
|
51
|
-
if not resolved_path.exists():
|
|
52
|
-
raise OrionisFileNotFoundException(f"The requested path does not exist: {resolved_path}")
|
|
53
|
-
|
|
54
|
-
# Validate that the path is either a directory or a file
|
|
55
|
-
if not (resolved_path.is_dir() or resolved_path.is_file()):
|
|
56
|
-
raise OrionisPathValueException(f"The requested path is neither a valid directory nor a file: {resolved_path}")
|
|
57
|
-
|
|
58
|
-
# Store the resolved path in the instance variable
|
|
59
|
-
self.resolved_path = resolved_path
|
|
60
|
-
|
|
61
|
-
# Return the current instance
|
|
62
|
-
return self
|
|
63
|
-
|
|
64
|
-
def toString(self) -> str:
|
|
65
|
-
"""
|
|
66
|
-
Returns the string representation of the resolved path.
|
|
67
|
-
|
|
68
|
-
Returns
|
|
69
|
-
-------
|
|
70
|
-
str
|
|
71
|
-
The resolved path as a string.
|
|
72
|
-
"""
|
|
73
|
-
return str(self.resolved_path)
|
|
74
|
-
|
|
75
|
-
def get(self) -> Path:
|
|
76
|
-
"""
|
|
77
|
-
Returns the resolved path as a Path object.
|
|
78
|
-
|
|
79
|
-
Returns
|
|
80
|
-
-------
|
|
81
|
-
Path
|
|
82
|
-
The resolved path.
|
|
83
|
-
"""
|
|
84
|
-
return self.resolved_path
|
|
85
|
-
|
|
86
|
-
def __str__(self) -> str:
|
|
87
|
-
"""
|
|
88
|
-
Returns the string representation of the resolved path.
|
|
89
|
-
|
|
90
|
-
Returns
|
|
91
|
-
-------
|
|
92
|
-
str
|
|
93
|
-
The resolved path as a string.
|
|
94
|
-
"""
|
|
95
|
-
return str(self.resolved_path)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
from orionis.container.facades.facade import Facade
|
|
2
|
-
|
|
3
|
-
class PathResolver(Facade):
|
|
4
|
-
|
|
5
|
-
@classmethod
|
|
6
|
-
def getFacadeAccessor(cls):
|
|
7
|
-
"""
|
|
8
|
-
Returns the binding key for the path resolver service in the container.
|
|
9
|
-
|
|
10
|
-
Returns
|
|
11
|
-
-------
|
|
12
|
-
str
|
|
13
|
-
The unique string identifier for the path resolver service, used by the service container.
|
|
14
|
-
"""
|
|
15
|
-
return "core.orionis.path_resolver"
|
tests/services/path/__init__.py
DELETED
|
File without changes
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import tempfile
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from orionis.services.paths.exceptions import OrionisFileNotFoundException
|
|
5
|
-
from orionis.services.paths.resolver import Resolver
|
|
6
|
-
from orionis.test.cases.asynchronous import AsyncTestCase
|
|
7
|
-
|
|
8
|
-
class TestServicesResolver(AsyncTestCase):
|
|
9
|
-
|
|
10
|
-
async def testFileNotFound(self):
|
|
11
|
-
"""
|
|
12
|
-
Test that resolving a non-existent file path raises OrionisFileNotFoundException.
|
|
13
|
-
|
|
14
|
-
Returns
|
|
15
|
-
-------
|
|
16
|
-
None
|
|
17
|
-
|
|
18
|
-
Raises
|
|
19
|
-
------
|
|
20
|
-
OrionisFileNotFoundException
|
|
21
|
-
If the file does not exist.
|
|
22
|
-
"""
|
|
23
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
24
|
-
resolver = Resolver(tmpdir)
|
|
25
|
-
non_existent = "does_not_exist.txt"
|
|
26
|
-
with self.assertRaises(OrionisFileNotFoundException):
|
|
27
|
-
resolver.relativePath(non_existent)
|
|
28
|
-
|
|
29
|
-
async def testValidFilePath(self):
|
|
30
|
-
"""
|
|
31
|
-
Test that resolving a valid file path returns the correct absolute path.
|
|
32
|
-
|
|
33
|
-
Returns
|
|
34
|
-
-------
|
|
35
|
-
None
|
|
36
|
-
|
|
37
|
-
Asserts
|
|
38
|
-
-------
|
|
39
|
-
The resolved path ends with the file name and is absolute.
|
|
40
|
-
"""
|
|
41
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
42
|
-
# Create a temporary file inside the temp directory
|
|
43
|
-
file_path = Path(tmpdir) / "testfile.txt"
|
|
44
|
-
file_path.write_text("sample content")
|
|
45
|
-
resolver = Resolver(tmpdir)
|
|
46
|
-
resolved = resolver.relativePath("testfile.txt").toString()
|
|
47
|
-
# The resolved path should end with the file name
|
|
48
|
-
self.assertTrue(resolved.endswith("testfile.txt"))
|
|
49
|
-
# The resolved path should be absolute
|
|
50
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
51
|
-
|
|
52
|
-
async def testValidDirectoryPath(self):
|
|
53
|
-
"""
|
|
54
|
-
Test that resolving a valid directory path returns the correct absolute path.
|
|
55
|
-
|
|
56
|
-
Returns
|
|
57
|
-
-------
|
|
58
|
-
None
|
|
59
|
-
|
|
60
|
-
Asserts
|
|
61
|
-
-------
|
|
62
|
-
The resolved path ends with the directory name and is absolute.
|
|
63
|
-
"""
|
|
64
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
65
|
-
# Create a subdirectory inside the temp directory
|
|
66
|
-
subdir = Path(tmpdir) / "subdir"
|
|
67
|
-
subdir.mkdir()
|
|
68
|
-
resolver = Resolver(tmpdir)
|
|
69
|
-
resolved = resolver.relativePath("subdir").toString()
|
|
70
|
-
self.assertTrue(resolved.endswith("subdir"))
|
|
71
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
72
|
-
|
|
73
|
-
async def testOtherBasePath(self):
|
|
74
|
-
"""
|
|
75
|
-
Test that providing a different base path to Resolver works as expected.
|
|
76
|
-
|
|
77
|
-
Returns
|
|
78
|
-
-------
|
|
79
|
-
None
|
|
80
|
-
|
|
81
|
-
Asserts
|
|
82
|
-
-------
|
|
83
|
-
The resolved path ends with the file name and is absolute.
|
|
84
|
-
"""
|
|
85
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
86
|
-
# Create a file in a subdirectory
|
|
87
|
-
subdir = Path(tmpdir) / "base"
|
|
88
|
-
subdir.mkdir()
|
|
89
|
-
file_path = subdir / "file.txt"
|
|
90
|
-
file_path.write_text("data")
|
|
91
|
-
resolver = Resolver(str(subdir))
|
|
92
|
-
resolved = resolver.relativePath("file.txt").toString()
|
|
93
|
-
self.assertTrue(resolved.endswith("file.txt"))
|
|
94
|
-
self.assertTrue(os.path.isabs(resolved))
|
|
95
|
-
|
|
96
|
-
async def testEqualOutputString(self):
|
|
97
|
-
"""
|
|
98
|
-
Test that the string representation of the resolved path matches the output of toString().
|
|
99
|
-
|
|
100
|
-
Returns
|
|
101
|
-
-------
|
|
102
|
-
None
|
|
103
|
-
|
|
104
|
-
Asserts
|
|
105
|
-
-------
|
|
106
|
-
The string representation of the resolved path matches the output of toString().
|
|
107
|
-
"""
|
|
108
|
-
with tempfile.TemporaryDirectory() as tmpdir:
|
|
109
|
-
file_path = Path(tmpdir) / "file.txt"
|
|
110
|
-
file_path.write_text("abc")
|
|
111
|
-
resolver = Resolver(tmpdir).relativePath("file.txt")
|
|
112
|
-
self.assertEqual(resolver.toString(), str(resolver))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|