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.
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stdl
3
- Version: 0.5.0
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==2.8.2
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
  [![Tests](https://github.com/zigai/stdl/actions/workflows/tests.yml/badge.svg)](https://github.com/zigai/stdl/actions/workflows/tests.yml)
37
+ [![Documentation Status](https://readthedocs.org/projects/stdl/badge/?version=latest)](https://stdl.readthedocs.io/en/latest/?badge=latest)
32
38
  [![PyPI version](https://badge.fury.io/py/stdl.svg)](https://badge.fury.io/py/stdl)
33
39
  ![Supported versions](https://img.shields.io/badge/python-3.10+-blue.svg)
34
40
  [![Downloads](https://static.pepy.tech/badge/stdl)](https://pepy.tech/project/stdl)
35
41
  [![license](https://img.shields.io/github/license/zigai/stdl.svg)](https://github.com/zigai/stdl/blob/master/LICENSE)
36
42
 
37
- Extended Python standard library.
38
- # Installation
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
- # License
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
+ [![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.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
- 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,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 = ["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"
@@ -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. Defaults to None.
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 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
@@ -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 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.
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 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 "-".
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