stdl 0.5.3__tar.gz → 0.5.5__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.3/stdl.egg-info → stdl-0.5.5}/PKG-INFO +1 -1
- {stdl-0.5.3 → stdl-0.5.5}/pyproject.toml +1 -1
- stdl-0.5.5/stdl/__init__.py +1 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl/dt.py +3 -3
- {stdl-0.5.3 → stdl-0.5.5}/stdl/fs.py +17 -20
- {stdl-0.5.3 → stdl-0.5.5}/stdl/lst.py +1 -1
- {stdl-0.5.3 → stdl-0.5.5}/stdl/st.py +11 -3
- {stdl-0.5.3 → stdl-0.5.5/stdl.egg-info}/PKG-INFO +1 -1
- stdl-0.5.3/stdl/__init__.py +0 -1
- {stdl-0.5.3 → stdl-0.5.5}/LICENSE +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/README.md +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/setup.cfg +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/setup.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl/decorators.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl/log.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl/net.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl.egg-info/SOURCES.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl.egg-info/dependency_links.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl.egg-info/requires.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/stdl.egg-info/top_level.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/tests/test_decorators.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/tests/test_dt.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/tests/test_fs.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/tests/test_lst.py +0 -0
- {stdl-0.5.3 → stdl-0.5.5}/tests/test_st.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from stdl import decorators, dt, fs, log, lst, net, st
|
|
@@ -125,7 +125,7 @@ def datetime_fmt(
|
|
|
125
125
|
```
|
|
126
126
|
"""
|
|
127
127
|
if d is None:
|
|
128
|
-
d = datetime.fromtimestamp(time.
|
|
128
|
+
d = datetime.fromtimestamp(time.time(), **{"tz": timezone.utc} if utc else {})
|
|
129
129
|
|
|
130
130
|
elif isinstance(d, str):
|
|
131
131
|
d = parse_datetime_str(d)
|
|
@@ -162,7 +162,7 @@ def time_fmt(
|
|
|
162
162
|
str: Formated time.
|
|
163
163
|
"""
|
|
164
164
|
if t is None:
|
|
165
|
-
tm = datetime.fromtimestamp(time.
|
|
165
|
+
tm = datetime.fromtimestamp(time.time(), **{"tz": timezone.utc} if utc else {})
|
|
166
166
|
elif isinstance(t, datetime):
|
|
167
167
|
tm = t.time()
|
|
168
168
|
elif isinstance(t, (int, float)):
|
|
@@ -208,7 +208,7 @@ def date_fmt(
|
|
|
208
208
|
```
|
|
209
209
|
"""
|
|
210
210
|
if d is None:
|
|
211
|
-
d = date.fromtimestamp(time.
|
|
211
|
+
d = date.fromtimestamp(time.time())
|
|
212
212
|
elif isinstance(d, (float, int)):
|
|
213
213
|
d = date.fromtimestamp(d)
|
|
214
214
|
elif isinstance(d, datetime):
|
|
@@ -18,7 +18,6 @@ from datetime import datetime
|
|
|
18
18
|
from os import PathLike
|
|
19
19
|
from pathlib import Path
|
|
20
20
|
from queue import Queue
|
|
21
|
-
from select import select
|
|
22
21
|
|
|
23
22
|
import toml
|
|
24
23
|
import yaml
|
|
@@ -102,7 +101,7 @@ class File(PathLike):
|
|
|
102
101
|
Args:
|
|
103
102
|
path (os.PathLike): File path.
|
|
104
103
|
encoding (str, optional): The file's encoding.
|
|
105
|
-
abs (bool
|
|
104
|
+
abs (bool): Whether to use the absolute path.
|
|
106
105
|
"""
|
|
107
106
|
self.encoding = encoding
|
|
108
107
|
self.path: str = os.fspath(path)
|
|
@@ -698,7 +697,9 @@ def is_wsl() -> bool:
|
|
|
698
697
|
|
|
699
698
|
|
|
700
699
|
def mkdir(path: str | Path, mode: int = 511, exist_ok: bool = True) -> None:
|
|
701
|
-
"""
|
|
700
|
+
"""
|
|
701
|
+
Creates a directory.
|
|
702
|
+
|
|
702
703
|
Args:
|
|
703
704
|
path (str | Path): The path of the directory to create.
|
|
704
705
|
exist_ok (bool, optional): Whether to raise an exception if the directory already exists. Defaults to True.
|
|
@@ -707,7 +708,9 @@ def mkdir(path: str | Path, mode: int = 511, exist_ok: bool = True) -> None:
|
|
|
707
708
|
|
|
708
709
|
|
|
709
710
|
def mkdirs(dest: str | Path, names: list[str]) -> None:
|
|
710
|
-
"""
|
|
711
|
+
"""
|
|
712
|
+
Creates directories inside a destination directory.
|
|
713
|
+
|
|
711
714
|
Args:
|
|
712
715
|
dest (str | Path): The destination directory.
|
|
713
716
|
names (list[str]): A list of directory names to be created in the destination directory.
|
|
@@ -863,7 +866,7 @@ def ensure_paths_exist(*args: str | PathLike | Iterable[str | PathLike]) -> None
|
|
|
863
866
|
|
|
864
867
|
def check_path(path: str | PathLike):
|
|
865
868
|
if not os.path.exists(os.fspath(path)):
|
|
866
|
-
raise FileNotFoundError(f"Path does not exist: {path}")
|
|
869
|
+
raise FileNotFoundError(f"Path does not exist: '{path}'")
|
|
867
870
|
|
|
868
871
|
for path in args:
|
|
869
872
|
if isinstance(path, (str, bytes, PathLike)):
|
|
@@ -886,7 +889,7 @@ def ensure_paths_dont_exist(*args: str | PathLike | Iterable[str | PathLike]) ->
|
|
|
886
889
|
|
|
887
890
|
def check_path(path: str | PathLike):
|
|
888
891
|
if os.path.exists(os.fspath(path)):
|
|
889
|
-
raise FileExistsError(f"Path already exists: {path}")
|
|
892
|
+
raise FileExistsError(f"Path already exists: '{path}'")
|
|
890
893
|
|
|
891
894
|
for path in args:
|
|
892
895
|
if isinstance(path, (str, bytes, PathLike)):
|
|
@@ -1017,22 +1020,16 @@ def exec_cmd(
|
|
|
1017
1020
|
)
|
|
1018
1021
|
|
|
1019
1022
|
|
|
1020
|
-
def
|
|
1023
|
+
def read_piped() -> str:
|
|
1021
1024
|
"""
|
|
1022
|
-
Reads
|
|
1023
|
-
|
|
1024
|
-
Args:
|
|
1025
|
-
timeout (float, optional): The time to wait for input. Defaults to 0.
|
|
1026
|
-
|
|
1027
|
-
Returns:
|
|
1028
|
-
list[str]: The lines read from stdin.
|
|
1025
|
+
Reads piped input from stdin.
|
|
1029
1026
|
"""
|
|
1030
|
-
if
|
|
1031
|
-
return
|
|
1032
|
-
return
|
|
1027
|
+
if sys.stdin.isatty():
|
|
1028
|
+
return ""
|
|
1029
|
+
return sys.stdin.read().strip()
|
|
1033
1030
|
|
|
1034
1031
|
|
|
1035
|
-
def
|
|
1032
|
+
def start_file(path: str | PathLike) -> None:
|
|
1036
1033
|
"""
|
|
1037
1034
|
Open the file with your OS's default application.
|
|
1038
1035
|
|
|
@@ -1086,8 +1083,8 @@ __all__ = [
|
|
|
1086
1083
|
"dirname",
|
|
1087
1084
|
"joinpath",
|
|
1088
1085
|
"splitpath",
|
|
1089
|
-
"
|
|
1090
|
-
"
|
|
1086
|
+
"start_file",
|
|
1087
|
+
"read_piped",
|
|
1091
1088
|
"isdir",
|
|
1092
1089
|
"isfile",
|
|
1093
1090
|
"islink",
|
|
@@ -168,9 +168,9 @@ def _get_ansi_value(value: str | None, handler) -> str:
|
|
|
168
168
|
|
|
169
169
|
def colored(
|
|
170
170
|
text: str,
|
|
171
|
-
color: ForegroundColor | None = None,
|
|
172
|
-
background: BackgroundColor | None = None,
|
|
173
|
-
style: Style | None = None,
|
|
171
|
+
color: ForegroundColor | str | None = None,
|
|
172
|
+
background: BackgroundColor | str | None = None,
|
|
173
|
+
style: Style | str | None = None,
|
|
174
174
|
):
|
|
175
175
|
"""
|
|
176
176
|
Returns the text with ansi color, background color and text style codes.
|
|
@@ -383,6 +383,14 @@ def ansi_rjust(s: str, width: int, fillchar: str = " ") -> str:
|
|
|
383
383
|
return s.rjust(new_width, fillchar)
|
|
384
384
|
|
|
385
385
|
|
|
386
|
+
def ansi_strip(r: str) -> str:
|
|
387
|
+
"""
|
|
388
|
+
Remove ANSI escape codes from a string.
|
|
389
|
+
"""
|
|
390
|
+
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
|
|
391
|
+
return ansi_escape.sub("", r)
|
|
392
|
+
|
|
393
|
+
|
|
386
394
|
if __name__ == "__main__":
|
|
387
395
|
FG.print_all()
|
|
388
396
|
BG.print_all()
|
stdl-0.5.3/stdl/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from stdl import dt, fs, log, lst, net, st
|
|
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
|