danielutils 0.9.70__tar.gz → 0.9.72__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.72}/PKG-INFO +3 -2
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/__init__.py +27 -14
- danielutils-0.9.72/danielutils/classes/frange.py +125 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/colors.py +1 -1
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/data_structures/__init__.py +2 -1
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/memo.py +2 -1
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/timeout.py +9 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/isoftype.py +5 -3
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/__init__.py +1 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/class_reflection.py +1 -1
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/function_reflections.py +1 -1
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/get_traceback.py +1 -1
- danielutils-0.9.72/danielutils/reflection/system_reflections.py +34 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/threads/worker.py +1 -1
- danielutils-0.9.72/danielutils/university/__init__.py +2 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils.egg-info/PKG-INFO +3 -2
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils.egg-info/SOURCES.txt +4 -3
- {danielutils-0.9.70 → danielutils-0.9.72}/pyproject.toml +4 -4
- danielutils-0.9.70/danielutils/classes/frange.py +0 -61
- danielutils-0.9.70/danielutils/io.py +0 -436
- danielutils-0.9.70/danielutils/reflection/system_reflections.py +0 -55
- danielutils-0.9.70/danielutils/university/__init__.py +0 -1
- /danielutils-0.9.70/LISENCE → /danielutils-0.9.72/LICENSE +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/README.md +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/aliases.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/Convenience.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/Counter.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/Tree.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/repl.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/sorted_builtins/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/sorted_builtins/sset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/factory.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/tset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/classes/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- /danielutils-0.9.70/danielutils/print.py → /danielutils-0.9.72/danielutils/d_print.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/data_structures/Comparer.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/data_structures/Stack.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/date.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/date_time.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/decorate_conditionally.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/overload.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/processify.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/files_and_folders.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/generators/join_generators.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/internet.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/loops.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/math/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/math/constants.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/math/functions.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/math/math_print.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/math/math_symbols.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/Interface.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/multi_x.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/my_tqdm.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/path.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/py.typed +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/file_reflection.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/get_prev_frame.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/reflection/module_reflections.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/relations.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/signals.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/text.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/threads/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/threads/worker_pool.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/time.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils/university/databases/all.py +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils.egg-info/requires.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/setup.cfg +0 -0
- {danielutils-0.9.70 → danielutils-0.9.72}/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.72
|
|
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,8 +31,9 @@ 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
|
+
License-File: LICENSE
|
|
36
37
|
Requires-Dist: tqdm
|
|
37
38
|
|
|
38
39
|
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
"""danielutils is a convenience library of functions decorators
|
|
2
2
|
data-structures and more that make my development workflow faster
|
|
3
3
|
"""
|
|
4
|
-
|
|
4
|
+
# =================================================================
|
|
5
|
+
# ============================= LEAFS =============================
|
|
6
|
+
# =================================================================
|
|
7
|
+
from .path import *
|
|
8
|
+
from .date_time import *
|
|
9
|
+
from .multi_x import *
|
|
10
|
+
from .loops import *
|
|
11
|
+
from .signals import *
|
|
12
|
+
from .aliases import *
|
|
13
|
+
from .exceptions import PrintCatchOne
|
|
14
|
+
from .snippets import *
|
|
15
|
+
|
|
16
|
+
# =================================================================
|
|
17
|
+
# ========================= ORDER MATTERS =========================
|
|
18
|
+
# =================================================================
|
|
19
|
+
|
|
20
|
+
from .reflection import *
|
|
5
21
|
from .decorators import *
|
|
22
|
+
|
|
23
|
+
# ========== NEEDS REFLECTION ==========
|
|
24
|
+
from .threads import *
|
|
25
|
+
from .my_tqdm import *
|
|
26
|
+
# ========== NEEDS DECORATORS ==========
|
|
27
|
+
from .colors import *
|
|
28
|
+
# ========== NEEDS BOTH ==========
|
|
29
|
+
|
|
30
|
+
from .functions import *
|
|
6
31
|
from .files_and_folders import *
|
|
7
32
|
from .system import *
|
|
8
33
|
from .text import *
|
|
9
34
|
from .conversions import *
|
|
10
35
|
from .classes import *
|
|
11
36
|
from .time import *
|
|
12
|
-
from .colors import *
|
|
13
37
|
from .date import *
|
|
14
38
|
from .data_structures import *
|
|
15
39
|
from .math import *
|
|
16
|
-
from .path import *
|
|
17
40
|
from .system import *
|
|
18
|
-
from .
|
|
19
|
-
from .exceptions import PrintCatchOne
|
|
20
|
-
from .reflection import *
|
|
41
|
+
from .d_print import *
|
|
21
42
|
from .metaclasses import *
|
|
22
|
-
from .date_time import *
|
|
23
43
|
from .generators import *
|
|
24
|
-
from .snippets import *
|
|
25
|
-
from .aliases import *
|
|
26
|
-
from .signals import *
|
|
27
44
|
from .university import *
|
|
28
|
-
from .my_tqdm import *
|
|
29
|
-
from .threads import *
|
|
30
|
-
from .loops import *
|
|
31
|
-
from .multi_x import *
|
|
32
45
|
from .package_utils import *
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
from typing import Iterable, Callable, Optional, Iterator
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class frange(Iterable[float]):
|
|
5
|
+
"""this class is the same like builtin range but with float values
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
def __init__(self, start: float, stop: Optional[float] = None,
|
|
9
|
+
step: float = 1, round_method: Callable[[float], float] = lambda f: round(f, 3)):
|
|
10
|
+
if stop is None:
|
|
11
|
+
stop = start
|
|
12
|
+
start = 0
|
|
13
|
+
self.start = start
|
|
14
|
+
self.stop = stop
|
|
15
|
+
self.step = step
|
|
16
|
+
self.method = round_method
|
|
17
|
+
|
|
18
|
+
def __eq__(self, other):
|
|
19
|
+
if not isinstance(other, frange):
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
return self.start == other.start and self.stop == other.stop and self.step == other.step
|
|
22
|
+
|
|
23
|
+
def __iter__(self) -> Iterable:
|
|
24
|
+
if self.stop < self.start:
|
|
25
|
+
return
|
|
26
|
+
if self.start > self.stop:
|
|
27
|
+
return
|
|
28
|
+
if abs(self.stop - self.start) < abs(self.step):
|
|
29
|
+
return
|
|
30
|
+
if self.stop > 0 and self.step < 0:
|
|
31
|
+
return
|
|
32
|
+
if self.stop < 0 and self.step > 0:
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
cur = self.start
|
|
36
|
+
while cur < self.stop:
|
|
37
|
+
yield self.method(cur)
|
|
38
|
+
cur += self.step
|
|
39
|
+
|
|
40
|
+
def __len__(self) -> int:
|
|
41
|
+
return int((self.stop - self.start) // self.step)
|
|
42
|
+
|
|
43
|
+
def __str__(self) -> str:
|
|
44
|
+
return repr(self)
|
|
45
|
+
|
|
46
|
+
def __repr__(self):
|
|
47
|
+
return f"{self.__class__.__name__}({self.start}, {self.stop}, {self.step})"
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def _is_whole_step(self) -> bool:
|
|
51
|
+
return self.step - int(self.step) == 0
|
|
52
|
+
|
|
53
|
+
def __contains__(self, item):
|
|
54
|
+
if item < self.start:
|
|
55
|
+
return False
|
|
56
|
+
if item >= self.stop:
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
if self._is_whole_step:
|
|
60
|
+
if not item - int(item) == 0:
|
|
61
|
+
return False
|
|
62
|
+
|
|
63
|
+
return item / self.step - item // self.step == 0
|
|
64
|
+
|
|
65
|
+
def normalize(self) -> 'frange':
|
|
66
|
+
return frange(self.start / self.step, self.stop / self.step, 1)
|
|
67
|
+
|
|
68
|
+
def intersect(self, other: 'frange') -> 'frange':
|
|
69
|
+
a, b = self.normalize(), other.normalize()
|
|
70
|
+
start1, stop1 = a.start, a.stop
|
|
71
|
+
start2, stop2 = b.start, b.stop
|
|
72
|
+
remainder1, remainder2 = start1 - int(start1), start2 - int(start2)
|
|
73
|
+
if remainder1 == remainder2:
|
|
74
|
+
if stop1 == float("inf") or stop2 == float("inf"):
|
|
75
|
+
return frange(max(start1, start2), float("inf"))
|
|
76
|
+
return frange(max(start1, start2), min(stop1, stop2))
|
|
77
|
+
raise NotImplementedError("this part is not implemented yet")
|
|
78
|
+
if remainder1 != 0 and remainder2 / remainder1 - remainder2 // remainder1 == 0:
|
|
79
|
+
pass
|
|
80
|
+
|
|
81
|
+
pass
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class frange_iterator(Iterator[float]):
|
|
85
|
+
def __init__(self, obj: frange):
|
|
86
|
+
self.r = obj
|
|
87
|
+
|
|
88
|
+
def __next__(self):
|
|
89
|
+
if self.r.stop < self.r.start:
|
|
90
|
+
return
|
|
91
|
+
if self.r.start > self.r.stop:
|
|
92
|
+
return
|
|
93
|
+
if abs(self.r.stop - self.r.start) < abs(self.r.step):
|
|
94
|
+
return
|
|
95
|
+
if self.r.stop > 0 and self.r.step < 0:
|
|
96
|
+
return
|
|
97
|
+
if self.r.stop < 0 and self.r.step > 0:
|
|
98
|
+
return
|
|
99
|
+
|
|
100
|
+
cur = self.r.start
|
|
101
|
+
while cur < self.r.stop:
|
|
102
|
+
yield self.r.method(cur)
|
|
103
|
+
cur += self.r.step
|
|
104
|
+
|
|
105
|
+
def __iter__(self):
|
|
106
|
+
return self
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class brange(frange):
|
|
110
|
+
"""like frange but with tqdm
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
def __iter__(self):
|
|
114
|
+
itr = super().__iter__()
|
|
115
|
+
try:
|
|
116
|
+
from my_tqdm import tqdm # type:ignore # pylint: disable=import-error
|
|
117
|
+
return iter(tqdm(itr, desc=f"{self}", total=len(self)))
|
|
118
|
+
except:
|
|
119
|
+
return itr
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
__all__ = [
|
|
123
|
+
"frange",
|
|
124
|
+
"brange"
|
|
125
|
+
]
|
|
@@ -9,6 +9,7 @@ if get_python_version() < (3, 9):
|
|
|
9
9
|
else:
|
|
10
10
|
from builtins import dict as t_dict
|
|
11
11
|
from typing import ParamSpec # type:ignore # pylint: disable=ungrouped-imports
|
|
12
|
+
from copy import deepcopy
|
|
12
13
|
T = TypeVar("T")
|
|
13
14
|
P = ParamSpec("P")
|
|
14
15
|
FuncT = Callable[P, T] # type:ignore
|
|
@@ -27,7 +28,7 @@ def memo(func: FuncT) -> FuncT:
|
|
|
27
28
|
def wrapper(*args, **kwargs):
|
|
28
29
|
if (args, *kwargs.items()) not in cache:
|
|
29
30
|
cache[(args, *kwargs.items())] = func(*args, **kwargs)
|
|
30
|
-
return cache[(args, *kwargs.items())]
|
|
31
|
+
return deepcopy(cache[(args, *kwargs.items())])
|
|
31
32
|
return wrapper
|
|
32
33
|
|
|
33
34
|
|
|
@@ -4,6 +4,7 @@ import platform
|
|
|
4
4
|
from typing import Callable, TypeVar, Union
|
|
5
5
|
from .validate import validate
|
|
6
6
|
from ..reflection import get_python_version
|
|
7
|
+
|
|
7
8
|
if get_python_version() < (3, 9):
|
|
8
9
|
from typing_extensions import ParamSpec
|
|
9
10
|
else:
|
|
@@ -29,6 +30,7 @@ def timeout(duration: Union[int, float], silent: bool = False) -> Callable[[Func
|
|
|
29
30
|
Returns:
|
|
30
31
|
Callable: the result decorated function
|
|
31
32
|
"""
|
|
33
|
+
|
|
32
34
|
# https://stackoverflow.com/a/21861599/6416556
|
|
33
35
|
def timeout_deco(func: FuncT) -> FuncT:
|
|
34
36
|
if not callable(func):
|
|
@@ -56,5 +58,12 @@ def timeout(duration: Union[int, float], silent: bool = False) -> Callable[[Func
|
|
|
56
58
|
raise res[0]
|
|
57
59
|
return None
|
|
58
60
|
return res[0]
|
|
61
|
+
|
|
59
62
|
return wrapper
|
|
63
|
+
|
|
60
64
|
return timeout_deco
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
"timeout"
|
|
69
|
+
]
|
|
@@ -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
|
]
|
|
@@ -5,6 +5,7 @@ from .get_traceback import *
|
|
|
5
5
|
from .module_reflections import *
|
|
6
6
|
from .class_reflection import *
|
|
7
7
|
from .get_prev_frame import *
|
|
8
|
+
from .interpreter import *
|
|
8
9
|
# def get_class(module_name: str, class_name: str) -> type:
|
|
9
10
|
# """dynammically loads the module and returns the class from this file
|
|
10
11
|
|
|
@@ -2,7 +2,7 @@ import inspect
|
|
|
2
2
|
from typing import cast, Optional, Callable, Any
|
|
3
3
|
from types import FrameType
|
|
4
4
|
from .get_prev_frame import get_prev_frame_from, get_n_prev_frame
|
|
5
|
-
from
|
|
5
|
+
from .interpreter import get_python_version
|
|
6
6
|
|
|
7
7
|
if get_python_version() < (3, 9):
|
|
8
8
|
from typing import List as t_list, Set as t_set # pylint: disable=ungrouped-imports
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import platform
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OSType(Enum):
|
|
7
|
+
"""enum result for possible results of get_os()
|
|
8
|
+
"""
|
|
9
|
+
LINUX = "Linux"
|
|
10
|
+
WINDOWS = "Windows"
|
|
11
|
+
OSX = "OS X"
|
|
12
|
+
UNKNOWN = "Unknown"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_os() -> OSType:
|
|
16
|
+
"""returns the type of operation system running this code
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
OSType: enum result
|
|
20
|
+
"""
|
|
21
|
+
p = sys.platform
|
|
22
|
+
if p in {"linux", "linux2"}:
|
|
23
|
+
return OSType.LINUX
|
|
24
|
+
if p == "darwin":
|
|
25
|
+
return OSType.OSX
|
|
26
|
+
if p == "win32":
|
|
27
|
+
return OSType.WINDOWS
|
|
28
|
+
return OSType.UNKNOWN
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"OSType",
|
|
33
|
+
"get_os",
|
|
34
|
+
]
|
|
@@ -2,7 +2,7 @@ from threading import Thread
|
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
3
|
from typing import Optional, Any
|
|
4
4
|
from logging import error
|
|
5
|
-
import danielutils
|
|
5
|
+
import danielutils # this is explicitly this way to prevent circular import
|
|
6
6
|
from ..reflection import get_python_version
|
|
7
7
|
if get_python_version() >= (3, 9):
|
|
8
8
|
from builtins import tuple as t_tuple # type:ignore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.72
|
|
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,8 +31,9 @@ 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
|
+
License-File: LICENSE
|
|
36
37
|
Requires-Dist: tqdm
|
|
37
38
|
|
|
38
39
|
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
LICENSE
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
4
|
setup.py
|
|
5
|
+
./LICENSE
|
|
6
|
+
./README.md
|
|
5
7
|
danielutils/__init__.py
|
|
6
8
|
danielutils/aliases.py
|
|
7
9
|
danielutils/colors.py
|
|
10
|
+
danielutils/d_print.py
|
|
8
11
|
danielutils/date.py
|
|
9
12
|
danielutils/date_time.py
|
|
10
13
|
danielutils/exceptions.py
|
|
11
14
|
danielutils/files_and_folders.py
|
|
12
15
|
danielutils/internet.py
|
|
13
|
-
danielutils/io.py
|
|
14
16
|
danielutils/loops.py
|
|
15
17
|
danielutils/multi_x.py
|
|
16
18
|
danielutils/my_tqdm.py
|
|
17
19
|
danielutils/path.py
|
|
18
|
-
danielutils/print.py
|
|
19
20
|
danielutils/py.typed
|
|
20
21
|
danielutils/relations.py
|
|
21
22
|
danielutils/signals.py
|
|
@@ -4,16 +4,16 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "danielutils"
|
|
7
|
-
version = "0.9.
|
|
7
|
+
version = "0.9.72"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "danielnachumdev", email = "danielnachumdev@gmail.com" },
|
|
10
10
|
]
|
|
11
11
|
dependencies = ['tqdm']
|
|
12
12
|
keywords = ['functions', 'decorators', 'methods', 'classes', 'metaclasses']
|
|
13
|
-
license = { "file" = "
|
|
13
|
+
license = { "file" = "./LICENSE" }
|
|
14
14
|
description = "A python utils library for things I find useful"
|
|
15
|
-
readme = "README.md"
|
|
16
|
-
requires-python = ">=3.8.
|
|
15
|
+
readme = "./README.md"
|
|
16
|
+
requires-python = ">=3.8.0"
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Development Status :: 3 - Alpha",
|
|
19
19
|
"Intended Audience :: Developers",
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from typing import Iterable, Callable, Optional
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class frange:
|
|
5
|
-
"""this class is the same like builtin range but with float values
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
def __init__(self, start: float, stop: Optional[float] = None,
|
|
9
|
-
step: float = 1, round_method: Callable[[float], float] = lambda f: round(f, 3)):
|
|
10
|
-
if stop is None:
|
|
11
|
-
stop = start
|
|
12
|
-
start = 0
|
|
13
|
-
self.start = start
|
|
14
|
-
self.stop = stop
|
|
15
|
-
self.step = step
|
|
16
|
-
self.method = round_method
|
|
17
|
-
|
|
18
|
-
def __iter__(self) -> Iterable:
|
|
19
|
-
if self.stop < self.start:
|
|
20
|
-
return
|
|
21
|
-
if self.start > self.stop:
|
|
22
|
-
return
|
|
23
|
-
if abs(self.stop-self.start) < abs(self.step):
|
|
24
|
-
return
|
|
25
|
-
if self.stop > 0 and self.step < 0:
|
|
26
|
-
return
|
|
27
|
-
if self.stop < 0 and self.step > 0:
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
cur = self.start
|
|
31
|
-
while cur < self.stop:
|
|
32
|
-
yield self.method(cur)
|
|
33
|
-
cur += self.step
|
|
34
|
-
|
|
35
|
-
def __len__(self) -> int:
|
|
36
|
-
return int((self.stop-self.start)//self.step)
|
|
37
|
-
|
|
38
|
-
def __str__(self) -> str:
|
|
39
|
-
return repr(self)
|
|
40
|
-
|
|
41
|
-
def __repr__(self):
|
|
42
|
-
return f"{self.__class__.__name__}({self.start}, {self.stop}, {self.step})"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class brange(frange):
|
|
46
|
-
"""like frange but with tqdm
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
def __iter__(self):
|
|
50
|
-
itr = super().__iter__()
|
|
51
|
-
try:
|
|
52
|
-
from my_tqdm import tqdm # type:ignore # pylint: disable=import-error
|
|
53
|
-
return iter(tqdm(itr, desc=f"{self}", total=len(self)))
|
|
54
|
-
except:
|
|
55
|
-
return itr
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
__all__ = [
|
|
59
|
-
"frange",
|
|
60
|
-
"brange"
|
|
61
|
-
]
|