thds.core 1.34.20250415155543__py3-none-any.whl → 1.35.20250416225746__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.
Potentially problematic release.
This version of thds.core might be problematic. Click here for more details.
- thds/core/source/__init__.py +1 -0
- thds/core/source/_construct_tree.py +18 -0
- thds/core/source/tree.py +9 -2
- thds/core/timer.py +2 -5
- {thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/METADATA +1 -1
- {thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/RECORD +9 -8
- {thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/WHEEL +0 -0
- {thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/entry_points.txt +0 -0
- {thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/top_level.txt +0 -0
thds/core/source/__init__.py
CHANGED
|
@@ -5,5 +5,6 @@ yet will not be downloaded (if non-local) until it is actually opened or unwrapp
|
|
|
5
5
|
|
|
6
6
|
from . import serde, tree # noqa: F401
|
|
7
7
|
from ._construct import from_file, from_uri, path_from_uri, register_from_uri_handler # noqa: F401
|
|
8
|
+
from ._construct_tree import tree_from_directory # noqa: F401
|
|
8
9
|
from ._download import Downloader, register_download_handler # noqa: F401
|
|
9
10
|
from .src import Source # noqa: F401
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import typing as ty
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from ..files import path_from_uri
|
|
6
|
+
from ._construct import from_file
|
|
7
|
+
from .tree import SourceTree
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def tree_from_directory(dirpath: ty.Union[str, os.PathLike]) -> SourceTree:
|
|
11
|
+
path = path_from_uri(dirpath) if isinstance(dirpath, str) else Path(dirpath)
|
|
12
|
+
|
|
13
|
+
if path.exists() and not path.is_dir():
|
|
14
|
+
raise NotADirectoryError(f"File '{path}' is not a directory")
|
|
15
|
+
if not path.exists():
|
|
16
|
+
raise FileNotFoundError(f"Directory '{path}' not found")
|
|
17
|
+
|
|
18
|
+
return SourceTree(sources=[from_file(file) for file in path.glob("**/*") if file.is_file()])
|
thds/core/source/tree.py
CHANGED
|
@@ -93,8 +93,15 @@ class SourceTree(os.PathLike):
|
|
|
93
93
|
)
|
|
94
94
|
)
|
|
95
95
|
]
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
|
|
97
|
+
if len(local_paths) == 1:
|
|
98
|
+
local_logical_root = local_paths[0].parent.resolve()
|
|
99
|
+
else:
|
|
100
|
+
local_logical_root = Path(
|
|
101
|
+
logical_root.find(map(str, local_paths), self.higher_logical_root)
|
|
102
|
+
)
|
|
103
|
+
assert local_logical_root.is_dir()
|
|
104
|
+
|
|
98
105
|
if not dest_dir:
|
|
99
106
|
return local_logical_root
|
|
100
107
|
|
thds/core/timer.py
CHANGED
|
@@ -141,11 +141,7 @@ class Timer:
|
|
|
141
141
|
|
|
142
142
|
@property
|
|
143
143
|
def secs_per_call(self) -> float:
|
|
144
|
-
return (self.secs / self.calls)
|
|
145
|
-
|
|
146
|
-
@property
|
|
147
|
-
def mins(self) -> float:
|
|
148
|
-
return self.secs / 60.0
|
|
144
|
+
return (self.secs / self.calls) if self.calls > 0 else float("nan")
|
|
149
145
|
|
|
150
146
|
def pct_of_total(self, total: float) -> float:
|
|
151
147
|
return (self.secs / total) * 100
|
|
@@ -200,6 +196,7 @@ class TimeTracker:
|
|
|
200
196
|
|
|
201
197
|
def __exit__(self, *args, **kwargs):
|
|
202
198
|
cmpnt = self.tracked_times[self._names.pop()]
|
|
199
|
+
cmpnt.calls += 1
|
|
203
200
|
cmpnt.secs += time.perf_counter() - self._start_times.pop()
|
|
204
201
|
|
|
205
202
|
@property
|
|
@@ -37,7 +37,7 @@ thds/core/scope.py,sha256=iPRhS-lIe-axDctqxBtEPeF0PM_w-0tRS-9kPweUGBY,7205
|
|
|
37
37
|
thds/core/source_serde.py,sha256=X4c7LiT3VidejqtTel9YB6dWGB3x-ct39KF9E50Nbx4,139
|
|
38
38
|
thds/core/stack_context.py,sha256=17lPOuYWclUpZ-VXRkPgI4WbiMzq7_ZY6Kj1QK_1oNo,1332
|
|
39
39
|
thds/core/thunks.py,sha256=p1OvMBJ4VGMsD8BVA7zwPeAp0L3y_nxVozBF2E78t3M,1053
|
|
40
|
-
thds/core/timer.py,sha256=
|
|
40
|
+
thds/core/timer.py,sha256=Ckj2eQzc3Y4yi4FZq1vnZ4WQVgwtrBPiLqi1kxjk_zM,5374
|
|
41
41
|
thds/core/tmp.py,sha256=KgBAwQCmpm7I762eLRu-3MSfH3dKnqlrJkZ5nmPcRbc,3110
|
|
42
42
|
thds/core/types.py,sha256=sFqI_8BsB1u85PSizjBZw8PBtplC7U54E19wZZWCEvI,152
|
|
43
43
|
thds/core/log/__init__.py,sha256=bDbZvlxyymY6VrQzD8lCn0egniLEiA9hpNMAXZ7e7wY,1348
|
|
@@ -46,12 +46,13 @@ thds/core/log/json_formatter.py,sha256=C5bRsSbAqaQqfTm88jc3mYe3vwKZZLAxET8s7_u7a
|
|
|
46
46
|
thds/core/log/kw_formatter.py,sha256=9-MVOd2r5NEkYNne9qWyFMeR5lac3w7mjHXsDa681i0,3379
|
|
47
47
|
thds/core/log/kw_logger.py,sha256=CyZVPnkUMtrUL2Lyk261AIEPmoP-buf_suFAhQlU1io,4063
|
|
48
48
|
thds/core/log/logfmt.py,sha256=i66zoG2oERnE1P_0TVXdlfJ1YgUmvtMjqRtdV5u2SvU,10366
|
|
49
|
-
thds/core/source/__init__.py,sha256=
|
|
49
|
+
thds/core/source/__init__.py,sha256=0Zy3mwJgwLtc4jq14Cwu6d_Rq-aZOMIlu4zaADeKgmo,487
|
|
50
50
|
thds/core/source/_construct.py,sha256=plSyQZRe8h0X7PpbfMjhm1qkFgrcyuSrReyWQo28YfA,3121
|
|
51
|
+
thds/core/source/_construct_tree.py,sha256=5Zk3a5a0uVxklWw6q4JOvI_bErqwlBngUz4TyEAWn1g,616
|
|
51
52
|
thds/core/source/_download.py,sha256=pUhkphHdB7y4ZpxZZ6ITIS5giXMHuRf420yYAJwx6aE,2924
|
|
52
53
|
thds/core/source/serde.py,sha256=wXCfuv_Dv3QvJJr-uebGmTrfhCU_1a8VX3VJnXhVHfU,3539
|
|
53
54
|
thds/core/source/src.py,sha256=9A_8kSBUc5k6OLAYe5EW_VogpXFIqofow7Rxl8xv-eg,4559
|
|
54
|
-
thds/core/source/tree.py,sha256=
|
|
55
|
+
thds/core/source/tree.py,sha256=iNCoCE655MwXQwc2Y0IIm1HMVk5Inj0NGVU9U8Wl_90,4317
|
|
55
56
|
thds/core/sqlite/__init__.py,sha256=tDMzuO76qTtckJHldPQ6nPZ6kcvhhoJrVuuW42JtaSQ,606
|
|
56
57
|
thds/core/sqlite/connect.py,sha256=l4QaSAI8RjP7Qh2FjmJ3EwRgfGf65Z3-LjtC9ocHM_U,977
|
|
57
58
|
thds/core/sqlite/copy.py,sha256=y3IRQTBrWDfKuVIfW7fYuEgwRCRKHjN0rxVFkIb9VrQ,1155
|
|
@@ -67,8 +68,8 @@ thds/core/sqlite/structured.py,sha256=SvZ67KcVcVdmpR52JSd52vMTW2ALUXmlHEeD-VrzWV
|
|
|
67
68
|
thds/core/sqlite/types.py,sha256=oUkfoKRYNGDPZRk29s09rc9ha3SCk2SKr_K6WKebBFs,1308
|
|
68
69
|
thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
|
|
69
70
|
thds/core/sqlite/write.py,sha256=z0219vDkQDCnsV0WLvsj94keItr7H4j7Y_evbcoBrWU,3458
|
|
70
|
-
thds_core-1.
|
|
71
|
-
thds_core-1.
|
|
72
|
-
thds_core-1.
|
|
73
|
-
thds_core-1.
|
|
74
|
-
thds_core-1.
|
|
71
|
+
thds_core-1.35.20250416225746.dist-info/METADATA,sha256=xVzJ2UiMPzXTwONBhzvYWubU1Z8cxPpp3PIJhpj_McY,2275
|
|
72
|
+
thds_core-1.35.20250416225746.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
73
|
+
thds_core-1.35.20250416225746.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
|
|
74
|
+
thds_core-1.35.20250416225746.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
|
|
75
|
+
thds_core-1.35.20250416225746.dist-info/RECORD,,
|
|
File without changes
|
{thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{thds_core-1.34.20250415155543.dist-info → thds_core-1.35.20250416225746.dist-info}/top_level.txt
RENAMED
|
File without changes
|