stdl 0.5.0__tar.gz → 0.5.2__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.0/stdl.egg-info → stdl-0.5.2}/PKG-INFO +29 -6
- stdl-0.5.2/README.md +38 -0
- {stdl-0.5.0 → stdl-0.5.2}/pyproject.toml +19 -3
- stdl-0.5.2/stdl/__init__.py +1 -0
- {stdl-0.5.0 → stdl-0.5.2}/stdl/decorators.py +6 -3
- {stdl-0.5.0 → stdl-0.5.2}/stdl/dt.py +16 -20
- {stdl-0.5.0 → stdl-0.5.2}/stdl/fs.py +205 -164
- {stdl-0.5.0 → stdl-0.5.2}/stdl/log.py +4 -2
- {stdl-0.5.0 → stdl-0.5.2}/stdl/lst.py +8 -18
- {stdl-0.5.0 → stdl-0.5.2}/stdl/net.py +3 -3
- {stdl-0.5.0 → stdl-0.5.2}/stdl/st.py +8 -7
- {stdl-0.5.0 → stdl-0.5.2/stdl.egg-info}/PKG-INFO +29 -6
- {stdl-0.5.0 → stdl-0.5.2}/stdl.egg-info/SOURCES.txt +0 -1
- stdl-0.5.2/stdl.egg-info/requires.txt +16 -0
- {stdl-0.5.0 → stdl-0.5.2}/tests/test_fs.py +32 -0
- stdl-0.5.2/tests/test_st.py +128 -0
- stdl-0.5.0/README.md +0 -20
- stdl-0.5.0/stdl/__init__.py +0 -1
- stdl-0.5.0/stdl/dataclass.py +0 -45
- stdl-0.5.0/stdl.egg-info/requires.txt +0 -11
- stdl-0.5.0/tests/test_st.py +0 -41
- {stdl-0.5.0 → stdl-0.5.2}/LICENSE +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/setup.cfg +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/setup.py +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/stdl.egg-info/dependency_links.txt +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/stdl.egg-info/top_level.txt +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/tests/test_decorators.py +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/tests/test_dt.py +0 -0
- {stdl-0.5.0 → stdl-0.5.2}/tests/test_lst.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stdl
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
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
|
-
Keywords: python utilites,filesystem,string manipulation,logging configuration,list utils,standard library
|
|
7
|
+
Keywords: python utilites,filesystem,string manipulation,logging configuration,list utils,standard library,ANSI colors,terminal output
|
|
8
8
|
Classifier: Intended Audience :: Developers
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
@@ -19,23 +19,46 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: PyYAML>=6.0
|
|
21
21
|
Requires-Dist: tqdm
|
|
22
|
-
Requires-Dist: python-dateutil
|
|
22
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
23
|
+
Requires-Dist: toml>=0.10.2
|
|
23
24
|
Provides-Extra: test
|
|
24
25
|
Requires-Dist: pytest; extra == "test"
|
|
25
26
|
Provides-Extra: dev
|
|
26
27
|
Requires-Dist: black; extra == "dev"
|
|
27
28
|
Requires-Dist: pytest; extra == "dev"
|
|
28
29
|
Requires-Dist: ruff; extra == "dev"
|
|
30
|
+
Requires-Dist: mkdocs; extra == "dev"
|
|
31
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
32
|
+
Requires-Dist: mkdocs-autorefs; extra == "dev"
|
|
33
|
+
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
29
34
|
|
|
30
35
|
# stdl
|
|
31
36
|
[](https://github.com/zigai/stdl/actions/workflows/tests.yml)
|
|
37
|
+
[](https://stdl.readthedocs.io/en/latest/?badge=latest)
|
|
32
38
|
[](https://badge.fury.io/py/stdl)
|
|
33
39
|

|
|
34
40
|
[](https://pepy.tech/project/stdl)
|
|
35
41
|
[](https://github.com/zigai/stdl/blob/master/LICENSE)
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
`stdl` is a collection of Python utilities that complement the standard library. It provides common functions and tools that developers frequently need, with minimal external dependencies.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
- File and directory operations
|
|
47
|
+
- String manipulation
|
|
48
|
+
- ANSI color support for terminal output
|
|
49
|
+
- Date and time formatting
|
|
50
|
+
- List processing
|
|
51
|
+
- Function decorators
|
|
52
|
+
- Logging configuration for `logging` and `loguru`
|
|
53
|
+
- [See docs](https://stdl.readthedocs.io/en/latest/?badge=latest)
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
- PyYAML
|
|
57
|
+
- python-dateutil
|
|
58
|
+
- toml
|
|
59
|
+
- tqdm
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
39
62
|
|
|
40
63
|
#### Using pip
|
|
41
64
|
```
|
|
@@ -45,5 +68,5 @@ pip install stdl
|
|
|
45
68
|
```
|
|
46
69
|
pip install git+https://github.com/zigai/stdl
|
|
47
70
|
```
|
|
48
|
-
|
|
71
|
+
## License
|
|
49
72
|
[MIT License](https://github.com/zigai/stdl/blob/master/LICENSE)
|
stdl-0.5.2/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# stdl
|
|
2
|
+
[](https://github.com/zigai/stdl/actions/workflows/tests.yml)
|
|
3
|
+
[](https://stdl.readthedocs.io/en/latest/?badge=latest)
|
|
4
|
+
[](https://badge.fury.io/py/stdl)
|
|
5
|
+

|
|
6
|
+
[](https://pepy.tech/project/stdl)
|
|
7
|
+
[](https://github.com/zigai/stdl/blob/master/LICENSE)
|
|
8
|
+
|
|
9
|
+
`stdl` is a collection of Python utilities that complement the standard library. It provides common functions and tools that developers frequently need, with minimal external dependencies.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
- File and directory operations
|
|
13
|
+
- String manipulation
|
|
14
|
+
- ANSI color support for terminal output
|
|
15
|
+
- Date and time formatting
|
|
16
|
+
- List processing
|
|
17
|
+
- Function decorators
|
|
18
|
+
- Logging configuration for `logging` and `loguru`
|
|
19
|
+
- [See docs](https://stdl.readthedocs.io/en/latest/?badge=latest)
|
|
20
|
+
|
|
21
|
+
## Dependencies
|
|
22
|
+
- PyYAML
|
|
23
|
+
- python-dateutil
|
|
24
|
+
- toml
|
|
25
|
+
- tqdm
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
#### Using pip
|
|
30
|
+
```
|
|
31
|
+
pip install stdl
|
|
32
|
+
```
|
|
33
|
+
#### From source
|
|
34
|
+
```
|
|
35
|
+
pip install git+https://github.com/zigai/stdl
|
|
36
|
+
```
|
|
37
|
+
## License
|
|
38
|
+
[MIT License](https://github.com/zigai/stdl/blob/master/LICENSE)
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "stdl"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.2"
|
|
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" }
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
"PyYAML>=6.0",
|
|
12
|
+
"tqdm",
|
|
13
|
+
"python-dateutil>=2.8.2",
|
|
14
|
+
"toml>=0.10.2 ",
|
|
15
|
+
]
|
|
10
16
|
|
|
11
17
|
classifiers = [
|
|
12
18
|
"Intended Audience :: Developers",
|
|
@@ -27,12 +33,22 @@ keywords = [
|
|
|
27
33
|
"logging configuration",
|
|
28
34
|
"list utils",
|
|
29
35
|
"standard library",
|
|
36
|
+
"ANSI colors",
|
|
37
|
+
"terminal output",
|
|
30
38
|
]
|
|
31
39
|
|
|
32
40
|
|
|
33
41
|
[project.optional-dependencies]
|
|
34
42
|
test = ["pytest"]
|
|
35
|
-
dev = [
|
|
43
|
+
dev = [
|
|
44
|
+
"black",
|
|
45
|
+
"pytest",
|
|
46
|
+
"ruff",
|
|
47
|
+
"mkdocs",
|
|
48
|
+
"mkdocs-material",
|
|
49
|
+
"mkdocs-autorefs",
|
|
50
|
+
"mkdocstrings[python]",
|
|
51
|
+
]
|
|
36
52
|
|
|
37
53
|
[project.urls]
|
|
38
54
|
Repository = "https://github.com/zigai/stdl"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from stdl import dt, fs, log, lst, net, st
|
|
@@ -2,13 +2,13 @@ import inspect
|
|
|
2
2
|
import json
|
|
3
3
|
import sys
|
|
4
4
|
import time
|
|
5
|
+
import typing as T
|
|
5
6
|
from functools import wraps
|
|
6
|
-
from typing import Callable
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def timer(
|
|
10
10
|
r: int | None = 2,
|
|
11
|
-
sink: Callable = sys.stdout.write,
|
|
11
|
+
sink: T.Callable = sys.stdout.write,
|
|
12
12
|
show_args: bool = False,
|
|
13
13
|
serialize: bool = False,
|
|
14
14
|
sep=" | ",
|
|
@@ -24,7 +24,7 @@ def timer(
|
|
|
24
24
|
sep (str, optional): Separator between the function/method name and the arguments. Defaults to " | ".
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
|
-
def decorator(func: Callable):
|
|
27
|
+
def decorator(func: T.Callable):
|
|
28
28
|
@wraps(func)
|
|
29
29
|
def wrapper(*args, **kwargs):
|
|
30
30
|
time_start = time.perf_counter()
|
|
@@ -84,3 +84,6 @@ def retry(attempts: int, delay: float = 0):
|
|
|
84
84
|
return wrapper
|
|
85
85
|
|
|
86
86
|
return decorator
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
__all__ = ["timer", "retry"]
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import random
|
|
2
2
|
import time
|
|
3
|
+
import typing as T
|
|
3
4
|
from dataclasses import dataclass
|
|
4
5
|
from datetime import date, datetime, timedelta, timezone
|
|
5
|
-
from typing import Generator
|
|
6
6
|
|
|
7
7
|
from dateutil.parser import parse as parse_datetime_str
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ class Timer:
|
|
|
40
40
|
Stop the timer.
|
|
41
41
|
|
|
42
42
|
Args:
|
|
43
|
-
label (str | None, optional): Label for the stop.
|
|
43
|
+
label (str | None, optional): Label for the stop.
|
|
44
44
|
|
|
45
45
|
Returns:
|
|
46
46
|
TimerStop: The stop data
|
|
@@ -88,10 +88,6 @@ class Timer:
|
|
|
88
88
|
)
|
|
89
89
|
]
|
|
90
90
|
|
|
91
|
-
def print_stops(self) -> None:
|
|
92
|
-
for stop in self.stops:
|
|
93
|
-
print(stop)
|
|
94
|
-
|
|
95
91
|
|
|
96
92
|
def datetime_fmt(
|
|
97
93
|
d: str | float | int | None | datetime = None,
|
|
@@ -105,12 +101,12 @@ def datetime_fmt(
|
|
|
105
101
|
"""Format date and time
|
|
106
102
|
|
|
107
103
|
Args:
|
|
108
|
-
d (str | float | None | datetime, optional): Input datetime. Defaults to
|
|
109
|
-
fmt (str, optional): Date format.
|
|
110
|
-
dsep (str, optional): Date values separator.
|
|
111
|
-
tsep (str, optional): Time values separator.
|
|
112
|
-
ms (bool, optional): include miliseconds.
|
|
113
|
-
utc (bool, optional): Use the UTC timezone when building a datetime object from a timestamp.
|
|
104
|
+
d (str | float | None | datetime, optional): Input datetime. Defaults to current date and time.
|
|
105
|
+
fmt (str, optional): Date format.
|
|
106
|
+
dsep (str, optional): Date values separator.
|
|
107
|
+
tsep (str, optional): Time values separator.
|
|
108
|
+
ms (bool, optional): include miliseconds.
|
|
109
|
+
utc (bool, optional): Use the UTC timezone when building a datetime object from a timestamp.
|
|
114
110
|
|
|
115
111
|
Raises:
|
|
116
112
|
TypeError: Raises TypeError if the type of ``d`` is not one of the following: float, str, None, datetime, int
|
|
@@ -153,10 +149,10 @@ def time_fmt(
|
|
|
153
149
|
Format time
|
|
154
150
|
|
|
155
151
|
Args:
|
|
156
|
-
t (float | datetime | int | None, optional): Input time. Defaults to current time
|
|
157
|
-
sep (str, optional): Character(s) that separates hours, minutes, seconds...
|
|
158
|
-
ms (bool, optional): include miliseconds.
|
|
159
|
-
utc (bool, optional): Use the UTC timezone when building a time object from a timestamp.
|
|
152
|
+
t (float | datetime | int | None, optional): Input time. Defaults to current time.
|
|
153
|
+
sep (str, optional): Character(s) that separates hours, minutes, seconds...
|
|
154
|
+
ms (bool, optional): include miliseconds.
|
|
155
|
+
utc (bool, optional): Use the UTC timezone when building a time object from a timestamp.
|
|
160
156
|
|
|
161
157
|
Raises:
|
|
162
158
|
TypeError: Raises TypeError if the type of ``t`` is not one of the following: float, None, datetime, int
|
|
@@ -188,9 +184,9 @@ def date_fmt(
|
|
|
188
184
|
Format date
|
|
189
185
|
|
|
190
186
|
Args:
|
|
191
|
-
d (float | date | datetime | int | None ): Input date. Defaults to current date
|
|
192
|
-
fmt (str, optional): Date format.
|
|
193
|
-
sep (str, optional): Character(s) that separates days, months and years.
|
|
187
|
+
d (float | date | datetime | int | None ): Input date. Defaults to current date.
|
|
188
|
+
fmt (str, optional): Date format.
|
|
189
|
+
sep (str, optional): Character(s) that separates days, months and years.
|
|
194
190
|
|
|
195
191
|
Raises:
|
|
196
192
|
TypeError: Raises TypeError if the type of ``d`` is not one of the following: float, None, date, datetime, int
|
|
@@ -222,7 +218,7 @@ def date_fmt(
|
|
|
222
218
|
return d.strftime(f"%{fmt[0]}{sep}%{fmt[1]}{sep}%{fmt[2]}")
|
|
223
219
|
|
|
224
220
|
|
|
225
|
-
def date_range(start: date, end: date) -> Generator[date, None, None]:
|
|
221
|
+
def date_range(start: date, end: date) -> T.Generator[date, None, None]:
|
|
226
222
|
"""
|
|
227
223
|
Returns a generator for dates between ``start`` and ``end``
|
|
228
224
|
|