danielutils 0.9.70__tar.gz → 0.9.71__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.
- {danielutils-0.9.70 → danielutils-0.9.71}/PKG-INFO +2 -2
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/isoftype.py +5 -3
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils.egg-info/PKG-INFO +2 -2
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils.egg-info/SOURCES.txt +0 -1
- {danielutils-0.9.70 → danielutils-0.9.71}/pyproject.toml +2 -2
- danielutils-0.9.70/danielutils/io.py +0 -436
- {danielutils-0.9.70 → danielutils-0.9.71}/LISENCE +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/README.md +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/aliases.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/Convenience.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/Counter.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/Tree.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/frange.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/repl.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/sorted_builtins/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/sorted_builtins/sset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/factory.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/tset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/classes/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/colors.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/data_structures/Comparer.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/data_structures/Stack.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/data_structures/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/date.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/date_time.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/decorate_conditionally.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/memo.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/overload.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/processify.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/timeout.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/files_and_folders.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/generators/join_generators.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/internet.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/loops.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/math/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/math/constants.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/math/functions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/math/math_print.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/math/math_symbols.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/Interface.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/multi_x.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/my_tqdm.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/path.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/print.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/py.typed +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/class_reflection.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/file_reflection.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/function_reflections.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/get_prev_frame.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/get_traceback.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/module_reflections.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/reflection/system_reflections.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/relations.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/signals.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/text.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/threads/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/threads/worker.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/threads/worker_pool.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/time.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/university/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils/university/databases/all.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils.egg-info/requires.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/setup.cfg +0 -0
- {danielutils-0.9.70 → danielutils-0.9.71}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.71
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -31,7 +31,7 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
31
31
|
Classifier: Intended Audience :: Developers
|
|
32
32
|
Classifier: Programming Language :: Python :: 3
|
|
33
33
|
Classifier: Operating System :: Microsoft :: Windows
|
|
34
|
-
Requires-Python: >=3.8.
|
|
34
|
+
Requires-Python: >=3.8.0
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
Requires-Dist: tqdm
|
|
37
37
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
from typing import get_args, get_origin, get_type_hints, Any, Union, TypeVar
|
|
1
|
+
from typing import get_args, get_origin, get_type_hints, Any, Union, TypeVar, \
|
|
2
2
|
ForwardRef, Literal, Optional, Tuple as t_tuple
|
|
3
3
|
from collections.abc import Callable, Generator, Iterable
|
|
4
4
|
from ..reflection import get_python_version
|
|
5
|
+
|
|
5
6
|
if get_python_version() < (3, 9):
|
|
6
7
|
from typing_extensions import ParamSpec, Concatenate
|
|
7
8
|
else:
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
# pylint: disable=ungrouped-imports
|
|
10
11
|
from typing import ParamSpec, Concatenate # type:ignore
|
|
11
12
|
from builtins import tuple as t_tuple # type:ignore
|
|
12
13
|
# implicit_union_type = type(int | str)
|
|
@@ -168,6 +169,8 @@ def __handle_callable(params: tuple) -> bool:
|
|
|
168
169
|
print("Using lambda function with isoftype is ambiguous.")
|
|
169
170
|
return not strict
|
|
170
171
|
|
|
172
|
+
if t_args is None:
|
|
173
|
+
return True
|
|
171
174
|
if len(t_args) == 0:
|
|
172
175
|
return True
|
|
173
176
|
|
|
@@ -305,7 +308,6 @@ __all__ = [
|
|
|
305
308
|
"isoftype"
|
|
306
309
|
]
|
|
307
310
|
|
|
308
|
-
|
|
309
311
|
__all__ = [
|
|
310
312
|
"isoftype"
|
|
311
313
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.71
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -31,7 +31,7 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
31
31
|
Classifier: Intended Audience :: Developers
|
|
32
32
|
Classifier: Programming Language :: Python :: 3
|
|
33
33
|
Classifier: Operating System :: Microsoft :: Windows
|
|
34
|
-
Requires-Python: >=3.8.
|
|
34
|
+
Requires-Python: >=3.8.0
|
|
35
35
|
Description-Content-Type: text/markdown
|
|
36
36
|
Requires-Dist: tqdm
|
|
37
37
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "danielutils"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.71"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "danielnachumdev", email = "danielnachumdev@gmail.com" },
|
|
10
10
|
]
|
|
@@ -13,7 +13,7 @@ keywords = ['functions', 'decorators', 'methods', 'classes', 'metaclasses']
|
|
|
13
13
|
license = { "file" = "LISENCE" }
|
|
14
14
|
description = "A python utils library for things I find useful"
|
|
15
15
|
readme = "README.md"
|
|
16
|
-
requires-python = ">=3.8.
|
|
16
|
+
requires-python = ">=3.8.0"
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Development Status :: 3 - Alpha",
|
|
19
19
|
"Intended Audience :: Developers",
|
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
import subprocess
|
|
3
|
-
from typing import IO, Iterator, Generator, Optional, cast, Union, List as t_list
|
|
4
|
-
import shutil
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
import os
|
|
7
|
-
from .decorators import validate
|
|
8
|
-
from .reflection import get_python_version
|
|
9
|
-
if get_python_version() >= (3, 9):
|
|
10
|
-
from builtins import list as t_list
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
@validate
|
|
14
|
-
def path_exists(path: str) -> bool:
|
|
15
|
-
"""checks whether a path exists
|
|
16
|
-
|
|
17
|
-
Args:
|
|
18
|
-
path (str): path to check
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
bool: result of check
|
|
22
|
-
"""
|
|
23
|
-
return os.path.exists(path)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@validate
|
|
27
|
-
def file_exists(path: str) -> bool:
|
|
28
|
-
"""checks whether a file exists at specified path
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
path (str): path to check
|
|
32
|
-
|
|
33
|
-
Returns:
|
|
34
|
-
bool: will return true iff the path exists and it is a path to a file
|
|
35
|
-
"""
|
|
36
|
-
return path_exists(path) and is_file(path)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@validate
|
|
40
|
-
def directory_exists(path: str) -> bool:
|
|
41
|
-
"""checks whether a directory exists at specified path
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
path (str): path to check
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
bool: will return true iff the path exists and it is a path to a directory
|
|
48
|
-
"""
|
|
49
|
-
return path_exists(path) and is_directory(path)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@validate
|
|
53
|
-
def delete_file(path: str) -> None:
|
|
54
|
-
"""deletes a file if it exists
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
path (str): path of file
|
|
58
|
-
"""
|
|
59
|
-
if file_exists(path):
|
|
60
|
-
os.remove(path)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@validate
|
|
64
|
-
# type:ignore
|
|
65
|
-
def read_file(path: str, read_bytes: bool = False) -> Union[t_list[str], t_list[bytes]]:
|
|
66
|
-
"""read all lines from a file
|
|
67
|
-
|
|
68
|
-
Args:
|
|
69
|
-
path (str): the path to the file
|
|
70
|
-
|
|
71
|
-
Returns:
|
|
72
|
-
list[str]: a list of all the lines in the file
|
|
73
|
-
"""
|
|
74
|
-
try:
|
|
75
|
-
if read_bytes:
|
|
76
|
-
with open(path, "rb") as f:
|
|
77
|
-
return f.readlines()
|
|
78
|
-
else:
|
|
79
|
-
with open(path, "r", encoding="mbcs") as f:
|
|
80
|
-
return f.readlines()
|
|
81
|
-
except Exception as e:
|
|
82
|
-
if isinstance(e, UnicodeDecodeError):
|
|
83
|
-
raise UnicodeDecodeError(e.encoding, e.object, e.start, e.end,
|
|
84
|
-
"Can't read byte in file.\nTo use with bytes use: read_bytes = True ") from e
|
|
85
|
-
raise e
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
@validate
|
|
89
|
-
def is_file(path: str) -> bool:
|
|
90
|
-
"""return whether a path represents a file
|
|
91
|
-
|
|
92
|
-
Args:
|
|
93
|
-
path (str): path to check
|
|
94
|
-
"""
|
|
95
|
-
return os.path.isfile(path)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@validate
|
|
99
|
-
def is_directory(path: str) -> bool:
|
|
100
|
-
"""return whether a path represents a directory
|
|
101
|
-
|
|
102
|
-
Args:
|
|
103
|
-
path (str): path to check
|
|
104
|
-
"""
|
|
105
|
-
return os.path.isdir(path)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
@validate
|
|
109
|
-
def get_files(path: str) -> t_list[str]:
|
|
110
|
-
"""return a list of names of all files inside specified directory
|
|
111
|
-
|
|
112
|
-
Args:
|
|
113
|
-
path (str): directory
|
|
114
|
-
|
|
115
|
-
Returns:
|
|
116
|
-
list[str]: all files
|
|
117
|
-
"""
|
|
118
|
-
files_and_directories = get_files_and_directories(path)
|
|
119
|
-
return list(
|
|
120
|
-
filter(lambda name: is_file(os.path.join(path, name)), files_and_directories))
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
@validate
|
|
124
|
-
def get_files_and_directories(path: str) -> t_list[str]:
|
|
125
|
-
"""get a list of all files and directories in specified path
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
path (str): path to check
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
list[str]: all files and directories
|
|
132
|
-
"""
|
|
133
|
-
return os.listdir(path)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
@validate
|
|
137
|
-
def get_directories(path: str) -> t_list[str]:
|
|
138
|
-
"""get all directories in specified path
|
|
139
|
-
|
|
140
|
-
Args:
|
|
141
|
-
path (str): path to check
|
|
142
|
-
|
|
143
|
-
Returns:
|
|
144
|
-
list[str]: all directories
|
|
145
|
-
"""
|
|
146
|
-
files_and_directories = get_files_and_directories(path)
|
|
147
|
-
return list(
|
|
148
|
-
filter(lambda name: is_directory(os.path.join(path, name)), files_and_directories))
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
@ validate
|
|
152
|
-
def delete_directory(path: str) -> None:
|
|
153
|
-
"""delete a directory and all its contents
|
|
154
|
-
|
|
155
|
-
Args:
|
|
156
|
-
path (str): _description_
|
|
157
|
-
"""
|
|
158
|
-
if is_directory(path):
|
|
159
|
-
clear_directory(path)
|
|
160
|
-
os.rmdir(path)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
@validate
|
|
164
|
-
def clear_directory(path: str) -> None:
|
|
165
|
-
"""clears the content of a directory
|
|
166
|
-
|
|
167
|
-
Args:
|
|
168
|
-
path (str): the path of the directory to clean
|
|
169
|
-
"""
|
|
170
|
-
for file in get_files(path):
|
|
171
|
-
delete_file(os.path.join(path, file))
|
|
172
|
-
for subdir in get_directories(path):
|
|
173
|
-
delete_directory(os.path.join(path, subdir))
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@validate
|
|
177
|
-
def create_directory(path: str) -> None:
|
|
178
|
-
"""create a directory at the specified path if it doesn't already exists
|
|
179
|
-
|
|
180
|
-
Args:
|
|
181
|
-
path (str): the path to create a directory at
|
|
182
|
-
"""
|
|
183
|
-
if not directory_exists(path):
|
|
184
|
-
os.makedirs(path)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
@validate
|
|
188
|
-
def create_file(path: str) -> None:
|
|
189
|
-
if not file_exists(path):
|
|
190
|
-
with open(path, "w", encoding='utf8') as f:
|
|
191
|
-
pass
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
@validate
|
|
195
|
-
def get_file_type_from_directory(path: str, file_type: str) -> Iterator[str]:
|
|
196
|
-
"""returns all file with specific type from a directory
|
|
197
|
-
|
|
198
|
-
Args:
|
|
199
|
-
path (str): path of directory
|
|
200
|
-
file_type (str): the desired file type. eg: ".png"
|
|
201
|
-
|
|
202
|
-
Returns:
|
|
203
|
-
list[str]: result
|
|
204
|
-
"""
|
|
205
|
-
return filter(
|
|
206
|
-
lambda name: Path(os.path.join(path, name)).suffix == file_type,
|
|
207
|
-
get_files(path)
|
|
208
|
-
)
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
@validate
|
|
212
|
-
def get_file_type_from_directory_recursively(path: str, file_type: str) -> Generator[str, None, None]:
|
|
213
|
-
"""_summary_
|
|
214
|
-
|
|
215
|
-
Args:
|
|
216
|
-
path (str): _description_
|
|
217
|
-
file_type (str): _description_
|
|
218
|
-
|
|
219
|
-
Returns:
|
|
220
|
-
_type_: _description_
|
|
221
|
-
"""
|
|
222
|
-
yield from filter(
|
|
223
|
-
lambda name: Path(os.path.join(path, name)).suffix == file_type,
|
|
224
|
-
get_files(path)
|
|
225
|
-
)
|
|
226
|
-
for subdir in get_directories(path):
|
|
227
|
-
for v in get_file_type_from_directory_recursively(os.path.join(path, subdir), file_type):
|
|
228
|
-
yield os.path.join(subdir, v)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
@validate
|
|
232
|
-
def rename_file(path: str, new_name: str) -> None:
|
|
233
|
-
"""renames a file
|
|
234
|
-
|
|
235
|
-
Args:
|
|
236
|
-
path (str): file to rename
|
|
237
|
-
new_name (str): the desired new name
|
|
238
|
-
"""
|
|
239
|
-
new_path = "./" + \
|
|
240
|
-
"/".join(Path(path).parts[:-1])+"/"+new_name+Path(path).suffix
|
|
241
|
-
move_file(path, new_path)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
@validate
|
|
245
|
-
def move_file(old_path: str, new_path: str) -> None:
|
|
246
|
-
"""moves a file
|
|
247
|
-
|
|
248
|
-
Args:
|
|
249
|
-
old_path (str): old path
|
|
250
|
-
new_path (str): new path
|
|
251
|
-
"""
|
|
252
|
-
os.rename(old_path, new_path)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
@validate
|
|
256
|
-
async def open_file(file_path: str, application_path: str) -> int:
|
|
257
|
-
"""open a file with the specified application
|
|
258
|
-
|
|
259
|
-
Args:
|
|
260
|
-
file_path (str): the file to open
|
|
261
|
-
application_path (str): the application to open with
|
|
262
|
-
Returns:
|
|
263
|
-
int: return code
|
|
264
|
-
"""
|
|
265
|
-
with subprocess.Popen([application_path, file_path]) as p:
|
|
266
|
-
return p.wait()
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
@validate
|
|
270
|
-
def move_directory(old_path: str, new_path: str) -> None:
|
|
271
|
-
"""moves a directory
|
|
272
|
-
|
|
273
|
-
Args:
|
|
274
|
-
old_path (str): old path
|
|
275
|
-
new_path (str): new path
|
|
276
|
-
"""
|
|
277
|
-
shutil.move(old_path, new_path)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
@validate
|
|
281
|
-
def copy_file(src: str, dest: str) -> None:
|
|
282
|
-
"""copies file from src to dest
|
|
283
|
-
|
|
284
|
-
Args:
|
|
285
|
-
src (str): src
|
|
286
|
-
dest (str): dest
|
|
287
|
-
"""
|
|
288
|
-
shutil.copy(src, dest)
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
@validate
|
|
292
|
-
def copy_directory(src: str, dest: str) -> None:
|
|
293
|
-
"""copies a directory from src to dest
|
|
294
|
-
|
|
295
|
-
Args:
|
|
296
|
-
src (str): stc
|
|
297
|
-
dest (str): dest
|
|
298
|
-
"""
|
|
299
|
-
shutil.copy(src, dest)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
class IndentedWriter:
|
|
303
|
-
"""every class that will inherit this class will have the following functions available
|
|
304
|
-
write() with the same arguments a builtin print()
|
|
305
|
-
indent()
|
|
306
|
-
undent()
|
|
307
|
-
|
|
308
|
-
also, it is expected in the __init__ function to call super().__init__()
|
|
309
|
-
also, the output_stream must be set whether by the first argument io super().__init__(...)
|
|
310
|
-
or by set_stream() explicitly somewhere else.
|
|
311
|
-
|
|
312
|
-
this class will not function properly is the output_stream is not set!
|
|
313
|
-
|
|
314
|
-
"""
|
|
315
|
-
|
|
316
|
-
def __init__(self, output_stream: Optional[IO] = None, indent_value: str = "\t"):
|
|
317
|
-
self.indent_level = 0
|
|
318
|
-
self.output_stream: Optional[IO] = output_stream
|
|
319
|
-
self.indent_value = indent_value
|
|
320
|
-
|
|
321
|
-
def write(self, *args, sep=" ", end="\n") -> None:
|
|
322
|
-
"""writes the supplied arguments to the output_stream
|
|
323
|
-
|
|
324
|
-
Args:
|
|
325
|
-
sep (str, optional): the str to use as a separator between arguments. Defaults to " ".
|
|
326
|
-
end (str, optional): the str to use as the final value. Defaults to "\n".
|
|
327
|
-
|
|
328
|
-
Raises:
|
|
329
|
-
ValueError: _description_
|
|
330
|
-
"""
|
|
331
|
-
if self.output_stream is None:
|
|
332
|
-
raise ValueError(
|
|
333
|
-
"Can't write to an empty stream. the stream must not be None:"
|
|
334
|
-
" either by set_stream or by initialization")
|
|
335
|
-
self.output_stream.write(
|
|
336
|
-
str(self.indent_level*self.indent_value + sep.join(args)+end))
|
|
337
|
-
|
|
338
|
-
def set_stream(self, stream: IO) -> None:
|
|
339
|
-
"""explicitly sets the stream
|
|
340
|
-
|
|
341
|
-
Args:
|
|
342
|
-
stream (IO): stream
|
|
343
|
-
"""
|
|
344
|
-
self.output_stream = stream
|
|
345
|
-
self.output_stream = cast(IO, self.output_stream)
|
|
346
|
-
|
|
347
|
-
def indent(self) -> None:
|
|
348
|
-
"""indents the preceding output with write() by one quantity more
|
|
349
|
-
"""
|
|
350
|
-
self.indent_level += 1
|
|
351
|
-
|
|
352
|
-
def undent(self) -> None:
|
|
353
|
-
"""un-dents the preceding output with write() by one quantity less
|
|
354
|
-
has a minimum value of 0
|
|
355
|
-
"""
|
|
356
|
-
self.indent_level = max(0, self.indent_level-1)
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
class IndentedWriter2:
|
|
360
|
-
"""every class that will inherit this class will have the following functions available
|
|
361
|
-
write() with the same arguments a builtin print()
|
|
362
|
-
indent()
|
|
363
|
-
undent()
|
|
364
|
-
|
|
365
|
-
also, it is expected in the __init__ function to call super().__init__()
|
|
366
|
-
also, the output_stream must be set whether by the first argument io super().__init__(...)
|
|
367
|
-
or by set_stream() explicitly somewhere else.
|
|
368
|
-
|
|
369
|
-
this class will not function properly is the output_stream is not set!
|
|
370
|
-
|
|
371
|
-
"""
|
|
372
|
-
|
|
373
|
-
def __init__(self, indent_value: str = "\t"):
|
|
374
|
-
self.indent_level = 0
|
|
375
|
-
self.indent_value = indent_value
|
|
376
|
-
self.buffer: str = ""
|
|
377
|
-
|
|
378
|
-
def to_stream(self, stream: IO[str]) -> None:
|
|
379
|
-
"""outputs the buffer to a stream
|
|
380
|
-
|
|
381
|
-
Args:
|
|
382
|
-
stream (IO[str]): the stream to output to
|
|
383
|
-
"""
|
|
384
|
-
stream.write(self.buffer)
|
|
385
|
-
|
|
386
|
-
def write(self, *args, sep=" ", end="\n") -> None:
|
|
387
|
-
"""writes the supplied arguments to the output_stream
|
|
388
|
-
|
|
389
|
-
Args:
|
|
390
|
-
sep (str, optional): the str to use as a separator between arguments. Defaults to " ".
|
|
391
|
-
end (str, optional): the str to use as the final value. Defaults to "\n".
|
|
392
|
-
|
|
393
|
-
Raises:
|
|
394
|
-
ValueError: _description_
|
|
395
|
-
"""
|
|
396
|
-
self.buffer += str(self.indent_level *
|
|
397
|
-
self.indent_value + sep.join(args)+end)
|
|
398
|
-
|
|
399
|
-
def indent(self) -> None:
|
|
400
|
-
"""indents the preceding output with write() by one quantity more
|
|
401
|
-
"""
|
|
402
|
-
self.indent_level += 1
|
|
403
|
-
|
|
404
|
-
def undent(self) -> None:
|
|
405
|
-
"""un-dents the preceding output with write() by one quantity less
|
|
406
|
-
has a minimum value of 0
|
|
407
|
-
"""
|
|
408
|
-
self.indent_level = max(0, self.indent_level-1)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
__all__ = [
|
|
412
|
-
"path_exists",
|
|
413
|
-
"file_exists",
|
|
414
|
-
"directory_exists",
|
|
415
|
-
"delete_file",
|
|
416
|
-
"read_file",
|
|
417
|
-
"is_file",
|
|
418
|
-
"is_directory",
|
|
419
|
-
"get_files",
|
|
420
|
-
"get_files_and_directories",
|
|
421
|
-
"get_directories",
|
|
422
|
-
"delete_directory",
|
|
423
|
-
"clear_directory",
|
|
424
|
-
"create_directory",
|
|
425
|
-
'create_file',
|
|
426
|
-
"get_file_type_from_directory",
|
|
427
|
-
"get_file_type_from_directory_recursively",
|
|
428
|
-
"rename_file",
|
|
429
|
-
"move_file",
|
|
430
|
-
"open_file",
|
|
431
|
-
"move_directory",
|
|
432
|
-
"copy_file",
|
|
433
|
-
"copy_directory",
|
|
434
|
-
"IndentedWriter",
|
|
435
|
-
"IndentedWriter2"
|
|
436
|
-
]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/specialized_conversions/to_hex.py
RENAMED
|
File without changes
|
{danielutils-0.9.70 → danielutils-0.9.71}/danielutils/conversions/specialized_conversions/to_int.py
RENAMED
|
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
|
|
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
|
|
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
|
{danielutils-0.9.70 → danielutils-0.9.71}/danielutils/metaclasses/implicit_data_deleter_meta.py
RENAMED
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|