adiumentum 0.1.0__tar.gz → 0.1.1__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.1.0 → adiumentum-0.1.1}/PKG-INFO +1 -1
- {adiumentum-0.1.0 → adiumentum-0.1.1}/pyproject.toml +1 -1
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/__init__.py +6 -5
- adiumentum-0.1.1/src/adiumentum/file_modification_time.py +39 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/frozendict.py +2 -2
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/functional.py +2 -2
- adiumentum-0.1.1/src/adiumentum/timestamping.py +20 -0
- adiumentum-0.1.0/src/adiumentum/file_modification_time.py +0 -31
- adiumentum-0.1.0/src/adiumentum/timestamping.py +0 -12
- {adiumentum-0.1.0 → adiumentum-0.1.1}/README.md +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/color.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/comparison.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/converters.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/elementary_types.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/exceptions.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/io.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/markers.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/numerical.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/performance_logging.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/string.py +0 -0
- {adiumentum-0.1.0 → adiumentum-0.1.1}/src/adiumentum/typing_utils.py +0 -0
@@ -3,9 +3,9 @@ from .comparison import equal_within, nearly_equal
|
|
3
3
|
from .exceptions import CustomValidationError
|
4
4
|
from .file_modification_time import (
|
5
5
|
first_newer,
|
6
|
-
|
7
|
-
get_time_modified,
|
6
|
+
time_created,
|
8
7
|
time_created_readable,
|
8
|
+
time_modified,
|
9
9
|
time_modified_readable,
|
10
10
|
)
|
11
11
|
from .frozendict import FrozenDefaultDict
|
@@ -50,7 +50,7 @@ from .string import (
|
|
50
50
|
indent_lines,
|
51
51
|
parse_sequence,
|
52
52
|
)
|
53
|
-
from .timestamping import insert_timestamp
|
53
|
+
from .timestamping import insert_timestamp, make_timestamp
|
54
54
|
from .typing_utils import (
|
55
55
|
areinstances,
|
56
56
|
call_fallback_if_none,
|
@@ -80,8 +80,6 @@ __all__ = [
|
|
80
80
|
"first_newer",
|
81
81
|
"flexsplit",
|
82
82
|
"fold_dictionaries",
|
83
|
-
"get_time_created",
|
84
|
-
"get_time_modified",
|
85
83
|
"helper",
|
86
84
|
"identity",
|
87
85
|
"ihash",
|
@@ -92,6 +90,7 @@ __all__ = [
|
|
92
90
|
"list_full",
|
93
91
|
"lmap",
|
94
92
|
"log_perf",
|
93
|
+
"make_timestamp",
|
95
94
|
"mutates",
|
96
95
|
"mutates_and_returns_instance",
|
97
96
|
"mutates_instance",
|
@@ -105,7 +104,9 @@ __all__ = [
|
|
105
104
|
"smap",
|
106
105
|
"step_data",
|
107
106
|
"step_transition",
|
107
|
+
"time_created",
|
108
108
|
"time_created_readable",
|
109
|
+
"time_modified",
|
109
110
|
"time_modified_readable",
|
110
111
|
"tmap",
|
111
112
|
"validator",
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import os
|
2
|
+
from datetime import datetime
|
3
|
+
from pathlib import Path
|
4
|
+
|
5
|
+
|
6
|
+
def time_created(path: Path | str) -> float:
|
7
|
+
return Path(path).stat().st_ctime
|
8
|
+
|
9
|
+
|
10
|
+
def format_time(raw_time: float, places: int = 3) -> str:
|
11
|
+
dt = datetime.fromtimestamp(raw_time)
|
12
|
+
if places > 0:
|
13
|
+
idx: int | None = min(0, int(places) - 6) or None
|
14
|
+
return dt.strftime("%Y-%m-%d_%H:%M:%S.%f")[:idx]
|
15
|
+
return dt.strftime("%Y-%m-%d_%H:%M:%S")
|
16
|
+
|
17
|
+
|
18
|
+
def time_created_readable(path: Path | str, places: int = 3) -> str:
|
19
|
+
# time_created: time.struct_time = time.strptime(time.ctime(time_created(path)))
|
20
|
+
return format_time(time_created(path), places=places)
|
21
|
+
|
22
|
+
|
23
|
+
def time_modified(path: Path | str) -> float:
|
24
|
+
return Path(path).stat().st_mtime
|
25
|
+
|
26
|
+
|
27
|
+
def time_modified_readable(path: Path | str, places: int = 3) -> str:
|
28
|
+
# time_modified: time.struct_time = time.strptime(time.ctime(time_modified(path)))
|
29
|
+
return format_time(time_modified(path), places=places)
|
30
|
+
|
31
|
+
|
32
|
+
def first_newer(file1: str | Path, file2: str | Path | tuple[Path, ...] | tuple[str, ...]) -> bool:
|
33
|
+
m1 = os.path.getmtime(file1)
|
34
|
+
|
35
|
+
if isinstance(file2, tuple):
|
36
|
+
m2 = max(os.path.getmtime(f) for f in file2)
|
37
|
+
else:
|
38
|
+
m2 = os.path.getmtime(file2)
|
39
|
+
return m1 > m2
|
@@ -1,12 +1,12 @@
|
|
1
1
|
from collections import defaultdict
|
2
2
|
from collections.abc import Callable
|
3
|
-
from typing import
|
3
|
+
from typing import TypeVar, cast
|
4
4
|
|
5
5
|
T = TypeVar("T")
|
6
6
|
K = TypeVar("K")
|
7
7
|
|
8
8
|
|
9
|
-
class FrozenDefaultDict
|
9
|
+
class FrozenDefaultDict[K, T](defaultdict[K, T]):
|
10
10
|
def __init__(self, default_factory: Callable[[], T], dictionary: dict[K, T]):
|
11
11
|
super().__init__(default_factory, dictionary)
|
12
12
|
|
@@ -33,11 +33,11 @@ def dmap(callable_: Callable[[TPre], TPost], dictionary: dict[TPre, TPre]) -> di
|
|
33
33
|
return {callable_(k): callable_(v) for k, v in dictionary.items()}
|
34
34
|
|
35
35
|
|
36
|
-
def identity(x: T) -> T:
|
36
|
+
def identity[T](x: T) -> T:
|
37
37
|
return x
|
38
38
|
|
39
39
|
|
40
|
-
def fold_dictionaries(dicts: Iterable[dict[K, T]]) -> dict[K, T]:
|
40
|
+
def fold_dictionaries[K, T](dicts: Iterable[dict[K, T]]) -> dict[K, T]:
|
41
41
|
def _or(dict1: dict[K, T], dict2: dict[K, T]) -> dict[K, T]:
|
42
42
|
return dict1 | dict2
|
43
43
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from pathlib import Path
|
3
|
+
|
4
|
+
|
5
|
+
def make_timestamp(places: int = 3) -> str:
|
6
|
+
dt = datetime.now()
|
7
|
+
if places > 0:
|
8
|
+
idx: int | None = min(0, int(places) - 6) or None
|
9
|
+
return dt.strftime("%Y-%m-%d_%H:%M:%S.%f")[:idx]
|
10
|
+
return dt.strftime("%Y-%m-%d_%H:%M:%S")
|
11
|
+
|
12
|
+
|
13
|
+
def insert_timestamp(p: Path | str) -> Path:
|
14
|
+
new_path = str(p)
|
15
|
+
|
16
|
+
if "." in new_path:
|
17
|
+
base, suffix = new_path.rsplit(".", 1)
|
18
|
+
return Path(f"{base}__{make_timestamp()}.{suffix}")
|
19
|
+
|
20
|
+
return Path(f"{new_path}__{make_timestamp()}")
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import time
|
3
|
-
from pathlib import Path
|
4
|
-
|
5
|
-
|
6
|
-
def get_time_created(path: Path | str) -> float:
|
7
|
-
return os.path.getctime(path)
|
8
|
-
|
9
|
-
|
10
|
-
def time_created_readable(path: Path | str) -> str:
|
11
|
-
time_created: time.struct_time = time.strptime(time.ctime(get_time_created(path)))
|
12
|
-
return time.strftime("%Y-%m-%d %H:%M:%S", time_created)
|
13
|
-
|
14
|
-
|
15
|
-
def get_time_modified(path: Path | str) -> float:
|
16
|
-
return os.path.getmtime(path)
|
17
|
-
|
18
|
-
|
19
|
-
def time_modified_readable(path: Path | str) -> str:
|
20
|
-
time_modified: time.struct_time = time.strptime(time.ctime(get_time_modified(path)))
|
21
|
-
return time.strftime("%Y-%m-%d %H:%M:%S", time_modified)
|
22
|
-
|
23
|
-
|
24
|
-
def first_newer(file1: str | Path, file2: str | Path | tuple[Path, ...] | tuple[str, ...]) -> bool:
|
25
|
-
m1 = os.path.getmtime(file1)
|
26
|
-
|
27
|
-
if isinstance(file2, tuple):
|
28
|
-
m2 = max(os.path.getmtime(f) for f in file2)
|
29
|
-
else:
|
30
|
-
m2 = os.path.getmtime(file2)
|
31
|
-
return m1 > m2
|
@@ -1,12 +0,0 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
from pathlib import Path
|
3
|
-
|
4
|
-
|
5
|
-
def insert_timestamp(p: Path | str) -> Path:
|
6
|
-
new_path = str(p)
|
7
|
-
|
8
|
-
if "." in new_path:
|
9
|
-
base, suffix = new_path.rsplit(".", 1)
|
10
|
-
return Path(f"{base}__{datetime.now():%Y-%m-%d_%H:%M:%S}.{suffix}")
|
11
|
-
|
12
|
-
return Path(f"{new_path}__{datetime.now():%Y-%m-%d_%H:%M:%S}")
|
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
|