adiumentum 0.3.1__py3-none-any.whl → 0.3.2__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.
- adiumentum/paths_manager.py +56 -8
- adiumentum/pydantic_extensions.py +7 -6
- {adiumentum-0.3.1.dist-info → adiumentum-0.3.2.dist-info}/METADATA +1 -1
- {adiumentum-0.3.1.dist-info → adiumentum-0.3.2.dist-info}/RECORD +6 -6
- {adiumentum-0.3.1.dist-info → adiumentum-0.3.2.dist-info}/WHEEL +0 -0
- {adiumentum-0.3.1.dist-info → adiumentum-0.3.2.dist-info}/entry_points.txt +0 -0
adiumentum/paths_manager.py
CHANGED
@@ -1,19 +1,67 @@
|
|
1
|
-
from abc import abstractmethod
|
1
|
+
from abc import ABC, abstractmethod
|
2
2
|
from pathlib import Path
|
3
3
|
from typing import Self
|
4
4
|
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
# class PathsManager:
|
9
|
+
# @abstractmethod
|
10
|
+
# def setup(self) -> None: ...
|
11
|
+
|
12
|
+
# @classmethod
|
13
|
+
# @abstractmethod
|
14
|
+
# def auto(cls, root_dir: Path): ...
|
15
|
+
|
16
|
+
# @classmethod
|
17
|
+
# @abstractmethod
|
18
|
+
# def read(cls, config_file_path: Path) -> Self: ...
|
19
|
+
|
20
|
+
# @abstractmethod
|
21
|
+
# def write(self, config_file_path: Path) -> None: ...
|
22
|
+
|
5
23
|
|
6
|
-
class PathsManager:
|
7
|
-
@abstractmethod
|
8
|
-
def setup(self) -> None: ...
|
9
24
|
|
25
|
+
class PathsManager(BaseModel, ABC):
|
26
|
+
@abstractmethod
|
10
27
|
@classmethod
|
28
|
+
def create(cls, *args, **kwargs) -> Self:
|
29
|
+
"""
|
30
|
+
Create directories first if they do not already exist.
|
31
|
+
"""
|
32
|
+
...
|
33
|
+
|
11
34
|
@abstractmethod
|
12
|
-
|
35
|
+
@classmethod
|
36
|
+
def auto(cls, root_dir: Path, **kwargs) -> Self:
|
37
|
+
"""
|
38
|
+
Create directories and files in the default location if they do not alreay exist.
|
39
|
+
"""
|
40
|
+
...
|
41
|
+
|
13
42
|
|
43
|
+
@abstractmethod
|
14
44
|
@classmethod
|
45
|
+
def read(cls, config_file_path: Path) -> Self:
|
46
|
+
...
|
47
|
+
|
15
48
|
@abstractmethod
|
16
|
-
def
|
49
|
+
def write(self, config_file_path: Path) -> None:
|
50
|
+
...
|
17
51
|
|
18
|
-
@
|
19
|
-
def
|
52
|
+
@staticmethod
|
53
|
+
def ensure_file_exists(p: Path, content_if_empty: str = "") -> Path:
|
54
|
+
if not p.exists():
|
55
|
+
p.touch()
|
56
|
+
if content_if_empty:
|
57
|
+
p.write_text(content_if_empty)
|
58
|
+
return p
|
59
|
+
|
60
|
+
@staticmethod
|
61
|
+
def ensure_directory_exists(p: Path) -> Path:
|
62
|
+
for parent in p.parents:
|
63
|
+
if not parent.exists():
|
64
|
+
parent.mkdir()
|
65
|
+
if not p.exists():
|
66
|
+
p.mkdir()
|
67
|
+
return p
|
@@ -97,13 +97,14 @@ class AbstractCustom(ABC):
|
|
97
97
|
return set()
|
98
98
|
|
99
99
|
@classmethod
|
100
|
-
|
101
|
-
|
100
|
+
def model_construct(cls, _fields_set: set[str] | None = None, **values: Any) -> Self:
|
101
|
+
raise NotImplementedError
|
102
102
|
|
103
|
-
@abstractmethod
|
104
103
|
def model_copy(
|
105
104
|
self, *, update: Mapping[str, Any] | None = None, deep: bool = False
|
106
|
-
) -> Self:
|
105
|
+
) -> Self:
|
106
|
+
return self.__class__.model_validate(self.model_dump())
|
107
|
+
|
107
108
|
|
108
109
|
def model_dump(
|
109
110
|
self,
|
@@ -275,10 +276,10 @@ class AbstractCustom(ABC):
|
|
275
276
|
return self.get_adapter().__annotations__
|
276
277
|
|
277
278
|
@classmethod
|
278
|
-
def
|
279
|
+
def read_json_file(cls, read_path: Path) -> Self:
|
279
280
|
return cls.model_validate_json(read_path.read_text())
|
280
281
|
|
281
|
-
def
|
282
|
+
def write_json_file(self, write_path: Path) -> None:
|
282
283
|
write_json(cast(JSONDict, self.model_dump(mode="json")), write_path)
|
283
284
|
|
284
285
|
@staticmethod
|
@@ -13,14 +13,14 @@ adiumentum/io_utils.py,sha256=033110e6b9335ad4270cf62c86a0df53c5c43954521a814729
|
|
13
13
|
adiumentum/markers.py,sha256=988f0b7ef80d61871165f30b601f05c9981cfd353c235eb314de5271e8040900,2959
|
14
14
|
adiumentum/merge.py,sha256=b1894b08e906ead6f423dfb6d637df553eeed4f894c197f771f3569854044c32,3877
|
15
15
|
adiumentum/numerical.py,sha256=adad3335e7220c8bf9666ce8c79f01ca4f1a0933316bb8e6fbfc0440293fbbed,704
|
16
|
-
adiumentum/paths_manager.py,sha256=
|
16
|
+
adiumentum/paths_manager.py,sha256=0e6e9d9499d16c4bea9c32fde631aeb6c73684c2fd6e0897b3dd5d5b6e6c6eb2,1565
|
17
17
|
adiumentum/performance_logging.py,sha256=bd0c42337fb5c77921700e5487d366ea103e8cd25825138962bfb44c1b54773b,1471
|
18
18
|
adiumentum/pydantic_extensions.md,sha256=6f5fe7fc9f10e0f6a87e2861dd16d066892099542dbaca3764944c6a27635706,24936
|
19
|
-
adiumentum/pydantic_extensions.py,sha256=
|
19
|
+
adiumentum/pydantic_extensions.py,sha256=34c2b2920e09e8e018fa8d8a2acd5ee6c3f5a0633b1f3f385c5fccdb2fcc1a4d,12678
|
20
20
|
adiumentum/string_utils.py,sha256=459576481a67d1f078ffcbb0606ba235d0694cb0911905174239312224953f66,5321
|
21
21
|
adiumentum/timestamping.py,sha256=87729ac9dd7dac614fbb7bb1995e321bd860202a4c2f435e044f4af23dd545a0,556
|
22
22
|
adiumentum/typing_utils.py,sha256=81e01e90a60fe397c5211493fb4446af5f59fbd4b364c98f377962f4bd67ff8b,3894
|
23
|
-
adiumentum-0.3.
|
24
|
-
adiumentum-0.3.
|
25
|
-
adiumentum-0.3.
|
26
|
-
adiumentum-0.3.
|
23
|
+
adiumentum-0.3.2.dist-info/WHEEL,sha256=ab6157bc637547491fb4567cd7ddf26b04d63382916ca16c29a5c8e94c9c9ef7,79
|
24
|
+
adiumentum-0.3.2.dist-info/entry_points.txt,sha256=8d158243687a1102f915d2091f19bdc1443ec58709954317c4edff9edb9e5be8,57
|
25
|
+
adiumentum-0.3.2.dist-info/METADATA,sha256=2d463e743f3153c2cfd1a62b0ee7467f88002fa2c3d3ada72aa2496ae5d5a7e0,1104
|
26
|
+
adiumentum-0.3.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|