pyutilkit 0.9.0__tar.gz → 0.10.0__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.
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/PKG-INFO +1 -1
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/pyproject.toml +1 -1
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/files.py +1 -1
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/term.py +10 -8
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/timing.py +3 -3
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/LICENSE.md +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/docs/README.md +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/__init__.py +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/classes.py +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/data/__init__.py +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/data/timezones.py +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/date_utils.py +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/py.typed +0 -0
- {pyutilkit-0.9.0 → pyutilkit-0.10.0}/src/pyutilkit/subprocess.py +0 -0
|
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
|
|
|
9
9
|
from collections.abc import Callable
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
|
-
from typing_extensions import ParamSpec # py3.9: import from typing
|
|
12
|
+
from typing_extensions import ParamSpec # upgrade: py3.9: import from typing
|
|
13
13
|
|
|
14
14
|
P = ParamSpec("P")
|
|
15
15
|
|
|
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from collections.abc import Iterable
|
|
12
12
|
|
|
13
|
-
from typing_extensions import Self # py3.10: import from typing
|
|
13
|
+
from typing_extensions import Self # upgrade: py3.10: import from typing
|
|
14
14
|
|
|
15
15
|
TRUE_VAR = {"0", "false", "no"}
|
|
16
16
|
|
|
@@ -69,7 +69,7 @@ class SGRCodes(IntEnum):
|
|
|
69
69
|
|
|
70
70
|
@dataclass(frozen=True, order=True)
|
|
71
71
|
class SGRString:
|
|
72
|
-
__slots__ = ( # py3.9:
|
|
72
|
+
__slots__ = ( # upgrade: py3.9: use __slots__ = True
|
|
73
73
|
"_force_prefix",
|
|
74
74
|
"_force_sgr",
|
|
75
75
|
"_is_error",
|
|
@@ -146,7 +146,7 @@ class SGRString:
|
|
|
146
146
|
is_error=self._is_error,
|
|
147
147
|
)
|
|
148
148
|
|
|
149
|
-
def print(self, end: str =
|
|
149
|
+
def print(self, end: str = os.linesep, *, full_color: bool = False) -> None:
|
|
150
150
|
"""Print the command output.
|
|
151
151
|
|
|
152
152
|
The command will be printed to stdout if it's not the output of an error,
|
|
@@ -159,7 +159,7 @@ class SGRString:
|
|
|
159
159
|
if file.isatty():
|
|
160
160
|
prefix = self._prefix
|
|
161
161
|
sgr_prefix = "".join(code.sequence for code in self._sgr)
|
|
162
|
-
sgr_suffix = SGRCodes.RESET.sequence
|
|
162
|
+
sgr_suffix = SGRCodes.RESET.sequence if self._sgr else ""
|
|
163
163
|
suffix = self._suffix
|
|
164
164
|
else:
|
|
165
165
|
prefix = ""
|
|
@@ -217,12 +217,12 @@ class SGRString:
|
|
|
217
217
|
|
|
218
218
|
@dataclass(frozen=True, order=True)
|
|
219
219
|
class SGROutput:
|
|
220
|
-
__slots__ = ("_strings",) # py3.9:
|
|
220
|
+
__slots__ = ("_strings",) # upgrade: py3.9: use __slots__ = True
|
|
221
221
|
_strings: tuple[SGRString, ...]
|
|
222
222
|
|
|
223
223
|
def __init__(
|
|
224
224
|
self,
|
|
225
|
-
strings: Iterable[
|
|
225
|
+
strings: Iterable[object],
|
|
226
226
|
force_prefix: bool | None = None,
|
|
227
227
|
force_sgr: bool | None = None,
|
|
228
228
|
is_error: bool | None = None,
|
|
@@ -241,11 +241,13 @@ class SGROutput:
|
|
|
241
241
|
|
|
242
242
|
@staticmethod
|
|
243
243
|
def _clean_string(
|
|
244
|
-
string:
|
|
244
|
+
string: object,
|
|
245
245
|
force_prefix: bool | None,
|
|
246
246
|
force_sgr: bool | None,
|
|
247
247
|
is_error: bool | None,
|
|
248
248
|
) -> SGRString:
|
|
249
|
+
if not isinstance(string, SGRString):
|
|
250
|
+
string = SGRString(string)
|
|
249
251
|
force_prefix = (
|
|
250
252
|
string._force_prefix # noqa: SLF001
|
|
251
253
|
if force_prefix is None
|
|
@@ -265,7 +267,7 @@ class SGROutput:
|
|
|
265
267
|
is_error=is_error,
|
|
266
268
|
)
|
|
267
269
|
|
|
268
|
-
def print(self, sep: str = "", end: str =
|
|
270
|
+
def print(self, sep: str = "", end: str = os.linesep) -> None:
|
|
269
271
|
n = len(self._strings)
|
|
270
272
|
for index, string in enumerate(self._strings, start=1):
|
|
271
273
|
current_end = end if index == n else sep
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
1
|
+
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
from time import perf_counter_ns
|
|
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from types import TracebackType
|
|
9
9
|
|
|
10
|
-
from typing_extensions import Self # py3.10: import
|
|
10
|
+
from typing_extensions import Self # upgrade: py3.10: import from typing
|
|
11
11
|
|
|
12
12
|
METRIC_MULTIPLIER = 1000
|
|
13
13
|
SECONDS_PER_MINUTE = 60
|
|
@@ -18,7 +18,7 @@ SECONDS_PER_DAY = SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY
|
|
|
18
18
|
|
|
19
19
|
@dataclass(frozen=True, order=True)
|
|
20
20
|
class Timing:
|
|
21
|
-
__slots__ = ("nanoseconds",) # py3.9:
|
|
21
|
+
__slots__ = ("nanoseconds",) # upgrade: py3.9: use __slots__ = True
|
|
22
22
|
|
|
23
23
|
nanoseconds: int
|
|
24
24
|
|
|
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
|