adiumentum 0.3.0__tar.gz → 0.3.2__tar.gz
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-0.3.0 → adiumentum-0.3.2}/PKG-INFO +1 -2
- {adiumentum-0.3.0 → adiumentum-0.3.2}/pyproject.toml +1 -2
- adiumentum-0.3.2/src/adiumentum/paths_manager.py +67 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/pydantic_extensions.py +7 -6
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/string_utils.py +29 -9
- adiumentum-0.3.0/src/adiumentum/paths_manager.py +0 -19
- {adiumentum-0.3.0 → adiumentum-0.3.2}/README.md +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/__init__.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/color.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/comparison.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/converters.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/dependency_sorting.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/display.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/elementary_types.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/exceptions.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/file_modification_time.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/frozendict.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/functional.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/io_utils.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/markers.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/merge.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/numerical.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/performance_logging.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/pydantic_extensions.md +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/timestamping.py +0 -0
- {adiumentum-0.3.0 → adiumentum-0.3.2}/src/adiumentum/typing_utils.py +0 -0
@@ -1,13 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: adiumentum
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.2
|
4
4
|
Summary:
|
5
5
|
Author: Isaac Riley
|
6
6
|
Author-email: Isaac Riley <yelircaasi@proton.me>
|
7
7
|
Requires-Dist: pydantic>=2.11
|
8
8
|
Requires-Dist: multipledispatch>=1
|
9
9
|
Requires-Dist: loguru>=0.7.3
|
10
|
-
Requires-Dist: datethyme>=0.4.0
|
11
10
|
Requires-Python: >=3.11, <3.15
|
12
11
|
Description-Content-Type: text/markdown
|
13
12
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "adiumentum"
|
3
|
-
version = "0.3.
|
3
|
+
version = "0.3.2"
|
4
4
|
description = ""
|
5
5
|
authors = [{name = "Isaac Riley", email = "yelircaasi@proton.me"}]
|
6
6
|
readme = "README.md"
|
@@ -9,7 +9,6 @@ dependencies = [
|
|
9
9
|
"pydantic >= 2.11 ",
|
10
10
|
"multipledispatch >= 1 ",
|
11
11
|
"loguru >= 0.7.3",
|
12
|
-
"datethyme >= 0.4.0",
|
13
12
|
]
|
14
13
|
|
15
14
|
[project.scripts]
|
@@ -0,0 +1,67 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from pathlib import Path
|
3
|
+
from typing import Self
|
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
|
+
|
23
|
+
|
24
|
+
|
25
|
+
class PathsManager(BaseModel, ABC):
|
26
|
+
@abstractmethod
|
27
|
+
@classmethod
|
28
|
+
def create(cls, *args, **kwargs) -> Self:
|
29
|
+
"""
|
30
|
+
Create directories first if they do not already exist.
|
31
|
+
"""
|
32
|
+
...
|
33
|
+
|
34
|
+
@abstractmethod
|
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
|
+
|
42
|
+
|
43
|
+
@abstractmethod
|
44
|
+
@classmethod
|
45
|
+
def read(cls, config_file_path: Path) -> Self:
|
46
|
+
...
|
47
|
+
|
48
|
+
@abstractmethod
|
49
|
+
def write(self, config_file_path: Path) -> None:
|
50
|
+
...
|
51
|
+
|
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
|
@@ -1,20 +1,40 @@
|
|
1
1
|
import json
|
2
2
|
import re
|
3
3
|
from collections.abc import Callable, Iterable
|
4
|
-
from typing import Literal, TypeAlias, cast
|
5
|
-
|
6
|
-
from datethyme import Date, Time
|
4
|
+
from typing import Literal, Protocol, Self, TypeAlias, cast
|
7
5
|
|
8
6
|
from .functional import lmap
|
9
7
|
from .typing_utils import JSONDict, areinstances
|
10
8
|
|
9
|
+
class DateProtocol(Protocol):
|
10
|
+
year: int
|
11
|
+
month: int
|
12
|
+
day: int
|
13
|
+
|
14
|
+
@classmethod
|
15
|
+
def parse(cls, date_string: str) -> Self: ...
|
16
|
+
|
17
|
+
def __str__(self) -> str: ...
|
18
|
+
|
19
|
+
|
20
|
+
class TimeProtocol(Protocol):
|
21
|
+
hour: int
|
22
|
+
minute: int
|
23
|
+
second: float
|
24
|
+
|
25
|
+
@classmethod
|
26
|
+
def parse(cls, time_string: str) -> Self: ...
|
27
|
+
|
28
|
+
def __str__(self) -> str: ...
|
29
|
+
|
30
|
+
|
11
31
|
MixedValidated: TypeAlias = (
|
12
32
|
str
|
13
33
|
| bool
|
14
34
|
| int
|
15
35
|
| float
|
16
|
-
|
|
17
|
-
|
|
36
|
+
| TimeProtocol
|
37
|
+
| DateProtocol
|
18
38
|
| tuple[str, ...]
|
19
39
|
| tuple[str, str]
|
20
40
|
| tuple[float, float]
|
@@ -135,10 +155,10 @@ def cast_to_negative_score(s: str | bool) -> float:
|
|
135
155
|
return score
|
136
156
|
|
137
157
|
|
138
|
-
def
|
158
|
+
def cast_to_date(s: str | bool, date_class: type[DateProtocol]) -> DateProtocol:
|
139
159
|
if isinstance(s, bool):
|
140
160
|
raise TypeError
|
141
|
-
return
|
161
|
+
return date_class.parse(s)
|
142
162
|
|
143
163
|
|
144
164
|
def cast_to_stringtuple(s: str | bool) -> tuple[str, ...]:
|
@@ -160,10 +180,10 @@ def cast_as(
|
|
160
180
|
"integer": cast_to_int,
|
161
181
|
"float": cast_to_float,
|
162
182
|
"minutes": cast_to_minutes,
|
163
|
-
"time": Time.model_validate,
|
183
|
+
# "time": Time.model_validate, TODO: add later via injection
|
164
184
|
"positiveScore": cast_to_positive_score,
|
165
185
|
"negativeScore": cast_to_negative_score,
|
166
|
-
"date":
|
186
|
+
# "date": cast_to_date, TODO: add later via injection
|
167
187
|
"stringtuple": cast_to_stringtuple,
|
168
188
|
}
|
169
189
|
caster = dispatch[input_type]
|
@@ -1,19 +0,0 @@
|
|
1
|
-
from abc import abstractmethod
|
2
|
-
from pathlib import Path
|
3
|
-
from typing import Self
|
4
|
-
|
5
|
-
|
6
|
-
class PathsManager:
|
7
|
-
@abstractmethod
|
8
|
-
def setup(self) -> None: ...
|
9
|
-
|
10
|
-
@classmethod
|
11
|
-
@abstractmethod
|
12
|
-
def auto(cls, root_dir: Path): ...
|
13
|
-
|
14
|
-
@classmethod
|
15
|
-
@abstractmethod
|
16
|
-
def read(cls, config_file_path: Path) -> Self: ...
|
17
|
-
|
18
|
-
@abstractmethod
|
19
|
-
def write(self, config_file_path: Path) -> None: ...
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|