stdl 0.5.3__tar.gz → 0.5.4__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.4}/PKG-INFO +1 -1
- {stdl-0.5.3 → stdl-0.5.4}/pyproject.toml +1 -1
- stdl-0.5.4/stdl/__init__.py +1 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl/fs.py +17 -19
- {stdl-0.5.3 → stdl-0.5.4}/stdl/lst.py +1 -1
- {stdl-0.5.3 → stdl-0.5.4}/stdl/st.py +8 -0
- {stdl-0.5.3 → stdl-0.5.4/stdl.egg-info}/PKG-INFO +1 -1
- stdl-0.5.3/stdl/__init__.py +0 -1
- {stdl-0.5.3 → stdl-0.5.4}/LICENSE +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/README.md +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/setup.cfg +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/setup.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl/decorators.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl/dt.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl/log.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl/net.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl.egg-info/SOURCES.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl.egg-info/dependency_links.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl.egg-info/requires.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/stdl.egg-info/top_level.txt +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/tests/test_decorators.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/tests/test_dt.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/tests/test_fs.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/tests/test_lst.py +0 -0
- {stdl-0.5.3 → stdl-0.5.4}/tests/test_st.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from stdl import decorators, dt, fs, log, lst, net, st
|
|
@@ -102,7 +102,7 @@ class File(PathLike):
|
|
|
102
102
|
Args:
|
|
103
103
|
path (os.PathLike): File path.
|
|
104
104
|
encoding (str, optional): The file's encoding.
|
|
105
|
-
abs (bool
|
|
105
|
+
abs (bool): Whether to use the absolute path.
|
|
106
106
|
"""
|
|
107
107
|
self.encoding = encoding
|
|
108
108
|
self.path: str = os.fspath(path)
|
|
@@ -698,7 +698,9 @@ def is_wsl() -> bool:
|
|
|
698
698
|
|
|
699
699
|
|
|
700
700
|
def mkdir(path: str | Path, mode: int = 511, exist_ok: bool = True) -> None:
|
|
701
|
-
"""
|
|
701
|
+
"""
|
|
702
|
+
Creates a directory.
|
|
703
|
+
|
|
702
704
|
Args:
|
|
703
705
|
path (str | Path): The path of the directory to create.
|
|
704
706
|
exist_ok (bool, optional): Whether to raise an exception if the directory already exists. Defaults to True.
|
|
@@ -707,7 +709,9 @@ def mkdir(path: str | Path, mode: int = 511, exist_ok: bool = True) -> None:
|
|
|
707
709
|
|
|
708
710
|
|
|
709
711
|
def mkdirs(dest: str | Path, names: list[str]) -> None:
|
|
710
|
-
"""
|
|
712
|
+
"""
|
|
713
|
+
Creates directories inside a destination directory.
|
|
714
|
+
|
|
711
715
|
Args:
|
|
712
716
|
dest (str | Path): The destination directory.
|
|
713
717
|
names (list[str]): A list of directory names to be created in the destination directory.
|
|
@@ -863,7 +867,7 @@ def ensure_paths_exist(*args: str | PathLike | Iterable[str | PathLike]) -> None
|
|
|
863
867
|
|
|
864
868
|
def check_path(path: str | PathLike):
|
|
865
869
|
if not os.path.exists(os.fspath(path)):
|
|
866
|
-
raise FileNotFoundError(f"Path does not exist: {path}")
|
|
870
|
+
raise FileNotFoundError(f"Path does not exist: '{path}'")
|
|
867
871
|
|
|
868
872
|
for path in args:
|
|
869
873
|
if isinstance(path, (str, bytes, PathLike)):
|
|
@@ -886,7 +890,7 @@ def ensure_paths_dont_exist(*args: str | PathLike | Iterable[str | PathLike]) ->
|
|
|
886
890
|
|
|
887
891
|
def check_path(path: str | PathLike):
|
|
888
892
|
if os.path.exists(os.fspath(path)):
|
|
889
|
-
raise FileExistsError(f"Path already exists: {path}")
|
|
893
|
+
raise FileExistsError(f"Path already exists: '{path}'")
|
|
890
894
|
|
|
891
895
|
for path in args:
|
|
892
896
|
if isinstance(path, (str, bytes, PathLike)):
|
|
@@ -1017,22 +1021,16 @@ def exec_cmd(
|
|
|
1017
1021
|
)
|
|
1018
1022
|
|
|
1019
1023
|
|
|
1020
|
-
def
|
|
1024
|
+
def read_piped() -> str:
|
|
1021
1025
|
"""
|
|
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.
|
|
1026
|
+
Reads piped input from stdin.
|
|
1029
1027
|
"""
|
|
1030
|
-
if
|
|
1031
|
-
return
|
|
1032
|
-
return
|
|
1028
|
+
if sys.stdin.isatty():
|
|
1029
|
+
return ""
|
|
1030
|
+
return sys.stdin.read().strip()
|
|
1033
1031
|
|
|
1034
1032
|
|
|
1035
|
-
def
|
|
1033
|
+
def start_file(path: str | PathLike) -> None:
|
|
1036
1034
|
"""
|
|
1037
1035
|
Open the file with your OS's default application.
|
|
1038
1036
|
|
|
@@ -1086,8 +1084,8 @@ __all__ = [
|
|
|
1086
1084
|
"dirname",
|
|
1087
1085
|
"joinpath",
|
|
1088
1086
|
"splitpath",
|
|
1089
|
-
"
|
|
1090
|
-
"
|
|
1087
|
+
"start_file",
|
|
1088
|
+
"read_piped",
|
|
1091
1089
|
"isdir",
|
|
1092
1090
|
"isfile",
|
|
1093
1091
|
"islink",
|
|
@@ -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
|
|
File without changes
|