danielutils 0.9.6__tar.gz → 0.9.62__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.6 → danielutils-0.9.62}/PKG-INFO +2 -3
- {danielutils-0.9.6 → danielutils-0.9.62}/README.md +1 -1
- danielutils-0.9.62/danielutils/Classes/__init__.py +6 -0
- {danielutils-0.9.6/danielutils/classes → danielutils-0.9.62/danielutils/Classes}/frange.py +1 -1
- danielutils-0.9.6/danielutils/classes/Shell.py → danielutils-0.9.62/danielutils/Classes/repl.py +2 -2
- danielutils-0.9.62/danielutils/Conversions/__init__.py +2 -0
- {danielutils-0.9.6/danielutils/conversions/SpecializedConversions → danielutils-0.9.62/danielutils/Conversions/specialized_conversions}/to_hex.py +1 -1
- {danielutils-0.9.6/danielutils/conversions/SpecializedConversions → danielutils-0.9.62/danielutils/Conversions/specialized_conversions}/to_int.py +1 -1
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/__init__.py +1 -0
- danielutils-0.9.62/danielutils/Decorators/processify.py +57 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/isoftype.py +4 -3
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/InstanceCacheMeta.py +1 -1
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/Class.py +6 -1
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/File.py +3 -3
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/Function.py +43 -25
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/__init__.py +1 -1
- danielutils-0.9.62/danielutils/Reflection/get_prev_frame.py +30 -0
- danielutils-0.9.6/danielutils/time.py → danielutils-0.9.62/danielutils/Time.py +10 -3
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/__init__.py +4 -3
- danielutils-0.9.62/danielutils/data_structures/__init__.py +7 -0
- danielutils-0.9.62/danielutils/data_structures/default_dict.py +16 -0
- danielutils-0.9.6/danielutils/data_structures/Graph.py → danielutils-0.9.62/danielutils/data_structures/graph.py +2 -2
- danielutils-0.9.6/danielutils/data_structures/Heap.py → danielutils-0.9.62/danielutils/data_structures/heap.py +1 -1
- danielutils-0.9.6/danielutils/data_structures/Queue.py → danielutils-0.9.62/danielutils/data_structures/queue.py +2 -2
- danielutils-0.9.6/danielutils/data_structures/Stack.py → danielutils-0.9.62/danielutils/data_structures/stack.py +1 -1
- danielutils-0.9.62/danielutils/multi_x.py +16 -0
- danielutils-0.9.6/danielutils/tqdm.py → danielutils-0.9.62/danielutils/my_tqdm.py +7 -2
- {danielutils-0.9.6/danielutils/threading → danielutils-0.9.62/danielutils/threads}/worker.py +8 -3
- {danielutils-0.9.6/danielutils/threading → danielutils-0.9.62/danielutils/threads}/worker_pool.py +13 -4
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils.egg-info/PKG-INFO +2 -3
- danielutils-0.9.62/danielutils.egg-info/SOURCES.txt +179 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/pyproject.toml +3 -3
- {danielutils-0.9.6 → danielutils-0.9.62}/setup.py +4 -4
- danielutils-0.9.6/danielutils/classes/__init__.py +0 -6
- danielutils-0.9.6/danielutils/conversions/__init__.py +0 -2
- danielutils-0.9.6/danielutils/data_structures/__init__.py +0 -6
- danielutils-0.9.6/danielutils/reflection/get_prev_frame.py +0 -29
- danielutils-0.9.6/danielutils.egg-info/SOURCES.txt +0 -112
- {danielutils-0.9.6 → danielutils-0.9.62}/LISENCE +0 -0
- /danielutils-0.9.6/danielutils/aliases.py → /danielutils-0.9.62/danielutils/Aliases.py +0 -0
- {danielutils-0.9.6/danielutils/classes → danielutils-0.9.62/danielutils/Classes}/Convenience.py +0 -0
- {danielutils-0.9.6/danielutils/classes → danielutils-0.9.62/danielutils/Classes}/Counter.py +0 -0
- {danielutils-0.9.6/danielutils/classes → danielutils-0.9.62/danielutils/Classes}/Tree.py +0 -0
- {danielutils-0.9.6/danielutils/classes/SortedBuiltins → danielutils-0.9.62/danielutils/Classes/sorted_builtins}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/classes/SortedBuiltins → danielutils-0.9.62/danielutils/Classes/sorted_builtins}/sset.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/factory.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/tdict.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/tlist.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/tset.py +0 -0
- {danielutils-0.9.6/danielutils/classes/TypedBuiltins → danielutils-0.9.62/danielutils/Classes/typed_builtins}/ttuple.py +0 -0
- /danielutils-0.9.6/danielutils/colors.py → /danielutils-0.9.62/danielutils/Colors.py +0 -0
- /danielutils-0.9.6/danielutils/conversions/MainConversions.py → /danielutils-0.9.62/danielutils/Conversions/main_conversions.py +0 -0
- {danielutils-0.9.6/danielutils/conversions/SpecializedConversions → danielutils-0.9.62/danielutils/Conversions/specialized_conversions}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/PartiallyImplemented.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/atomic.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/attach.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/chain_decorators.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/decorate_conditionally.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/delay_call.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/deprecate.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/limit_recursion.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/memo.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/overload.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/property.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/threadify.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/timeout.py +0 -0
- {danielutils-0.9.6/danielutils/decorators → danielutils-0.9.62/danielutils/Decorators}/validate.py +0 -0
- /danielutils-0.9.6/danielutils/exceptions.py → /danielutils-0.9.62/danielutils/Exceptions.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/areoneof.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/check_foreach.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/isoneof.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/powerset.py +0 -0
- {danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/types_subseteq.py +0 -0
- {danielutils-0.9.6/danielutils/generators → danielutils-0.9.62/danielutils/Generators}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/generators → danielutils-0.9.62/danielutils/Generators}/conditional_generator.py +0 -0
- {danielutils-0.9.6/danielutils/generators → danielutils-0.9.62/danielutils/Generators}/generator_from_stream.py +0 -0
- {danielutils-0.9.6/danielutils/generators → danielutils-0.9.62/danielutils/Generators}/join_generators.py +0 -0
- /danielutils-0.9.6/danielutils/io.py → /danielutils-0.9.62/danielutils/IO.py +0 -0
- /danielutils-0.9.6/danielutils/internet.py → /danielutils-0.9.62/danielutils/Internet.py +0 -0
- /danielutils-0.9.6/danielutils/math/constants.py → /danielutils-0.9.62/danielutils/Math/Constants.py +0 -0
- /danielutils-0.9.6/danielutils/math/functions.py → /danielutils-0.9.62/danielutils/Math/Functions.py +0 -0
- {danielutils-0.9.6/danielutils/math → danielutils-0.9.62/danielutils/Math}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/math → danielutils-0.9.62/danielutils/Math}/math_print.py +0 -0
- {danielutils-0.9.6/danielutils/math → danielutils-0.9.62/danielutils/Math}/math_symbols.py +0 -0
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/AtomicClassMeta.py +0 -0
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/ImplicitDataDeleterMeta.py +0 -0
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/Interface.py +0 -0
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/OverloadMeta.py +0 -0
- {danielutils-0.9.6/danielutils/metaclasses → danielutils-0.9.62/danielutils/MetaClasses}/__init__.py +0 -0
- /danielutils-0.9.6/danielutils/path.py → /danielutils-0.9.62/danielutils/Path.py +0 -0
- /danielutils-0.9.6/danielutils/print.py → /danielutils-0.9.62/danielutils/Print.py +0 -0
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/Module.py +0 -0
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/System.py +0 -0
- {danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/get_traceback.py +0 -0
- /danielutils-0.9.6/danielutils/relations.py → /danielutils-0.9.62/danielutils/Relations.py +0 -0
- /danielutils-0.9.6/danielutils/signals.py → /danielutils-0.9.62/danielutils/Signals.py +0 -0
- {danielutils-0.9.6/danielutils/snippets → danielutils-0.9.62/danielutils/Snippets}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/snippets → danielutils-0.9.62/danielutils/Snippets}/try_get.py +0 -0
- /danielutils-0.9.6/danielutils/text.py → /danielutils-0.9.62/danielutils/Text.py +0 -0
- {danielutils-0.9.6/danielutils/university/databases → danielutils-0.9.62/danielutils/University/Databases}/__init__.py +0 -0
- {danielutils-0.9.6/danielutils/university/databases → danielutils-0.9.62/danielutils/University/Databases}/all.py +0 -0
- {danielutils-0.9.6/danielutils/university → danielutils-0.9.62/danielutils/University}/__init__.py +0 -0
- /danielutils-0.9.6/danielutils/data_structures/Comparer.py → /danielutils-0.9.62/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/data_structures/functions.py +0 -0
- /danielutils-0.9.6/danielutils/data_structures/Node.py → /danielutils-0.9.62/danielutils/data_structures/node.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/date.py +0 -0
- /danielutils-0.9.6/danielutils/datetime.py → /danielutils-0.9.62/danielutils/date_time.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/loops.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.6/danielutils/threading → danielutils-0.9.62/danielutils/threads}/__init__.py +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils.egg-info/requires.txt +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.6 → danielutils-0.9.62}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.62
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Home-page: https://github.com/danielnachumdev/danielutils
|
|
6
6
|
Author: danielnachumdev
|
|
@@ -36,7 +36,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
36
36
|
Classifier: Operating System :: Microsoft :: Windows
|
|
37
37
|
Requires-Python: >=3.8.17
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
|
-
Requires-Dist: tqdm
|
|
40
39
|
|
|
41
40
|
|
|
42
41
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml)
|
|
@@ -44,7 +43,7 @@ Requires-Dist: tqdm
|
|
|
44
43
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
45
44
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
46
45
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
47
|
-
# danielutils v=0.9.
|
|
46
|
+
# danielutils v=0.9.62
|
|
48
47
|
A utils library for things that I find useful for my coding workflow.\
|
|
49
48
|
Feel free to use and / or contribute / improve my code :)
|
|
50
49
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
5
5
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
6
6
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
7
|
-
# danielutils v=0.9.
|
|
7
|
+
# danielutils v=0.9.62
|
|
8
8
|
A utils library for things that I find useful for my coding workflow.\
|
|
9
9
|
Feel free to use and / or contribute / improve my code :)
|
|
10
10
|
|
|
@@ -49,7 +49,7 @@ class brange(frange):
|
|
|
49
49
|
def __iter__(self):
|
|
50
50
|
itr = super().__iter__()
|
|
51
51
|
try:
|
|
52
|
-
from
|
|
52
|
+
from my_tqdm import tqdm # type:ignore # pylint: disable=import-error
|
|
53
53
|
return iter(tqdm(itr, desc=f"{self}", total=len(self)))
|
|
54
54
|
except:
|
|
55
55
|
return itr
|
danielutils-0.9.6/danielutils/classes/Shell.py → danielutils-0.9.62/danielutils/Classes/repl.py
RENAMED
|
@@ -35,7 +35,7 @@ class Command:
|
|
|
35
35
|
return self.callback(*args, **kwargs)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
class
|
|
38
|
+
class REPL:
|
|
39
39
|
"""a class to easily create a shell application and get functionality for free
|
|
40
40
|
"""
|
|
41
41
|
|
|
@@ -82,7 +82,7 @@ class Shell:
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
__all__ = [
|
|
85
|
-
"
|
|
85
|
+
"REPL",
|
|
86
86
|
"Command",
|
|
87
87
|
"Argument"
|
|
88
88
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""functions that convert values to int"""
|
|
2
2
|
from typing import Union, List as t_list
|
|
3
|
-
from ..
|
|
3
|
+
from ..main_conversions import char_to_int
|
|
4
4
|
from ...reflection import get_python_version
|
|
5
5
|
if get_python_version() >= (3, 9):
|
|
6
6
|
from builtins import list as t_list
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
import functools
|
|
3
|
+
import multiprocessing
|
|
4
|
+
|
|
5
|
+
from ..reflection import get_n_caller_func, get_current_frame, get_n_prev_frame
|
|
6
|
+
from ..multi_x import process_id
|
|
7
|
+
import pickle
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def processify(func):
|
|
11
|
+
"""Modifies the function so that when calling it, a new process
|
|
12
|
+
will start to run it with provided arguments. Note that no return
|
|
13
|
+
value will be given.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
func (Callable): the function to make a process
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
Callable: the modified function
|
|
20
|
+
"""
|
|
21
|
+
multiprocessing.freeze_support()
|
|
22
|
+
|
|
23
|
+
@functools.wraps(func)
|
|
24
|
+
def wrapper(*args, **kwargs):
|
|
25
|
+
main_pid = kwargs.get("__main_pid", process_id())
|
|
26
|
+
if process_id() == main_pid:
|
|
27
|
+
frame = get_n_prev_frame(2)
|
|
28
|
+
dct = {k: v for k, v in frame.f_globals.items() if type(v) != type(inspect)}
|
|
29
|
+
p = multiprocessing.Process(target=_run_func, args=(main_pid, dct, func.__name__, args, kwargs))
|
|
30
|
+
p.start()
|
|
31
|
+
p.join() # Optionally wait for the process to finish
|
|
32
|
+
else:
|
|
33
|
+
del kwargs["__main_pid"]
|
|
34
|
+
return func(*args, **kwargs)
|
|
35
|
+
|
|
36
|
+
return wrapper
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _run_func(main_pid: int, dct: dict, func_name: str, args, kwargs) -> None:
|
|
41
|
+
return dct[func_name](*args, __main_pid=main_pid, **kwargs)
|
|
42
|
+
|
|
43
|
+
def debug_info(include_builtins: bool = False) -> dict:
|
|
44
|
+
f = get_n_prev_frame(2)
|
|
45
|
+
g = {k: v for k, v in f.f_globals.items() if k != "__builtins__"} if not include_builtins else dict(f.f_globals)
|
|
46
|
+
return {
|
|
47
|
+
"file": f.f_code.co_filename,
|
|
48
|
+
"function": f.f_code.co_qualname,
|
|
49
|
+
"line": f.f_lineno,
|
|
50
|
+
"globals": g,
|
|
51
|
+
"locals": dict(f.f_locals)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
"processify"
|
|
57
|
+
]
|
{danielutils-0.9.6/danielutils/functions → danielutils-0.9.62/danielutils/Functions}/isoftype.py
RENAMED
|
@@ -171,9 +171,6 @@ def __handle_callable(params: tuple) -> bool:
|
|
|
171
171
|
if len(t_args) == 0:
|
|
172
172
|
return True
|
|
173
173
|
|
|
174
|
-
obj_return_type = obj_hints.get('return')
|
|
175
|
-
obj_param_types = list(obj_hints.values())[:-1] if obj_hints else None
|
|
176
|
-
t_return_type = t_args[1]
|
|
177
174
|
if get_python_version() < (3, 9):
|
|
178
175
|
if isoftype(t_args[0][0], [ParamSpec, concatenate_t]):
|
|
179
176
|
return True
|
|
@@ -181,6 +178,10 @@ def __handle_callable(params: tuple) -> bool:
|
|
|
181
178
|
if isoftype(t_args[0], [ParamSpec, concatenate_t]):
|
|
182
179
|
return True
|
|
183
180
|
|
|
181
|
+
obj_return_type = obj_hints.get('return')
|
|
182
|
+
obj_param_types = list(obj_hints.values())[:-1] if obj_hints else None
|
|
183
|
+
t_return_type = t_args[1]
|
|
184
|
+
|
|
184
185
|
if isinstance(t_args[0], Iterable):
|
|
185
186
|
t_param_types = list(t_args[0])
|
|
186
187
|
A = obj_param_types + [obj_return_type] if obj_param_types else None
|
{danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/Class.py
RENAMED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import inspect
|
|
2
|
+
from ..reflection import get_python_version
|
|
3
|
+
if get_python_version() >= (3, 9):
|
|
4
|
+
from builtins import list as t_list # type:ignore
|
|
5
|
+
else:
|
|
6
|
+
from typing import List as t_list
|
|
2
7
|
|
|
3
8
|
|
|
4
|
-
def get_explicitly_declared_functions(cls: type) ->
|
|
9
|
+
def get_explicitly_declared_functions(cls: type) -> t_list[str]:
|
|
5
10
|
"""
|
|
6
11
|
Returns the names of the functions that are explicitly declared in a class.
|
|
7
12
|
|
{danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/File.py
RENAMED
|
@@ -2,7 +2,7 @@ import inspect
|
|
|
2
2
|
import os
|
|
3
3
|
from typing import Optional, cast
|
|
4
4
|
from types import FrameType
|
|
5
|
-
from .get_prev_frame import
|
|
5
|
+
from .get_prev_frame import get_prev_frame_from
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def get_filename() -> Optional[str]:
|
|
@@ -11,7 +11,7 @@ def get_filename() -> Optional[str]:
|
|
|
11
11
|
Returns:
|
|
12
12
|
Optional[str]: name of file
|
|
13
13
|
"""
|
|
14
|
-
frame =
|
|
14
|
+
frame = get_prev_frame_from(inspect.currentframe())
|
|
15
15
|
if frame is None:
|
|
16
16
|
return None
|
|
17
17
|
frame = cast(FrameType, frame)
|
|
@@ -25,7 +25,7 @@ def get_caller_filename() -> Optional[str]:
|
|
|
25
25
|
Returns:
|
|
26
26
|
Optional[str]: name of file
|
|
27
27
|
"""
|
|
28
|
-
frame =
|
|
28
|
+
frame = get_prev_frame_from(get_prev_frame_from(inspect.currentframe()))
|
|
29
29
|
if frame is None:
|
|
30
30
|
return None
|
|
31
31
|
frame = cast(FrameType, frame)
|
{danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/Function.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
from typing import cast, Optional, Callable, Any
|
|
3
3
|
from types import FrameType
|
|
4
|
-
from .get_prev_frame import
|
|
5
|
-
|
|
4
|
+
from .get_prev_frame import get_prev_frame_from, get_n_prev_frame
|
|
6
5
|
from ..reflection import get_python_version
|
|
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
|
|
9
9
|
else:
|
|
@@ -22,32 +22,12 @@ def get_caller_name(steps_back: int = 0) -> Optional[str]:
|
|
|
22
22
|
raise TypeError("steps_back must be an int")
|
|
23
23
|
if steps_back < 0:
|
|
24
24
|
raise ValueError("steps_back must be a non-negative integer")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# RGX = r'File ".*", line \d+, in (.+)\n'
|
|
28
|
-
# # traceback_list = get_traceback()
|
|
29
|
-
# # callee_frame = traceback_list[-1]
|
|
30
|
-
# # callee_name = re.search(RGX, callee_frame).group(1)
|
|
31
|
-
# # caller_frame = traceback_list[-2]
|
|
32
|
-
# # caller_name = re.search(RGX, caller_frame).group(1)
|
|
33
|
-
|
|
34
|
-
# this is more readable:
|
|
35
|
-
|
|
36
|
-
# current_frame = inspect.currentframe()
|
|
37
|
-
# callee_frame = current_frame.f_back
|
|
38
|
-
# # callee_name = callee_frame.f_code.co_name
|
|
39
|
-
# caller_frame = callee_frame.f_back
|
|
40
|
-
# caller_name = caller_frame.f_code.co_name
|
|
41
|
-
# return caller_name
|
|
42
|
-
frame = get_prev_frame(get_prev_frame(inspect.currentframe()))
|
|
43
|
-
if frame is None:
|
|
25
|
+
if (frame := get_n_prev_frame(2)) is None:
|
|
44
26
|
return None
|
|
45
27
|
frame = cast(FrameType, frame)
|
|
46
28
|
while steps_back > 0:
|
|
47
|
-
frame
|
|
48
|
-
if frame is None:
|
|
29
|
+
if (frame := cast(FrameType, get_prev_frame_from(frame))) is None:
|
|
49
30
|
return None
|
|
50
|
-
frame = cast(FrameType, frame)
|
|
51
31
|
steps_back -= 1
|
|
52
32
|
return frame.f_code.co_name
|
|
53
33
|
|
|
@@ -114,6 +94,40 @@ def is_function_annotated_properly(func: Callable, ignore: Optional[set] = None,
|
|
|
114
94
|
return True
|
|
115
95
|
|
|
116
96
|
|
|
97
|
+
def get_current_func():
|
|
98
|
+
caller_frame = get_n_prev_frame(2)
|
|
99
|
+
caller_name = caller_frame.f_code.co_name
|
|
100
|
+
caller_func = caller_frame.f_globals[caller_name]
|
|
101
|
+
return caller_func
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def get_caller_func() -> Optional[Callable]:
|
|
105
|
+
caller_frame = get_n_prev_frame(3)
|
|
106
|
+
if (caller_name := caller_frame.f_code.co_name) == "<module>":
|
|
107
|
+
return None
|
|
108
|
+
caller_func = caller_frame.f_globals[caller_name]
|
|
109
|
+
return caller_func
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
import json
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def get_n_caller_func(n_steps: int = 1) -> Optional[Callable]:
|
|
116
|
+
caller_frame = get_n_prev_frame(2 + n_steps)
|
|
117
|
+
# print(json.dumps(dict(caller_frame.f_globals), default=str, indent=4))
|
|
118
|
+
if (caller_name := caller_frame.f_code.co_name) == "<module>":
|
|
119
|
+
return None
|
|
120
|
+
caller_func = caller_frame.f_globals[caller_name]
|
|
121
|
+
return caller_func
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def get_caller_module_name() -> Optional[str]:
|
|
125
|
+
caller_func = get_caller_func()
|
|
126
|
+
if caller_func is None:
|
|
127
|
+
return None
|
|
128
|
+
return caller_func.__module__
|
|
129
|
+
|
|
130
|
+
|
|
117
131
|
def get_mro(obj: Any) -> t_list[type]:
|
|
118
132
|
"""returns the mro of an object
|
|
119
133
|
|
|
@@ -132,5 +146,9 @@ __all__ = [
|
|
|
132
146
|
"get_caller_name",
|
|
133
147
|
"get_function_return_type",
|
|
134
148
|
"is_function_annotated_properly",
|
|
135
|
-
"get_mro"
|
|
149
|
+
"get_mro",
|
|
150
|
+
"get_current_func",
|
|
151
|
+
"get_caller_func",
|
|
152
|
+
"get_n_caller_func",
|
|
153
|
+
"get_caller_module_name"
|
|
136
154
|
]
|
{danielutils-0.9.6/danielutils/reflection → danielutils-0.9.62/danielutils/Reflection}/__init__.py
RENAMED
|
@@ -4,7 +4,7 @@ from .Function import *
|
|
|
4
4
|
from .get_traceback import *
|
|
5
5
|
from .Module import *
|
|
6
6
|
from .Class import *
|
|
7
|
-
|
|
7
|
+
from .get_prev_frame import *
|
|
8
8
|
# def get_class(module_name: str, class_name: str) -> type:
|
|
9
9
|
# """dynammically loads the module and returns the class from this file
|
|
10
10
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from types import FrameType
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def get_current_frame() -> Optional[FrameType]:
|
|
7
|
+
return get_prev_frame_from(inspect.currentframe())
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_prev_frame_from(frame: Optional[FrameType]) -> Optional[FrameType]:
|
|
11
|
+
"""Get the previous frame (caller's frame) in the call stack."""
|
|
12
|
+
return frame.f_back if frame is not None else None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_n_prev_frame(n_steps: int = 1) -> Optional[FrameType]:
|
|
16
|
+
if (f := get_current_frame()) is None:
|
|
17
|
+
return None
|
|
18
|
+
i = 0
|
|
19
|
+
while i < n_steps:
|
|
20
|
+
if (f := f.f_back) is None:
|
|
21
|
+
return None
|
|
22
|
+
i += 1
|
|
23
|
+
return f
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"get_current_frame",
|
|
28
|
+
"get_prev_frame_from",
|
|
29
|
+
"get_n_prev_frame"
|
|
30
|
+
]
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import time
|
|
1
2
|
from datetime import datetime
|
|
2
3
|
from typing import Callable, TypeVar
|
|
3
|
-
from
|
|
4
|
-
|
|
4
|
+
from .reflection import get_python_version
|
|
5
|
+
|
|
6
|
+
if get_python_version() < (3, 9):
|
|
7
|
+
from typing_extensions import ParamSpec
|
|
8
|
+
else:
|
|
9
|
+
from typing import ParamSpec # type:ignore # pylint: disable=ungrouped-imports
|
|
5
10
|
T = TypeVar("T")
|
|
6
11
|
P = ParamSpec("P")
|
|
7
12
|
|
|
@@ -15,11 +20,13 @@ def measure(func: Callable[P, T]) -> Callable[P, float]:
|
|
|
15
20
|
Returns:
|
|
16
21
|
float: The time taken in seconds to execute the given function.
|
|
17
22
|
"""
|
|
23
|
+
|
|
18
24
|
def wrapper(*args, **kwargs) -> float:
|
|
19
25
|
start = time.time()
|
|
20
26
|
func(*args, **kwargs)
|
|
21
27
|
end = time.time()
|
|
22
|
-
return end-start
|
|
28
|
+
return end - start
|
|
29
|
+
|
|
23
30
|
return wrapper
|
|
24
31
|
|
|
25
32
|
|
|
@@ -19,12 +19,13 @@ from .print import *
|
|
|
19
19
|
from .exceptions import PrintCatchOne
|
|
20
20
|
from .reflection import *
|
|
21
21
|
from .metaclasses import *
|
|
22
|
-
from .
|
|
22
|
+
from .date_time import *
|
|
23
23
|
from .generators import *
|
|
24
24
|
from .snippets import *
|
|
25
25
|
from .aliases import *
|
|
26
26
|
from .signals import *
|
|
27
27
|
from .university import *
|
|
28
|
-
from .
|
|
29
|
-
from .
|
|
28
|
+
from .my_tqdm import *
|
|
29
|
+
from .threads import *
|
|
30
30
|
from .loops import *
|
|
31
|
+
from .multi_x import *
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Optional, Generator, List as t_list, Set as t_set
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
2
|
+
from .queue import Queue
|
|
3
|
+
from .node import MultiNode
|
|
4
4
|
from ..reflection import get_python_version
|
|
5
5
|
if get_python_version() >= (3, 9):
|
|
6
6
|
from builtins import list as t_list, set as t_set
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import Callable, Any, Union
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
2
|
+
from .heap import Heap
|
|
3
|
+
from .comparer import Comparer, CompareGreater
|
|
4
4
|
from .functions import default_weight_function
|
|
5
5
|
from ..metaclasses import AtomicClassMeta
|
|
6
6
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
from tqdm import tqdm
|
|
3
|
+
from .reflection import get_python_version
|
|
4
|
+
if get_python_version() >= (3, 9):
|
|
5
|
+
from builtins import list as t_list # type:ignore
|
|
6
|
+
else:
|
|
7
|
+
from typing import List as t_list
|
|
3
8
|
|
|
4
9
|
|
|
5
10
|
class ProgressBarPool:
|
|
6
|
-
def __init__(self, num_of_bars: int = 1, *, global_options: Optional[dict] = None, individual_options: Optional[
|
|
7
|
-
self.bars:
|
|
11
|
+
def __init__(self, num_of_bars: int = 1, *, global_options: Optional[dict] = None, individual_options: Optional[t_list[Optional[dict]]] = None) -> None:
|
|
12
|
+
self.bars: t_list[tqdm] = []
|
|
8
13
|
if global_options is None:
|
|
9
14
|
global_options = {}
|
|
10
15
|
if individual_options is None:
|
{danielutils-0.9.6/danielutils/threading → danielutils-0.9.62/danielutils/threads}/worker.py
RENAMED
|
@@ -3,6 +3,11 @@ from abc import ABC, abstractmethod
|
|
|
3
3
|
from typing import Optional, Any
|
|
4
4
|
from logging import error
|
|
5
5
|
import danielutils
|
|
6
|
+
from ..reflection import get_python_version
|
|
7
|
+
if get_python_version() >= (3, 9):
|
|
8
|
+
from builtins import tuple as t_tuple # type:ignore
|
|
9
|
+
else:
|
|
10
|
+
from typing import Tuple as t_tuple
|
|
6
11
|
|
|
7
12
|
|
|
8
13
|
class Worker(ABC):
|
|
@@ -47,16 +52,16 @@ class Worker(ABC):
|
|
|
47
52
|
execution of a single job
|
|
48
53
|
"""
|
|
49
54
|
self._work(obj)
|
|
50
|
-
self.
|
|
55
|
+
self._notify()
|
|
51
56
|
|
|
52
|
-
def
|
|
57
|
+
def _notify(self) -> None:
|
|
53
58
|
"""utility method to be called on the end of each iteration of work
|
|
54
59
|
to signal actions if needed
|
|
55
60
|
will call 'notification_function'
|
|
56
61
|
"""
|
|
57
62
|
self.pool._notify() # pylint: disable=protected-access
|
|
58
63
|
|
|
59
|
-
def acquire(self) -> Optional[
|
|
64
|
+
def acquire(self) -> Optional[t_tuple[Any]]:
|
|
60
65
|
"""acquire a new job object to work on from the pool
|
|
61
66
|
will return a tuple of only one object (the job) or None if there are no more jobs
|
|
62
67
|
Returns:
|
{danielutils-0.9.6/danielutils/threading → danielutils-0.9.62/danielutils/threads}/worker_pool.py
RENAMED
|
@@ -2,18 +2,23 @@ from queue import Queue
|
|
|
2
2
|
from typing import Optional, Any
|
|
3
3
|
from threading import Semaphore
|
|
4
4
|
from .worker import Worker
|
|
5
|
+
from ..reflection import get_python_version
|
|
6
|
+
if get_python_version() >= (3, 9):
|
|
7
|
+
from builtins import type as t_type, tuple as t_tuple, list as t_list # type:ignore
|
|
8
|
+
else:
|
|
9
|
+
from typing import Type as t_type, Tuple as t_tuple, List as t_list
|
|
5
10
|
|
|
6
11
|
|
|
7
12
|
class WorkerPool:
|
|
8
13
|
"""A worker pool class
|
|
9
14
|
"""
|
|
10
15
|
|
|
11
|
-
def __init__(self, num_workers: int, worker_class:
|
|
16
|
+
def __init__(self, num_workers: int, worker_class: t_type[Worker], w_kwargs: dict, global_variables: dict) -> None:
|
|
12
17
|
self.num_workers = num_workers
|
|
13
18
|
self.global_variables: dict = global_variables
|
|
14
|
-
self.q: Queue[
|
|
19
|
+
self.q: Queue[t_tuple[Any]] = Queue()
|
|
15
20
|
self.worker_class = worker_class
|
|
16
|
-
self.workers:
|
|
21
|
+
self.workers: t_list[Worker] = []
|
|
17
22
|
self.sem = Semaphore(0)
|
|
18
23
|
self.w_kwargs = w_kwargs
|
|
19
24
|
|
|
@@ -30,7 +35,7 @@ class WorkerPool:
|
|
|
30
35
|
self.q.put((job,))
|
|
31
36
|
self.sem.release()
|
|
32
37
|
|
|
33
|
-
def _acquire(self) -> Optional[
|
|
38
|
+
def _acquire(self) -> Optional[t_tuple[Any]]:
|
|
34
39
|
"""acquire a new job from the pool
|
|
35
40
|
|
|
36
41
|
Returns:
|
|
@@ -57,6 +62,10 @@ class WorkerPool:
|
|
|
57
62
|
if self.q.unfinished_tasks <= 0:
|
|
58
63
|
self.sem.release(self.num_workers)
|
|
59
64
|
|
|
65
|
+
def join(self) -> None:
|
|
66
|
+
for w in self.workers:
|
|
67
|
+
w.thread.join()
|
|
68
|
+
|
|
60
69
|
|
|
61
70
|
__all__ = [
|
|
62
71
|
"WorkerPool"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.62
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Home-page: https://github.com/danielnachumdev/danielutils
|
|
6
6
|
Author: danielnachumdev
|
|
@@ -36,7 +36,6 @@ Classifier: Programming Language :: Python :: 3
|
|
|
36
36
|
Classifier: Operating System :: Microsoft :: Windows
|
|
37
37
|
Requires-Python: >=3.8.17
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
|
-
Requires-Dist: tqdm
|
|
40
39
|
|
|
41
40
|
|
|
42
41
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml)
|
|
@@ -44,7 +43,7 @@ Requires-Dist: tqdm
|
|
|
44
43
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
45
44
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
46
45
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
47
|
-
# danielutils v=0.9.
|
|
46
|
+
# danielutils v=0.9.62
|
|
48
47
|
A utils library for things that I find useful for my coding workflow.\
|
|
49
48
|
Feel free to use and / or contribute / improve my code :)
|
|
50
49
|
|