pyutilkit 0.2.0__py3-none-any.whl → 0.9.0__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.
pyutilkit/__init__.py CHANGED
@@ -1 +0,0 @@
1
- __version__ = "0.2.0"
pyutilkit/classes.py CHANGED
@@ -1,13 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any
3
+ from typing import cast
4
4
 
5
5
 
6
6
  class Singleton(type):
7
7
  instance: type[Singleton] | None
8
8
 
9
9
  def __init__(
10
- cls, name: str, bases: tuple[type[Any], ...], namespace: dict[str, Any]
10
+ cls, name: str, bases: tuple[type[object], ...], namespace: dict[str, object]
11
11
  ) -> None:
12
12
  super().__init__(name, bases, namespace)
13
13
  cls.instance = None
@@ -15,4 +15,4 @@ class Singleton(type):
15
15
  def __call__(cls) -> type[Singleton]:
16
16
  if cls.instance is None:
17
17
  cls.instance = super().__call__()
18
- return cls.instance
18
+ return cast(type[Singleton], cls.instance)
pyutilkit/date_utils.py CHANGED
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from datetime import datetime, tzinfo
4
-
5
4
  from zoneinfo import ZoneInfo, available_timezones
6
5
 
7
6
  from pyutilkit.data.timezones import UNAVAILABLE_TIMEZONES
@@ -10,8 +9,7 @@ UTC = ZoneInfo("UTC")
10
9
 
11
10
 
12
11
  def get_timezones() -> set[str]:
13
- """
14
- Get all the available timezones
12
+ """Get all the available timezones.
15
13
 
16
14
  This takes into accounts timezones that might not be present in
17
15
  all systems.
@@ -24,8 +22,7 @@ def now(tz_info: ZoneInfo = UTC) -> datetime:
24
22
 
25
23
 
26
24
  def from_iso(date_string: str, tz_info: tzinfo = UTC) -> datetime:
27
- """
28
- Get datetime from an iso string
25
+ """Get datetime from an iso string.
29
26
 
30
27
  This to allow the Zulu timezone, which is a valid ISO timezone.
31
28
  """
@@ -38,16 +35,13 @@ def from_iso(date_string: str, tz_info: tzinfo = UTC) -> datetime:
38
35
 
39
36
 
40
37
  def from_timestamp(timestamp: float, tz_info: tzinfo = UTC) -> datetime:
41
- """
42
- Get a datetime tz-aware time object from a timestamp
43
- """
38
+ """Get a datetime tz-aware time object from a timestamp."""
44
39
  utc_dt = datetime.fromtimestamp(timestamp, tz=UTC)
45
40
  return convert_timezone(utc_dt, tz_info)
46
41
 
47
42
 
48
43
  def add_timezone(dt: datetime, tz_info: tzinfo = UTC) -> datetime:
49
- """
50
- Add a timezone to a naive datetime
44
+ """Add a timezone to a naive datetime.
51
45
 
52
46
  Raise an error in case of a tz-aware datetime
53
47
  """
@@ -58,8 +52,7 @@ def add_timezone(dt: datetime, tz_info: tzinfo = UTC) -> datetime:
58
52
 
59
53
 
60
54
  def convert_timezone(dt: datetime, tz_info: tzinfo = UTC) -> datetime:
61
- """
62
- Change the timezone of a tz-aware datetime
55
+ """Change the timezone of a tz-aware datetime.
63
56
 
64
57
  Raise an error in case of a naive datetime
65
58
  """
pyutilkit/files.py CHANGED
@@ -2,12 +2,13 @@ from __future__ import annotations
2
2
 
3
3
  import hashlib
4
4
  import logging
5
- from collections.abc import Callable
6
5
  from functools import wraps
7
- from pathlib import Path
8
6
  from typing import TYPE_CHECKING, TypeVar
9
7
 
10
8
  if TYPE_CHECKING:
9
+ from collections.abc import Callable
10
+ from pathlib import Path
11
+
11
12
  from typing_extensions import ParamSpec # py3.9: import from typing
12
13
 
13
14
  P = ParamSpec("P")
@@ -0,0 +1,55 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from dataclasses import dataclass
5
+ from subprocess import PIPE, Popen
6
+ from typing import TYPE_CHECKING
7
+
8
+ from pyutilkit.timing import Stopwatch, Timing
9
+
10
+ if TYPE_CHECKING:
11
+ from pathlib import Path
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class ProcessOutput:
16
+ stdout: bytes
17
+ stderr: bytes
18
+ pid: int
19
+ returncode: int
20
+ elapsed: Timing
21
+
22
+
23
+ def run_command(
24
+ command: str | list[str],
25
+ cwd: str | Path | None = None,
26
+ env: dict[str, str] | None = None,
27
+ ) -> ProcessOutput:
28
+ stdout = []
29
+ stderr = []
30
+ stopwatch = Stopwatch()
31
+ with stopwatch:
32
+ process = Popen( # noqa: S603
33
+ command, stdout=PIPE, stderr=PIPE, cwd=cwd, env=env
34
+ )
35
+
36
+ for line in process.stdout or []:
37
+ sys.stdout.buffer.write(line)
38
+ sys.stdout.flush()
39
+ stdout.append(line)
40
+
41
+ for line in process.stderr or []:
42
+ sys.stderr.buffer.write(line)
43
+ sys.stderr.flush()
44
+ stderr.append(line)
45
+
46
+ with stopwatch:
47
+ process.wait()
48
+
49
+ return ProcessOutput(
50
+ stdout=b"".join(stdout),
51
+ stderr=b"".join(stderr),
52
+ pid=process.pid,
53
+ returncode=process.returncode,
54
+ elapsed=stopwatch.elapsed,
55
+ )
pyutilkit/term.py CHANGED
@@ -1,14 +1,19 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
- from collections.abc import Iterable
4
+ import sys
5
+ from dataclasses import dataclass
5
6
  from enum import IntEnum, unique
6
7
  from math import ceil, floor
7
- from typing import TYPE_CHECKING, Any
8
+ from typing import TYPE_CHECKING
8
9
 
9
10
  if TYPE_CHECKING:
11
+ from collections.abc import Iterable
12
+
10
13
  from typing_extensions import Self # py3.10: import from typing
11
14
 
15
+ TRUE_VAR = {"0", "false", "no"}
16
+
12
17
 
13
18
  @unique
14
19
  class SGRCodes(IntEnum):
@@ -62,40 +67,126 @@ class SGRCodes(IntEnum):
62
67
  return f"\033[{self.value}m"
63
68
 
64
69
 
65
- class SGRString(str):
66
- _sgr: tuple[SGRCodes, ...]
67
- _string: str
68
- __slots__ = ("_sgr", "_string")
70
+ @dataclass(frozen=True, order=True)
71
+ class SGRString:
72
+ __slots__ = ( # py3.9: remove this line
73
+ "_force_prefix",
74
+ "_force_sgr",
75
+ "_is_error",
76
+ "_prefix",
77
+ "_sgr",
78
+ "_string",
79
+ "_suffix",
80
+ )
69
81
 
70
- def __new__(cls, obj: Any, *, params: Iterable[SGRCodes] = ()) -> Self:
71
- string = super().__new__(cls, obj)
72
- object.__setattr__(string, "_string", str(obj))
73
- object.__setattr__(string, "_sgr", tuple(params))
74
- return string
82
+ _string: str
83
+ _sgr: tuple[SGRCodes, ...]
84
+ _prefix: str
85
+ _suffix: str
86
+ _force_prefix: bool
87
+ _force_sgr: bool
88
+ _is_error: bool
75
89
 
76
- def __setattr__(self, name: str, value: Any) -> None:
77
- msg = "SGRString is immutable"
78
- raise AttributeError(msg)
90
+ def __init__(
91
+ self,
92
+ obj: object,
93
+ *,
94
+ prefix: str = "",
95
+ suffix: str = "",
96
+ params: Iterable[SGRCodes] = (),
97
+ force_prefix: bool = False,
98
+ force_sgr: bool = False,
99
+ is_error: bool = False,
100
+ ) -> None:
101
+ params = tuple(params)
102
+ force_prefix = (
103
+ force_prefix or os.getenv("PY_UTIL_FORCE_PREFIX", "").lower() in TRUE_VAR
104
+ )
105
+ force_sgr = force_sgr or os.getenv("PY_UTIL_FORCE_SGR", "").lower() in TRUE_VAR
79
106
 
80
- def __delattr__(self, name: str) -> None:
81
- msg = "SGRString is immutable"
82
- raise AttributeError(msg)
107
+ object.__setattr__(self, "_prefix", prefix)
108
+ object.__setattr__(self, "_string", str(obj))
109
+ object.__setattr__(self, "_sgr", params)
110
+ object.__setattr__(self, "_suffix", suffix)
111
+ object.__setattr__(self, "_force_prefix", force_prefix)
112
+ object.__setattr__(self, "_force_sgr", force_sgr)
113
+ object.__setattr__(self, "_is_error", is_error)
83
114
 
84
115
  def __str__(self) -> str:
85
- if not self._sgr:
86
- return self._string
87
- prefix = "".join(code.sequence for code in self._sgr)
88
- return f"{prefix}{self._string}{SGRCodes.RESET.sequence}"
116
+ sgr_prefix = "".join(code.sequence for code in self._sgr)
117
+ sgr_suffix = SGRCodes.RESET.sequence if self._sgr else ""
118
+ return f"{self._prefix}{sgr_prefix}{self._string}{sgr_suffix}{self._suffix}"
89
119
 
90
- def __mul__(self, other: Any) -> Self:
120
+ def __len__(self) -> int:
121
+ return len(self._prefix) + len(self._string) + len(self._suffix)
122
+
123
+ def __mul__(self, other: object) -> Self:
91
124
  if not isinstance(other, int):
92
125
  return NotImplemented
93
- return type(self)(self._string * other, params=self._sgr)
126
+ return type(self)(
127
+ self._string * other,
128
+ prefix=self._prefix,
129
+ suffix=self._suffix,
130
+ params=self._sgr,
131
+ force_prefix=self._force_prefix,
132
+ force_sgr=self._force_sgr,
133
+ is_error=self._is_error,
134
+ )
94
135
 
95
- def __rmul__(self, other: Any) -> Self:
136
+ def __rmul__(self, other: object) -> Self:
96
137
  if not isinstance(other, int):
97
138
  return NotImplemented
98
- return type(self)(self._string * other, params=self._sgr)
139
+ return type(self)(
140
+ self._string * other,
141
+ prefix=self._prefix,
142
+ suffix=self._suffix,
143
+ params=self._sgr,
144
+ force_prefix=self._force_prefix,
145
+ force_sgr=self._force_sgr,
146
+ is_error=self._is_error,
147
+ )
148
+
149
+ def print(self, end: str = "\n", *, full_color: bool = False) -> None:
150
+ """Print the command output.
151
+
152
+ The command will be printed to stdout if it's not the output of an error,
153
+ otherwise to stderr.
154
+
155
+ If the output stream isn't a tty, it will strip the SGR codes and the prefix,
156
+ unless forced to keep them.
157
+ """
158
+ file = sys.stderr if self._is_error else sys.stdout
159
+ if file.isatty():
160
+ prefix = self._prefix
161
+ sgr_prefix = "".join(code.sequence for code in self._sgr)
162
+ sgr_suffix = SGRCodes.RESET.sequence
163
+ suffix = self._suffix
164
+ else:
165
+ prefix = ""
166
+ sgr_prefix = ""
167
+ sgr_suffix = ""
168
+ suffix = ""
169
+ if self._force_sgr:
170
+ sgr_prefix = "".join(code.sequence for code in self._sgr)
171
+ sgr_suffix = SGRCodes.RESET.sequence if self._sgr else ""
172
+ if self._force_prefix:
173
+ prefix = self._prefix
174
+ suffix = self._suffix
175
+
176
+ if full_color:
177
+ prefix, sgr_prefix = sgr_prefix, prefix
178
+ suffix, sgr_suffix = sgr_suffix, suffix
179
+
180
+ print(
181
+ prefix,
182
+ sgr_prefix,
183
+ self._string,
184
+ sgr_suffix,
185
+ suffix,
186
+ sep="",
187
+ end=end,
188
+ file=file,
189
+ )
99
190
 
100
191
  def header(
101
192
  self,
@@ -105,12 +196,97 @@ class SGRString(str):
105
196
  right_spaces: int = 1,
106
197
  space: str = " ",
107
198
  ) -> None:
108
- columns = os.get_terminal_size().columns
109
- text = f"{space * left_spaces}{self}{space * right_spaces}"
199
+ try:
200
+ terminal_size = os.get_terminal_size()
201
+ except OSError:
202
+ # in pseudo-terminals an OSError is thrown
203
+ self.print()
204
+ return
205
+
206
+ columns = terminal_size.columns
110
207
  title_length = left_spaces + len(self) + right_spaces
111
208
  if title_length >= columns:
112
- print(text.strip())
209
+ self.print()
113
210
  return
114
211
 
115
212
  half = (columns - title_length) / 2
116
- print(f"{padding * ceil(half)}{text}{padding * floor(half)}")
213
+ prefix = f"{padding * ceil(half)}{space * left_spaces}{self._prefix}"
214
+ suffix = f"{self._suffix}{space * right_spaces}{padding * floor(half)}"
215
+ type(self)(self._string, prefix=prefix, suffix=suffix, params=self._sgr).print()
216
+
217
+
218
+ @dataclass(frozen=True, order=True)
219
+ class SGROutput:
220
+ __slots__ = ("_strings",) # py3.9: remove this line
221
+ _strings: tuple[SGRString, ...]
222
+
223
+ def __init__(
224
+ self,
225
+ strings: Iterable[SGRString],
226
+ force_prefix: bool | None = None,
227
+ force_sgr: bool | None = None,
228
+ is_error: bool | None = None,
229
+ ) -> None:
230
+ strings = tuple(
231
+ self._clean_string(
232
+ string,
233
+ force_prefix=force_prefix,
234
+ force_sgr=force_sgr,
235
+ is_error=is_error,
236
+ )
237
+ for string in strings
238
+ )
239
+
240
+ object.__setattr__(self, "_strings", strings)
241
+
242
+ @staticmethod
243
+ def _clean_string(
244
+ string: SGRString,
245
+ force_prefix: bool | None,
246
+ force_sgr: bool | None,
247
+ is_error: bool | None,
248
+ ) -> SGRString:
249
+ force_prefix = (
250
+ string._force_prefix # noqa: SLF001
251
+ if force_prefix is None
252
+ else force_prefix
253
+ )
254
+ force_sgr = (
255
+ string._force_sgr if force_sgr is None else force_sgr # noqa: SLF001
256
+ )
257
+ is_error = string._is_error if is_error is None else is_error # noqa: SLF001
258
+ return SGRString(
259
+ string._string, # noqa: SLF001
260
+ prefix=string._prefix, # noqa: SLF001
261
+ suffix=string._suffix, # noqa: SLF001
262
+ params=string._sgr, # noqa: SLF001
263
+ force_prefix=force_prefix,
264
+ force_sgr=force_sgr,
265
+ is_error=is_error,
266
+ )
267
+
268
+ def print(self, sep: str = "", end: str = "\n") -> None:
269
+ n = len(self._strings)
270
+ for index, string in enumerate(self._strings, start=1):
271
+ current_end = end if index == n else sep
272
+ string.print(end=current_end)
273
+
274
+ def header(
275
+ self,
276
+ *,
277
+ padding: str = " ",
278
+ left_spaces: int = 1,
279
+ right_spaces: int = 1,
280
+ space: str = " ",
281
+ ) -> None:
282
+ n = len(self._strings)
283
+ if n > 1:
284
+ msg = "Only one string is allowed for the header"
285
+ raise ValueError(msg)
286
+
287
+ self._strings[0].header(
288
+ padding=padding,
289
+ left_spaces=left_spaces,
290
+ right_spaces=right_spaces,
291
+ space=space,
292
+ )
pyutilkit/timing.py CHANGED
@@ -1,4 +1,19 @@
1
+ from __future__ import annotations # py3.9: remove this line
2
+
1
3
  from dataclasses import dataclass
4
+ from time import perf_counter_ns
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from types import TracebackType
9
+
10
+ from typing_extensions import Self # py3.10: import Self from typing
11
+
12
+ METRIC_MULTIPLIER = 1000
13
+ SECONDS_PER_MINUTE = 60
14
+ MINUTES_PER_HOUR = 60
15
+ HOURS_PER_DAY = 24
16
+ SECONDS_PER_DAY = SECONDS_PER_MINUTE * MINUTES_PER_HOUR * HOURS_PER_DAY
2
17
 
3
18
 
4
19
  @dataclass(frozen=True, order=True)
@@ -18,21 +33,98 @@ class Timing:
18
33
  ) -> None:
19
34
  total_nanoseconds = (
20
35
  nanoseconds
21
- + 1000 * microseconds
22
- + 1_000_000 * milliseconds
23
- + 1_000_000_000 * seconds
24
- + 86_400_000_000_000 * days
36
+ + METRIC_MULTIPLIER * microseconds
37
+ + METRIC_MULTIPLIER**2 * milliseconds
38
+ + METRIC_MULTIPLIER**3 * seconds
39
+ + SECONDS_PER_DAY * METRIC_MULTIPLIER**3 * days
25
40
  )
26
41
  object.__setattr__(self, "nanoseconds", total_nanoseconds)
27
42
 
28
43
  def __str__(self) -> str:
29
- if self.nanoseconds < 1000:
44
+ if self.nanoseconds < METRIC_MULTIPLIER:
30
45
  return f"{self.nanoseconds}ns"
31
- microseconds = self.nanoseconds / 1000
32
- if microseconds < 1000:
46
+ microseconds = self.nanoseconds / METRIC_MULTIPLIER
47
+ if microseconds < METRIC_MULTIPLIER:
33
48
  return f"{microseconds:.1f}µs"
34
- milliseconds = microseconds / 1000
35
- if milliseconds < 1000:
49
+ milliseconds = microseconds / METRIC_MULTIPLIER
50
+ if milliseconds < METRIC_MULTIPLIER:
36
51
  return f"{milliseconds:.1f}ms"
37
- seconds = milliseconds / 1000
38
- return f"{seconds:,.2f}s"
52
+ seconds = milliseconds / METRIC_MULTIPLIER
53
+ if seconds < SECONDS_PER_MINUTE:
54
+ return f"{seconds:.2f}s"
55
+ round_seconds = int(seconds)
56
+ minutes, seconds = divmod(round_seconds, SECONDS_PER_MINUTE)
57
+ hours, minutes = divmod(minutes, MINUTES_PER_HOUR)
58
+ if hours < HOURS_PER_DAY:
59
+ return f"{hours:02d}:{minutes:02d}:{seconds:02d}"
60
+ days, hours = divmod(hours, HOURS_PER_DAY)
61
+ return f"{days:,}d {hours:02d}:{minutes:02d}:{seconds:02d}"
62
+
63
+ def __bool__(self) -> bool:
64
+ return bool(self.nanoseconds)
65
+
66
+ def __add__(self, other: object) -> Timing:
67
+ if not isinstance(other, Timing):
68
+ return NotImplemented
69
+ return Timing(nanoseconds=self.nanoseconds + other.nanoseconds)
70
+
71
+ def __radd__(self, other: object) -> Timing:
72
+ if not isinstance(other, Timing):
73
+ return NotImplemented
74
+ return Timing(nanoseconds=self.nanoseconds + other.nanoseconds)
75
+
76
+ def __mul__(self, other: object) -> Timing:
77
+ if not isinstance(other, int):
78
+ return NotImplemented
79
+ return Timing(nanoseconds=self.nanoseconds * other)
80
+
81
+ def __rmul__(self, other: object) -> Timing:
82
+ if not isinstance(other, int):
83
+ return NotImplemented
84
+ return Timing(nanoseconds=self.nanoseconds * other)
85
+
86
+ def __floordiv__(self, other: object) -> Timing:
87
+ if not isinstance(other, int):
88
+ return NotImplemented
89
+ return Timing(nanoseconds=self.nanoseconds // other)
90
+
91
+ def __truediv__(self, other: object) -> Timing:
92
+ if not isinstance(other, int):
93
+ return NotImplemented
94
+ return Timing(nanoseconds=round(self.nanoseconds / other))
95
+
96
+
97
+ class Stopwatch:
98
+ _start: int
99
+ laps: list[Timing]
100
+
101
+ def __init__(self) -> None:
102
+ self._start = 0
103
+ self.laps: list[Timing] = []
104
+
105
+ def __enter__(self) -> Self:
106
+ self._start = perf_counter_ns()
107
+ return self
108
+
109
+ def __exit__(
110
+ self,
111
+ exc_type: type[BaseException] | None,
112
+ exc_value: BaseException | None,
113
+ traceback: TracebackType | None,
114
+ ) -> None:
115
+ _end = perf_counter_ns()
116
+ self.laps.append(Timing(nanoseconds=_end - self._start))
117
+
118
+ def __bool__(self) -> bool:
119
+ return bool(self.elapsed)
120
+
121
+ @property
122
+ def elapsed(self) -> Timing:
123
+ return sum(self.laps, Timing())
124
+
125
+ @property
126
+ def average(self) -> Timing:
127
+ if not self.laps:
128
+ msg = "No laps recorded"
129
+ raise ZeroDivisionError(msg)
130
+ return self.elapsed // len(self.laps)
@@ -0,0 +1,11 @@
1
+ # BSD 3-Clause License
2
+
3
+ Copyright &copy; 2024 Stephanos Kuma.
4
+
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,28 +1,26 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pyutilkit
3
- Version: 0.2.0
3
+ Version: 0.9.0
4
4
  Summary: python's missing batteries
5
5
  Home-page: https://pyutilkit.readthedocs.io/en/stable/
6
- License: LGPL-3.0+
6
+ License: BSD-3-Clause
7
7
  Keywords: utils
8
8
  Author: Stephanos Kuma
9
- Author-email: stephanos@kuma.ai
10
- Requires-Python: >=3.8,<4.0
9
+ Author-email: "Stephanos Kuma" <stephanos@kuma.ai>
10
+ Requires-Python: >=3.9
11
11
  Classifier: Development Status :: 4 - Beta
12
- Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
12
+ Classifier: License :: OSI Approved :: BSD License
13
13
  Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Requires-Dist: tzdata ; os_name == 'nt'
20
16
  Project-URL: Documentation, https://pyutilkit.readthedocs.io/en/stable/
21
17
  Project-URL: Repository, https://github.com/spapanik/pyutilkit
22
18
  Description-Content-Type: text/markdown
23
19
 
24
20
  # pyutilkit: python's missing batteries
25
21
 
22
+ [![build][build_badge]][build_url]
23
+ [![lint][lint_badge]][lint_url]
26
24
  [![tests][test_badge]][test_url]
27
25
  [![license][licence_badge]][licence_url]
28
26
  [![pypi][pypi_badge]][pypi_url]
@@ -31,17 +29,25 @@ Description-Content-Type: text/markdown
31
29
  [![build automation: yam][yam_badge]][yam_url]
32
30
  [![Lint: ruff][ruff_badge]][ruff_url]
33
31
 
34
- Long project description and tldr goes here
32
+ The Python has long maintained the philosophy of "batteries included", giving the user
33
+ a rich standard library, avoiding the need for third party tools for most work. Some packages
34
+ are so common, that the have a similar status to the standard library. Still, some code seems
35
+ to be written time and again, with every project. This small library, with minimal requirements,
36
+ hopes to stop this repetition.
35
37
 
36
38
  ## Links
37
39
 
38
40
  - [Documentation]
39
41
  - [Changelog]
40
42
 
43
+ [build_badge]: https://github.com/spapanik/pyutilkit/actions/workflows/build.yml/badge.svg
44
+ [build_url]: https://github.com/spapanik/pyutilkit/actions/workflows/build.yml
45
+ [lint_badge]: https://github.com/spapanik/pyutilkit/actions/workflows/lint.yml/badge.svg
46
+ [lint_url]: https://github.com/spapanik/pyutilkit/actions/workflows/lint.yml
41
47
  [test_badge]: https://github.com/spapanik/pyutilkit/actions/workflows/tests.yml/badge.svg
42
48
  [test_url]: https://github.com/spapanik/pyutilkit/actions/workflows/tests.yml
43
- [licence_badge]: https://img.shields.io/badge/License-LGPL_v3-blue.svg
44
- [licence_url]: https://github.com/spapanik/pyutilkit/blob/main/docs/LICENSE.md
49
+ [licence_badge]: https://img.shields.io/pypi/l/pyutilkit
50
+ [licence_url]: https://pyutilkit.readthedocs.io/en/stable/LICENSE/
45
51
  [pypi_badge]: https://img.shields.io/pypi/v/pyutilkit
46
52
  [pypi_url]: https://pypi.org/project/pyutilkit
47
53
  [pepy_badge]: https://pepy.tech/badge/pyutilkit
@@ -53,5 +59,4 @@ Long project description and tldr goes here
53
59
  [ruff_badge]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json
54
60
  [ruff_url]: https://github.com/charliermarsh/ruff
55
61
  [Documentation]: https://pyutilkit.readthedocs.io/en/stable/
56
- [Changelog]: https://github.com/spapanik/pyutilkit/blob/main/docs/CHANGELOG.md
57
-
62
+ [Changelog]: https://pyutilkit.readthedocs.io/en/stable/CHANGELOG/
@@ -0,0 +1,14 @@
1
+ pyutilkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ pyutilkit/classes.py,sha256=kW7SNwNNV2kyNJV9A_AlTi3ntvMPgDCc-WyMi6WOVbg,492
3
+ pyutilkit/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ pyutilkit/data/timezones.py,sha256=p67f7VXrKCWNoKv8NQ4yEHOFI_zV9zpViEBsiC_IE-U,3866
5
+ pyutilkit/date_utils.py,sha256=nGvNINVrB9-t44cCb6I_EV1L1yfj-LN7Di5o8TspckM,1795
6
+ pyutilkit/files.py,sha256=UjlZcDVHm0hfT3nDAnWVvuhjJUuROcScUuBf2k_b_Ls,1532
7
+ pyutilkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pyutilkit/subprocess.py,sha256=z4ofOc26t5sTuNchxZ0ry4E01dV1WTLQLfC1bRcET8o,1255
9
+ pyutilkit/term.py,sha256=Io7jkAsgDq26cBYOXuOvhzzNIq-AJGUGDrmVfJdoDhs,8167
10
+ pyutilkit/timing.py,sha256=vI-BIIelgYs38rjeadPTcjdxL8MK0ZbL0xaG_5O9Vdo,4133
11
+ pyutilkit-0.9.0.dist-info/LICENSE.md,sha256=OKRoxApqqyiqCH9m0r3h3_qksZC5nFH_smD-NhuI_EQ,1489
12
+ pyutilkit-0.9.0.dist-info/METADATA,sha256=IZIePO4-E1voL50M-5Dc1RjJg6unOL-Yt0TaljM8oFA,2893
13
+ pyutilkit-0.9.0.dist-info/WHEEL,sha256=vg2djHPphy5dcL8Ln2pQT6VaPK9QplSR-ynKOufIcA0,87
14
+ pyutilkit-0.9.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: phosphorus 0.8.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,159 +0,0 @@
1
- # GNU LESSER GENERAL PUBLIC LICENSE
2
-
3
- Version 3, 29 June 2007
4
-
5
- Copyright &copy; 2007 Free Software Foundation, Inc.
6
- [https://fsf.org/][FSF]
7
-
8
- Everyone is permitted to copy and distribute verbatim copies of this
9
- license document, but changing it is not allowed.
10
-
11
- This version of the GNU Lesser General Public License incorporates the
12
- terms and conditions of version 3 of the GNU General Public License,
13
- supplemented by the additional permissions listed below.
14
-
15
- ## 0. Additional Definitions.
16
-
17
- As used herein, "this License" refers to version 3 of the GNU Lesser
18
- General Public License, and the "GNU GPL" refers to version 3 of the
19
- GNU General Public License.
20
-
21
- "The Library" refers to a covered work governed by this License, other
22
- than an Application or a Combined Work as defined below.
23
-
24
- An "Application" is any work that makes use of an interface provided
25
- by the Library, but which is not otherwise based on the Library.
26
- Defining a subclass of a class defined by the Library is deemed a mode
27
- of using an interface provided by the Library.
28
-
29
- A "Combined Work" is a work produced by combining or linking an
30
- Application with the Library. The particular version of the Library
31
- with which the Combined Work was made is also called the "Linked
32
- Version".
33
-
34
- The "Minimal Corresponding Source" for a Combined Work means the
35
- Corresponding Source for the Combined Work, excluding any source code
36
- for portions of the Combined Work that, considered in isolation, are
37
- based on the Application, and not on the Linked Version.
38
-
39
- The "Corresponding Application Code" for a Combined Work means the
40
- object code and/or source code for the Application, including any data
41
- and utility programs needed for reproducing the Combined Work from the
42
- Application, but excluding the System Libraries of the Combined Work.
43
-
44
- ## 1. Exception to Section 3 of the GNU GPL.
45
-
46
- You may convey a covered work under sections 3 and 4 of this License
47
- without being bound by section 3 of the GNU GPL.
48
-
49
- ## 2. Conveying Modified Versions.
50
-
51
- If you modify a copy of the Library, and, in your modifications, a
52
- facility refers to a function or data to be supplied by an Application
53
- that uses the facility (other than as an argument passed when the
54
- facility is invoked), then you may convey a copy of the modified
55
- version:
56
-
57
- - a) under this License, provided that you make a good faith effort
58
- to ensure that, in the event an Application does not supply the
59
- function or data, the facility still operates, and performs
60
- whatever part of its purpose remains meaningful, or
61
- - b) under the GNU GPL, with none of the additional permissions of
62
- this License applicable to that copy.
63
-
64
- ## 3. Object Code Incorporating Material from Library Header Files.
65
-
66
- The object code form of an Application may incorporate material from a
67
- header file that is part of the Library. You may convey such object
68
- code under terms of your choice, provided that, if the incorporated
69
- material is not limited to numerical parameters, data structure
70
- layouts and accessors, or small macros, inline functions and templates
71
- (ten or fewer lines in length), you do both of the following:
72
-
73
- - a) Give prominent notice with each copy of the object code that
74
- the Library is used in it and that the Library and its use are
75
- covered by this License.
76
- - b) Accompany the object code with a copy of the GNU GPL and this
77
- license document.
78
-
79
- ## 4. Combined Works.
80
-
81
- You may convey a Combined Work under terms of your choice that, taken
82
- together, effectively do not restrict modification of the portions of
83
- the Library contained in the Combined Work and reverse engineering for
84
- debugging such modifications, if you also do each of the following:
85
-
86
- - a) Give prominent notice with each copy of the Combined Work that
87
- the Library is used in it and that the Library and its use are
88
- covered by this License.
89
- - b) Accompany the Combined Work with a copy of the GNU GPL and this
90
- license document.
91
- - c) For a Combined Work that displays copyright notices during
92
- execution, include the copyright notice for the Library among
93
- these notices, as well as a reference directing the user to the
94
- copies of the GNU GPL and this license document.
95
- - d) Do one of the following:
96
- - 0. Convey the Minimal Corresponding Source under the terms of
97
- this License, and the Corresponding Application Code in a form
98
- suitable for, and under terms that permit, the user to
99
- recombine or relink the Application with a modified version of
100
- the Linked Version to produce a modified Combined Work, in the
101
- manner specified by section 6 of the GNU GPL for conveying
102
- Corresponding Source.
103
- - 1. Use a suitable shared library mechanism for linking with
104
- the Library. A suitable mechanism is one that (a) uses at run
105
- time a copy of the Library already present on the user's
106
- computer system, and (b) will operate properly with a modified
107
- version of the Library that is interface-compatible with the
108
- Linked Version.
109
- - e) Provide Installation Information, but only if you would
110
- otherwise be required to provide such information under section 6
111
- of the GNU GPL, and only to the extent that such information is
112
- necessary to install and execute a modified version of the
113
- Combined Work produced by recombining or relinking the Application
114
- with a modified version of the Linked Version. (If you use option
115
- 4d0, the Installation Information must accompany the Minimal
116
- Corresponding Source and Corresponding Application Code. If you
117
- use option 4d1, you must provide the Installation Information in
118
- the manner specified by section 6 of the GNU GPL for conveying
119
- Corresponding Source.)
120
-
121
- ## 5. Combined Libraries.
122
-
123
- You may place library facilities that are a work based on the Library
124
- side by side in a single library together with other library
125
- facilities that are not Applications and are not covered by this
126
- License, and convey such a combined library under terms of your
127
- choice, if you do both of the following:
128
-
129
- - a) Accompany the combined library with a copy of the same work
130
- based on the Library, uncombined with any other library
131
- facilities, conveyed under the terms of this License.
132
- - b) Give prominent notice with the combined library that part of it
133
- is a work based on the Library, and explaining where to find the
134
- accompanying uncombined form of the same work.
135
-
136
- ## 6. Revised Versions of the GNU Lesser General Public License.
137
-
138
- The Free Software Foundation may publish revised and/or new versions
139
- of the GNU Lesser General Public License from time to time. Such new
140
- versions will be similar in spirit to the present version, but may
141
- differ in detail to address new problems or concerns.
142
-
143
- Each version is given a distinguishing version number. If the Library
144
- as you received it specifies that a certain numbered version of the
145
- GNU Lesser General Public License "or any later version" applies to
146
- it, you have the option of following the terms and conditions either
147
- of that published version or of any later version published by the
148
- Free Software Foundation. If the Library as you received it does not
149
- specify a version number of the GNU Lesser General Public License, you
150
- may choose any version of the GNU Lesser General Public License ever
151
- published by the Free Software Foundation.
152
-
153
- If the Library as you received it specifies that a proxy can decide
154
- whether future versions of the GNU Lesser General Public License shall
155
- apply, that proxy's public statement of acceptance of any version is
156
- permanent authorization for you to choose that version for the
157
- Library.
158
-
159
- [FSF]: https://www.fsf.org/
@@ -1,13 +0,0 @@
1
- pyutilkit/__init__.py,sha256=Zn1KFblwuFHiDRdRAiRnDBRkbPttWh44jKa5zG2ov0E,22
2
- pyutilkit/classes.py,sha256=DKGhYjpXXEr9BU8HFRygLJ4TPTIu0zp1bwL4TBTE_L4,462
3
- pyutilkit/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- pyutilkit/data/timezones.py,sha256=p67f7VXrKCWNoKv8NQ4yEHOFI_zV9zpViEBsiC_IE-U,3866
5
- pyutilkit/date_utils.py,sha256=JXYdN8ZLzRWPCC1A7ZSWgYBaHRbGERXqRS-6vH-oxOc,1821
6
- pyutilkit/files.py,sha256=bSfgplXNsAJtCTmkOBox1sh3Ce3iKg1k0CCxspSWbZ8,1523
7
- pyutilkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pyutilkit/term.py,sha256=lh5aZ3i3ka5aFBZz01NgYVVNRtHeu8rB4m3M3pLkKw8,2895
9
- pyutilkit/timing.py,sha256=7mT_uTFdEaQ7yw8JhLoUoonDHgr0qqOI03G0aB4YMM0,1073
10
- pyutilkit-0.2.0.dist-info/LICENSE.md,sha256=FnxbGtGgwsbyf1AA3Mz_Rja94ersC7tTZSTCyPgB0pI,7696
11
- pyutilkit-0.2.0.dist-info/METADATA,sha256=2uFxTqBz1byZNIBI1BO_Ws2ytiy3YKYAMCdjkgm7dEs,2402
12
- pyutilkit-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
- pyutilkit-0.2.0.dist-info/RECORD,,