stdl 0.5.0__tar.gz → 0.5.6__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.
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: stdl
3
- Version: 0.5.0
3
+ Version: 0.5.6
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
+ Project-URL: Documentation, https://stdl.readthedocs.io
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
10
11
  Classifier: Operating System :: OS Independent
@@ -19,23 +20,46 @@ Description-Content-Type: text/markdown
19
20
  License-File: LICENSE
20
21
  Requires-Dist: PyYAML>=6.0
21
22
  Requires-Dist: tqdm
22
- Requires-Dist: python-dateutil==2.8.2
23
+ Requires-Dist: python-dateutil>=2.8.2
24
+ Requires-Dist: toml>=0.10.2
23
25
  Provides-Extra: test
24
26
  Requires-Dist: pytest; extra == "test"
25
27
  Provides-Extra: dev
26
28
  Requires-Dist: black; extra == "dev"
27
29
  Requires-Dist: pytest; extra == "dev"
28
30
  Requires-Dist: ruff; extra == "dev"
31
+ Requires-Dist: mkdocs; extra == "dev"
32
+ Requires-Dist: mkdocs-material; extra == "dev"
33
+ Requires-Dist: mkdocs-autorefs; extra == "dev"
34
+ Requires-Dist: mkdocstrings[python]; extra == "dev"
29
35
 
30
36
  # stdl
31
37
  [![Tests](https://github.com/zigai/stdl/actions/workflows/tests.yml/badge.svg)](https://github.com/zigai/stdl/actions/workflows/tests.yml)
38
+ [![Documentation Status](https://readthedocs.org/projects/stdl/badge/?version=latest)](https://stdl.readthedocs.io/en/latest/?badge=latest)
32
39
  [![PyPI version](https://badge.fury.io/py/stdl.svg)](https://badge.fury.io/py/stdl)
33
40
  ![Supported versions](https://img.shields.io/badge/python-3.10+-blue.svg)
34
41
  [![Downloads](https://static.pepy.tech/badge/stdl)](https://pepy.tech/project/stdl)
35
42
  [![license](https://img.shields.io/github/license/zigai/stdl.svg)](https://github.com/zigai/stdl/blob/master/LICENSE)
36
43
 
37
- Extended Python standard library.
38
- # Installation
44
+ `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.
45
+
46
+ ## Features
47
+ - File and directory operations
48
+ - String manipulation
49
+ - ANSI color support for terminal output
50
+ - Date and time formatting
51
+ - List processing
52
+ - Function decorators
53
+ - Logging configuration for `logging` and `loguru`
54
+ - [See docs](https://stdl.readthedocs.io/en/latest/?badge=latest)
55
+
56
+ ## Dependencies
57
+ - PyYAML
58
+ - python-dateutil
59
+ - toml
60
+ - tqdm
61
+
62
+ ## Installation
39
63
 
40
64
  #### Using pip
41
65
  ```
@@ -45,5 +69,5 @@ pip install stdl
45
69
  ```
46
70
  pip install git+https://github.com/zigai/stdl
47
71
  ```
48
- # License
72
+ ## License
49
73
  [MIT License](https://github.com/zigai/stdl/blob/master/LICENSE)
stdl-0.5.6/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # stdl
2
+ [![Tests](https://github.com/zigai/stdl/actions/workflows/tests.yml/badge.svg)](https://github.com/zigai/stdl/actions/workflows/tests.yml)
3
+ [![Documentation Status](https://readthedocs.org/projects/stdl/badge/?version=latest)](https://stdl.readthedocs.io/en/latest/?badge=latest)
4
+ [![PyPI version](https://badge.fury.io/py/stdl.svg)](https://badge.fury.io/py/stdl)
5
+ ![Supported versions](https://img.shields.io/badge/python-3.10+-blue.svg)
6
+ [![Downloads](https://static.pepy.tech/badge/stdl)](https://pepy.tech/project/stdl)
7
+ [![license](https://img.shields.io/github/license/zigai/stdl.svg)](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.0"
3
+ version = "0.5.6"
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
- dependencies = ["PyYAML>=6.0", "tqdm", "python-dateutil==2.8.2"]
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,15 +33,26 @@ 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 = ["black", "pytest", "ruff"]
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"
55
+ Documentation = "https://stdl.readthedocs.io"
39
56
 
40
57
  [tool.black]
41
58
  line-length = 100
@@ -0,0 +1 @@
1
+ from stdl import decorators, dt, fs, log, lst, net, st
@@ -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"]
@@ -40,12 +40,12 @@ class Timer:
40
40
  Stop the timer.
41
41
 
42
42
  Args:
43
- label (str | None, optional): Label for the stop. Defaults to None.
43
+ label (str | None, optional): Label for the stop.
44
44
 
45
45
  Returns:
46
46
  TimerStop: The stop data
47
47
  """
48
- t = time.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.time()
81
+ self.start = time.perf_counter()
82
82
  self.stops: list[TimerStop] = [
83
83
  TimerStop(
84
84
  total=timedelta(seconds=0),
@@ -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 None.
109
- fmt (str, optional): Date format. Defaults to "Ymd".
110
- dsep (str, optional): Date values separator. Defaults to "-".
111
- tsep (str, optional): Time values separator. Defaults to ":".
112
- ms (bool, optional): include miliseconds. Defaults to False.
113
- utc (bool, optional): Use the UTC timezone when building a datetime object from a timestamp. Defaults to True.
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
@@ -118,14 +114,15 @@ def datetime_fmt(
118
114
  Returns:
119
115
  str: Formated date and time.
120
116
 
121
- Examples:
122
- --------
123
- >>> fmt_datetime()
124
- '2022-11-22 22:40:04' # current date and time
125
- >>> fmt_datetime(0)
126
- "1970-01-01 00:00:00"
127
- >>> fmt_datetime(0, fmt="dmY", dsep="/")
128
- "01/01/1970 00:00:00"
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
+ ```
129
126
  """
130
127
  if d is None:
131
128
  d = datetime.fromtimestamp(time.time(), **{"tz": timezone.utc} if utc else {})
@@ -153,10 +150,10 @@ def time_fmt(
153
150
  Format time
154
151
 
155
152
  Args:
156
- t (float | datetime | int | None, optional): Input time. Defaults to current time if it's not provided.
157
- sep (str, optional): Character(s) that separates hours, minutes, seconds... Defaults to ":".
158
- ms (bool, optional): include miliseconds. Defaults to False.
159
- utc (bool, optional): Use the UTC timezone when building a time object from a timestamp. Defaults to True.
153
+ t (float | datetime | int | None, optional): Input time. Defaults to current time.
154
+ sep (str, optional): Character(s) that separates hours, minutes, seconds...
155
+ ms (bool, optional): include miliseconds.
156
+ utc (bool, optional): Use the UTC timezone when building a time object from a timestamp.
160
157
 
161
158
  Raises:
162
159
  TypeError: Raises TypeError if the type of ``t`` is not one of the following: float, None, datetime, int
@@ -188,9 +185,9 @@ def date_fmt(
188
185
  Format date
189
186
 
190
187
  Args:
191
- d (float | date | datetime | int | None ): Input date. Defaults to current date if it's not provided.
192
- fmt (str, optional): Date format. Defaults to "Ymd".
193
- sep (str, optional): Character(s) that separates days, months and years. Defaults to "-".
188
+ d (float | date | datetime | int | None ): Input date. Defaults to current date.
189
+ fmt (str, optional): Date format.
190
+ sep (str, optional): Character(s) that separates days, months and years.
194
191
 
195
192
  Raises:
196
193
  TypeError: Raises TypeError if the type of ``d`` is not one of the following: float, None, date, datetime, int
@@ -198,16 +195,17 @@ def date_fmt(
198
195
  Returns:
199
196
  str: Formated date.
200
197
 
201
- Examples
202
- --------
203
- >>> fmt_date(date(2022,11,22))
204
- '2022-11-22'
205
- >>> fmt_date(date(2022,11,22), sep="/")
206
- '2022/11/22'
207
- >>> fmt_date(date(2022,11,22), sep="/", fmt="dmY")
208
- '22/11/2022'
209
- >>> fmt_date()
210
- '2022-11-22'
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
+ ```
211
209
  """
212
210
  if d is None:
213
211
  d = date.fromtimestamp(time.time())
@@ -226,12 +224,13 @@ def date_range(start: date, end: date) -> Generator[date, None, None]:
226
224
  """
227
225
  Returns a generator for dates between ``start`` and ``end``
228
226
 
229
- Examples
230
- --------
231
- >>> for i in date_range(date(2022,11,19), date(2022,11,22)): print(i)
232
- 2022-11-19
233
- 2022-11-20
234
- 2022-11-21
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
+ ```
235
234
  """
236
235
  for n in range(int((end - start).days)):
237
236
  yield start + timedelta(n)