dycw-utilities 0.129.9__py3-none-any.whl → 0.129.11__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.
- {dycw_utilities-0.129.9.dist-info → dycw_utilities-0.129.11.dist-info}/METADATA +6 -1
- {dycw_utilities-0.129.9.dist-info → dycw_utilities-0.129.11.dist-info}/RECORD +7 -6
- utilities/__init__.py +1 -1
- utilities/git.py +40 -0
- utilities/logging.py +9 -6
- {dycw_utilities-0.129.9.dist-info → dycw_utilities-0.129.11.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.129.9.dist-info → dycw_utilities-0.129.11.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,15 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dycw-utilities
|
3
|
-
Version: 0.129.
|
3
|
+
Version: 0.129.11
|
4
4
|
Author-email: Derek Wan <d.wan@icloud.com>
|
5
5
|
License-File: LICENSE
|
6
6
|
Requires-Python: >=3.12
|
7
7
|
Requires-Dist: typing-extensions<4.15,>=4.14.0
|
8
|
+
Provides-Extra: logging
|
9
|
+
Requires-Dist: atomicwrites<1.5,>=1.4.1; extra == 'logging'
|
10
|
+
Requires-Dist: coloredlogs<15.1,>=15.0.1; extra == 'logging'
|
11
|
+
Requires-Dist: tzlocal<5.4,>=5.3.1; extra == 'logging'
|
12
|
+
Requires-Dist: whenever<0.9,>=0.8.4; extra == 'logging'
|
8
13
|
Provides-Extra: test
|
9
14
|
Requires-Dist: dycw-pytest-only<2.2,>=2.1.1; extra == 'test'
|
10
15
|
Requires-Dist: hypothesis<6.136,>=6.135.0; extra == 'test'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=JW5cx0uUmfjX3K1m1sd4wQ2ZvR0xLVVdP93bj5ilIso,61
|
2
2
|
utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
|
3
3
|
utilities/asyncio.py,sha256=3n5EIcSq2xtEF1i4oR0oY2JmBq3NyugeHKFK39Mt22s,37987
|
4
4
|
utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
|
@@ -20,6 +20,7 @@ utilities/fpdf2.py,sha256=y1NGXR5chWqLXWpewGV3hlRGMr_5yV1lVRkPBhPEgJI,1843
|
|
20
20
|
utilities/functions.py,sha256=jgt592voaHNtX56qX0SRvFveVCRmSIxCZmqvpLZCnY8,27305
|
21
21
|
utilities/functools.py,sha256=WrpHt7NLNWSUn9A1Q_ZIWlNaYZOEI4IFKyBG9HO3BC4,1643
|
22
22
|
utilities/getpass.py,sha256=DfN5UgMAtFCqS3dSfFHUfqIMZX2shXvwphOz_6J6f6A,103
|
23
|
+
utilities/git.py,sha256=oi7-_l5e9haSANSCvQw25ufYGoNahuUPHAZ6114s3JQ,1191
|
23
24
|
utilities/hashlib.py,sha256=SVTgtguur0P4elppvzOBbLEjVM3Pea0eWB61yg2ilxo,309
|
24
25
|
utilities/http.py,sha256=WcahTcKYRtZ04WXQoWt5EGCgFPcyHD3EJdlMfxvDt-0,946
|
25
26
|
utilities/hypothesis.py,sha256=UnUMJmeqwJuK7uyUqw_i3opUYzVKud4RMG0RMOSRBQY,44463
|
@@ -29,7 +30,7 @@ utilities/iterables.py,sha256=mDqw2_0MUVp-P8FklgcaVTi2TXduH0MxbhTDzzhSBho,44915
|
|
29
30
|
utilities/jupyter.py,sha256=ft5JA7fBxXKzP-L9W8f2-wbF0QeYc_2uLQNFDVk4Z-M,2917
|
30
31
|
utilities/libcst.py,sha256=Jto5ppzRzsxn4AD32IS8n0lbgLYXwsVJB6EY8giNZyY,4974
|
31
32
|
utilities/lightweight_charts.py,sha256=0xNfcsrgFI0R9xL25LtSm-W5yhfBI93qQNT6HyaXAhg,2769
|
32
|
-
utilities/logging.py,sha256=
|
33
|
+
utilities/logging.py,sha256=GvSjMcjjHehbGeFGLQDiNvDteKym3-M-WF8tPlVDIQY,26228
|
33
34
|
utilities/loguru.py,sha256=MEMQVWrdECxk1e3FxGzmOf21vWT9j8CAir98SEXFKPA,3809
|
34
35
|
utilities/luigi.py,sha256=fpH9MbxJDuo6-k9iCXRayFRtiVbUtibCJKugf7ygpv0,5988
|
35
36
|
utilities/math.py,sha256=-mQgbah-dPJwOEWf3SonrFoVZ2AVxMgpeQ3dfVa-oJA,26764
|
@@ -89,7 +90,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
|
|
89
90
|
utilities/whenever.py,sha256=QbXgFAPuUL7PCp2hajmIP-FFIfIR1J6Y0TxJbeoj60I,18434
|
90
91
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
91
92
|
utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
|
92
|
-
dycw_utilities-0.129.
|
93
|
-
dycw_utilities-0.129.
|
94
|
-
dycw_utilities-0.129.
|
95
|
-
dycw_utilities-0.129.
|
93
|
+
dycw_utilities-0.129.11.dist-info/METADATA,sha256=WHVZXt4JJ08qllef49xi0SLybG4cxYGVYOMR8G4Efzc,12980
|
94
|
+
dycw_utilities-0.129.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
95
|
+
dycw_utilities-0.129.11.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.129.11.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/git.py
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from pathlib import Path
|
5
|
+
from re import IGNORECASE, search
|
6
|
+
from subprocess import PIPE, CalledProcessError, check_output
|
7
|
+
from typing import TYPE_CHECKING, override
|
8
|
+
|
9
|
+
from utilities.pathlib import PWD
|
10
|
+
|
11
|
+
if TYPE_CHECKING:
|
12
|
+
from utilities.types import PathLike
|
13
|
+
|
14
|
+
|
15
|
+
def get_repo_root(*, path: PathLike = PWD) -> Path:
|
16
|
+
"""Get the repo root."""
|
17
|
+
try:
|
18
|
+
output = check_output(
|
19
|
+
["git", "rev-parse", "--show-toplevel"], stderr=PIPE, cwd=path, text=True
|
20
|
+
)
|
21
|
+
except CalledProcessError as error:
|
22
|
+
# newer versions of git report "Not a git repository", whilst older
|
23
|
+
# versions report "not a git repository"
|
24
|
+
if search("fatal: not a git repository", error.stderr, flags=IGNORECASE):
|
25
|
+
raise GetRepoRootError(cwd=path) from error
|
26
|
+
raise # pragma: no cover
|
27
|
+
else:
|
28
|
+
return Path(output.strip("\n"))
|
29
|
+
|
30
|
+
|
31
|
+
@dataclass(kw_only=True, slots=True)
|
32
|
+
class GetRepoRootError(Exception):
|
33
|
+
cwd: PathLike
|
34
|
+
|
35
|
+
@override
|
36
|
+
def __str__(self) -> str:
|
37
|
+
return f"Path is not part of a `git` repository: {self.cwd}"
|
38
|
+
|
39
|
+
|
40
|
+
__all__ = ["GetRepoRootError", "get_repo_root"]
|
utilities/logging.py
CHANGED
@@ -85,6 +85,9 @@ except ModuleNotFoundError: # pragma: no cover
|
|
85
85
|
type _When = Literal[
|
86
86
|
"S", "M", "H", "D", "midnight", "W0", "W1", "W2", "W3", "W4", "W5", "W6"
|
87
87
|
]
|
88
|
+
_BACKUP_COUNT: int = 100
|
89
|
+
_MAX_BYTES: int = 10 * 1024**2
|
90
|
+
_WHEN: _When = "D"
|
88
91
|
|
89
92
|
|
90
93
|
class SizeAndTimeRotatingFileHandler(BaseRotatingHandler):
|
@@ -100,10 +103,10 @@ class SizeAndTimeRotatingFileHandler(BaseRotatingHandler):
|
|
100
103
|
encoding: str | None = None,
|
101
104
|
delay: bool = False,
|
102
105
|
errors: Literal["strict", "ignore", "replace"] | None = None,
|
103
|
-
maxBytes: int =
|
104
|
-
when: _When =
|
106
|
+
maxBytes: int = _MAX_BYTES,
|
107
|
+
when: _When = _WHEN,
|
105
108
|
interval: int = 1,
|
106
|
-
backupCount: int =
|
109
|
+
backupCount: int = _BACKUP_COUNT,
|
107
110
|
utc: bool = False,
|
108
111
|
atTime: dt.time | None = None,
|
109
112
|
) -> None:
|
@@ -554,10 +557,10 @@ def setup_logging(
|
|
554
557
|
console_filters: Iterable[_FilterType] | None = None,
|
555
558
|
console_fmt: str = "❯ {_zoned_datetime_str} | {name}:{funcName}:{lineno} | {message}", # noqa: RUF001
|
556
559
|
files_dir: MaybeCallablePathLike | None = get_default_logging_path,
|
557
|
-
files_when: _When =
|
560
|
+
files_when: _When = _WHEN,
|
558
561
|
files_interval: int = 1,
|
559
|
-
files_backup_count: int =
|
560
|
-
files_max_bytes: int =
|
562
|
+
files_backup_count: int = _BACKUP_COUNT,
|
563
|
+
files_max_bytes: int = _MAX_BYTES,
|
561
564
|
files_filters: Iterable[_FilterType] | None = None,
|
562
565
|
files_fmt: str = "{_zoned_datetime_str} | {name}:{funcName}:{lineno} | {levelname:8} | {message}",
|
563
566
|
filters: MaybeIterable[_FilterType] | None = None,
|
File without changes
|
File without changes
|