stdl 0.5.2__tar.gz → 0.5.3__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.
- {stdl-0.5.2/stdl.egg-info → stdl-0.5.3}/PKG-INFO +2 -1
- {stdl-0.5.2 → stdl-0.5.3}/pyproject.toml +2 -1
- {stdl-0.5.2 → stdl-0.5.3}/stdl/dt.py +32 -29
- {stdl-0.5.2 → stdl-0.5.3}/stdl/fs.py +23 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl/log.py +7 -7
- {stdl-0.5.2 → stdl-0.5.3}/stdl/st.py +6 -4
- {stdl-0.5.2 → stdl-0.5.3/stdl.egg-info}/PKG-INFO +2 -1
- {stdl-0.5.2 → stdl-0.5.3}/LICENSE +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/README.md +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/setup.cfg +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/setup.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl/__init__.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl/decorators.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl/lst.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl/net.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl.egg-info/SOURCES.txt +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl.egg-info/dependency_links.txt +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl.egg-info/requires.txt +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/stdl.egg-info/top_level.txt +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/tests/test_decorators.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/tests/test_dt.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/tests/test_fs.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/tests/test_lst.py +0 -0
- {stdl-0.5.2 → stdl-0.5.3}/tests/test_st.py +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stdl
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.3
|
|
4
4
|
Summary: Extended Python Standard Library
|
|
5
5
|
Author-email: Žiga Ivanšek <ziga.ivansek@gmail.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/zigai/stdl
|
|
7
|
+
Project-URL: Documentation, https://stdl.readthedocs.io
|
|
7
8
|
Keywords: python utilites,filesystem,string manipulation,logging configuration,list utils,standard library,ANSI colors,terminal output
|
|
8
9
|
Classifier: Intended Audience :: Developers
|
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "stdl"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.3"
|
|
4
4
|
description = "Extended Python Standard Library"
|
|
5
5
|
authors = [{ name = "Žiga Ivanšek", email = "ziga.ivansek@gmail.com" }]
|
|
6
6
|
license = { file = "LICENSE.txt" }
|
|
@@ -52,6 +52,7 @@ dev = [
|
|
|
52
52
|
|
|
53
53
|
[project.urls]
|
|
54
54
|
Repository = "https://github.com/zigai/stdl"
|
|
55
|
+
Documentation = "https://stdl.readthedocs.io"
|
|
55
56
|
|
|
56
57
|
[tool.black]
|
|
57
58
|
line-length = 100
|
|
@@ -45,7 +45,7 @@ class Timer:
|
|
|
45
45
|
Returns:
|
|
46
46
|
TimerStop: The stop data
|
|
47
47
|
"""
|
|
48
|
-
t = time.
|
|
48
|
+
t = time.perf_counter()
|
|
49
49
|
elapsed_total = t - self.start
|
|
50
50
|
since_last = t - self.stops[-1].at if self.stops else 0
|
|
51
51
|
if not self.ms:
|
|
@@ -78,7 +78,7 @@ class Timer:
|
|
|
78
78
|
|
|
79
79
|
def reset(self) -> None:
|
|
80
80
|
"""Reset the timer."""
|
|
81
|
-
self.start = time.
|
|
81
|
+
self.start = time.perf_counter()
|
|
82
82
|
self.stops: list[TimerStop] = [
|
|
83
83
|
TimerStop(
|
|
84
84
|
total=timedelta(seconds=0),
|
|
@@ -114,17 +114,18 @@ def datetime_fmt(
|
|
|
114
114
|
Returns:
|
|
115
115
|
str: Formated date and time.
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
117
|
+
Example:
|
|
118
|
+
```python
|
|
119
|
+
>>> fmt_datetime()
|
|
120
|
+
'2022-11-22 22:40:04' # current date and time
|
|
121
|
+
>>> fmt_datetime(0)
|
|
122
|
+
"1970-01-01 00:00:00"
|
|
123
|
+
>>> fmt_datetime(0, fmt="dmY", dsep="/")
|
|
124
|
+
"01/01/1970 00:00:00"
|
|
125
|
+
```
|
|
125
126
|
"""
|
|
126
127
|
if d is None:
|
|
127
|
-
d = datetime.fromtimestamp(time.
|
|
128
|
+
d = datetime.fromtimestamp(time.perf_counter(), **{"tz": timezone.utc} if utc else {})
|
|
128
129
|
|
|
129
130
|
elif isinstance(d, str):
|
|
130
131
|
d = parse_datetime_str(d)
|
|
@@ -161,7 +162,7 @@ def time_fmt(
|
|
|
161
162
|
str: Formated time.
|
|
162
163
|
"""
|
|
163
164
|
if t is None:
|
|
164
|
-
tm = datetime.fromtimestamp(time.
|
|
165
|
+
tm = datetime.fromtimestamp(time.perf_counter(), **{"tz": timezone.utc} if utc else {})
|
|
165
166
|
elif isinstance(t, datetime):
|
|
166
167
|
tm = t.time()
|
|
167
168
|
elif isinstance(t, (int, float)):
|
|
@@ -194,19 +195,20 @@ def date_fmt(
|
|
|
194
195
|
Returns:
|
|
195
196
|
str: Formated date.
|
|
196
197
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
Example:
|
|
199
|
+
```python
|
|
200
|
+
>>> fmt_date(date(2022,11,22))
|
|
201
|
+
'2022-11-22'
|
|
202
|
+
>>> fmt_date(date(2022,11,22), sep="/")
|
|
203
|
+
'2022/11/22'
|
|
204
|
+
>>> fmt_date(date(2022,11,22), sep="/", fmt="dmY")
|
|
205
|
+
'22/11/2022'
|
|
206
|
+
>>> fmt_date()
|
|
207
|
+
'2022-11-22'
|
|
208
|
+
```
|
|
207
209
|
"""
|
|
208
210
|
if d is None:
|
|
209
|
-
d = date.fromtimestamp(time.
|
|
211
|
+
d = date.fromtimestamp(time.perf_counter())
|
|
210
212
|
elif isinstance(d, (float, int)):
|
|
211
213
|
d = date.fromtimestamp(d)
|
|
212
214
|
elif isinstance(d, datetime):
|
|
@@ -222,12 +224,13 @@ def date_range(start: date, end: date) -> T.Generator[date, None, None]:
|
|
|
222
224
|
"""
|
|
223
225
|
Returns a generator for dates between ``start`` and ``end``
|
|
224
226
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
227
|
+
Example:
|
|
228
|
+
```python
|
|
229
|
+
>>> for i in date_range(date(2022,11,19), date(2022,11,22)): print(i)
|
|
230
|
+
2022-11-19
|
|
231
|
+
2022-11-20
|
|
232
|
+
2022-11-21
|
|
233
|
+
```
|
|
231
234
|
"""
|
|
232
235
|
for n in range(int((end - start).days)):
|
|
233
236
|
yield start + timedelta(n)
|
|
@@ -873,6 +873,29 @@ def ensure_paths_exist(*args: str | PathLike | Iterable[str | PathLike]) -> None
|
|
|
873
873
|
check_path(i)
|
|
874
874
|
|
|
875
875
|
|
|
876
|
+
def ensure_paths_dont_exist(*args: str | PathLike | Iterable[str | PathLike]) -> None:
|
|
877
|
+
"""
|
|
878
|
+
Ensures that the specified paths don't exist.
|
|
879
|
+
|
|
880
|
+
Args:
|
|
881
|
+
*args : one or more strings representing the paths to check. Can also include an Iterable of paths.
|
|
882
|
+
|
|
883
|
+
Raises:
|
|
884
|
+
FileNotFoundError : if one of the provided paths exists.
|
|
885
|
+
"""
|
|
886
|
+
|
|
887
|
+
def check_path(path: str | PathLike):
|
|
888
|
+
if os.path.exists(os.fspath(path)):
|
|
889
|
+
raise FileExistsError(f"Path already exists: {path}")
|
|
890
|
+
|
|
891
|
+
for path in args:
|
|
892
|
+
if isinstance(path, (str, bytes, PathLike)):
|
|
893
|
+
check_path(path)
|
|
894
|
+
elif isinstance(path, Iterable):
|
|
895
|
+
for i in path:
|
|
896
|
+
check_path(i)
|
|
897
|
+
|
|
898
|
+
|
|
876
899
|
class CompletedCommand(subprocess.CompletedProcess):
|
|
877
900
|
def __init__(
|
|
878
901
|
self,
|
|
@@ -22,13 +22,13 @@ class LoguruFormatter:
|
|
|
22
22
|
|
|
23
23
|
def format(self, record: dict) -> str:
|
|
24
24
|
"""
|
|
25
|
-
Example
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
Example:
|
|
26
|
+
```python
|
|
27
|
+
>>> import sys
|
|
28
|
+
>>> from loguru import logger
|
|
29
|
+
>>> logger.remove()
|
|
30
|
+
>>> logger.add(sys.stdout, level="DEBUG", format=loguru_formater)
|
|
31
|
+
```
|
|
32
32
|
"""
|
|
33
33
|
extras = ""
|
|
34
34
|
if len(record["extra"]):
|
|
@@ -203,8 +203,10 @@ def terminal_link(
|
|
|
203
203
|
Returns a hyperlink that can be used in terminals.
|
|
204
204
|
|
|
205
205
|
NOTE:
|
|
206
|
-
Hyperlinks are not supported in all terminals.
|
|
207
|
-
|
|
206
|
+
Hyperlinks are not supported in all terminals.
|
|
207
|
+
For more information visit
|
|
208
|
+
<https://github.com/Alhadis/OSC8-Adoption/>
|
|
209
|
+
and
|
|
208
210
|
<https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda>
|
|
209
211
|
|
|
210
212
|
Args:
|
|
@@ -234,7 +236,7 @@ def remove(s: str, chars: str | set, replace_with: str = "") -> str:
|
|
|
234
236
|
|
|
235
237
|
Args:
|
|
236
238
|
s (str): Input string.
|
|
237
|
-
|
|
239
|
+
chars (str | set): Characters to remove
|
|
238
240
|
replace_with (str, optional): If provided, replace the characters with this value.
|
|
239
241
|
|
|
240
242
|
"""
|
|
@@ -255,7 +257,7 @@ def keep(s: str, chars: str | set, replace_with: str = "") -> str:
|
|
|
255
257
|
|
|
256
258
|
Args:
|
|
257
259
|
s (str): Input string
|
|
258
|
-
|
|
260
|
+
chars (str | set): Characters to keep
|
|
259
261
|
replace_with (str, optional): If provided, replace other characters with this value.
|
|
260
262
|
|
|
261
263
|
"""
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stdl
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.3
|
|
4
4
|
Summary: Extended Python Standard Library
|
|
5
5
|
Author-email: Žiga Ivanšek <ziga.ivansek@gmail.com>
|
|
6
6
|
Project-URL: Repository, https://github.com/zigai/stdl
|
|
7
|
+
Project-URL: Documentation, https://stdl.readthedocs.io
|
|
7
8
|
Keywords: python utilites,filesystem,string manipulation,logging configuration,list utils,standard library,ANSI colors,terminal output
|
|
8
9
|
Classifier: Intended Audience :: Developers
|
|
9
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|