danielutils 0.9.62__tar.gz → 1.0.0__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-1.0.0/MANIFEST.in +1 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/PKG-INFO +7 -7
- {danielutils-0.9.62 → danielutils-1.0.0}/README.md +4 -1
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Aliases.py +6 -7
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Colors.py +8 -8
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/main_conversions.py +9 -9
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/specialized_conversions/to_hex.py +2 -2
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/specialized_conversions/to_int.py +3 -3
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/__init__.py +4 -1
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/atomic.py +5 -7
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/attach.py +5 -7
- danielutils-1.0.0/danielutils/Decorators/decorate_conditionally.py +32 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/delay_call.py +4 -6
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/deprecate.py +7 -6
- danielutils-1.0.0/danielutils/Decorators/final.py +37 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/limit_recursion.py +7 -10
- danielutils-1.0.0/danielutils/Decorators/memo.py +51 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/overload.py +35 -28
- danielutils-0.9.62/danielutils/Decorators/PartiallyImplemented.py → danielutils-1.0.0/danielutils/Decorators/partially_implemented.py +4 -8
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/processify.py +11 -9
- danielutils-1.0.0/danielutils/Decorators/singleton.py +41 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/threadify.py +3 -6
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/timeout.py +12 -8
- danielutils-1.0.0/danielutils/Decorators/total_ordering.py +82 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/validate.py +91 -93
- danielutils-1.0.0/danielutils/Functions/__init__.py +13 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/areoneof.py +3 -3
- danielutils-1.0.0/danielutils/Functions/factorial.py +5 -0
- danielutils-1.0.0/danielutils/Functions/flatten.py +28 -0
- danielutils-1.0.0/danielutils/Functions/foreach.py +14 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/isoftype.py +156 -29
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/isoneof.py +4 -4
- danielutils-0.9.62/danielutils/loops.py → danielutils-1.0.0/danielutils/Functions/multiloop.py +3 -26
- danielutils-1.0.0/danielutils/Functions/parallel_for.py +37 -0
- danielutils-1.0.0/danielutils/Functions/partition.py +37 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/types_subseteq.py +4 -4
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Generators/generator_from_stream.py +1 -1
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Generators/join_generators.py +10 -9
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Internet.py +7 -7
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/MetaClasses/Interface.py +7 -7
- danielutils-1.0.0/danielutils/MetaClasses/__init__.py +5 -0
- danielutils-0.9.62/danielutils/MetaClasses/AtomicClassMeta.py → danielutils-1.0.0/danielutils/MetaClasses/atomic_class_meta.py +2 -2
- danielutils-0.9.62/danielutils/MetaClasses/InstanceCacheMeta.py → danielutils-1.0.0/danielutils/MetaClasses/instance_cache_meta.py +1 -1
- danielutils-0.9.62/danielutils/MetaClasses/OverloadMeta.py → danielutils-1.0.0/danielutils/MetaClasses/overload_meta.py +6 -4
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Reflection/__init__.py +9 -7
- danielutils-1.0.0/danielutils/Reflection/argument_info.py +114 -0
- danielutils-1.0.0/danielutils/Reflection/class_/__init__.py +1 -0
- danielutils-1.0.0/danielutils/Reflection/class_/class_reflection.py +226 -0
- danielutils-1.0.0/danielutils/Reflection/class_info.py +104 -0
- danielutils-1.0.0/danielutils/Reflection/decoration_info.py +44 -0
- danielutils-1.0.0/danielutils/Reflection/file/__init__.py +1 -0
- danielutils-1.0.0/danielutils/Reflection/file/file_reflection.py +58 -0
- danielutils-1.0.0/danielutils/Reflection/function/__init__.py +1 -0
- danielutils-0.9.62/danielutils/Reflection/Function.py → danielutils-1.0.0/danielutils/Reflection/function/function_reflections.py +56 -66
- danielutils-1.0.0/danielutils/Reflection/function_info.py +97 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/__init__.py +9 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/callstack.py +42 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/get_traceback.py +27 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/interpreter.py +41 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/is_debugging.py +13 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/os_.py +33 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/packages.py +33 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/python_version.py +26 -0
- danielutils-1.0.0/danielutils/Reflection/interpreter/tracer.py +175 -0
- danielutils-1.0.0/danielutils/Reflection/module/__init__.py +2 -0
- danielutils-1.0.0/danielutils/Reflection/module/package_reflection.py +157 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Text.py +8 -8
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Time.py +1 -5
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/University/Databases/all.py +22 -22
- danielutils-1.0.0/danielutils/University/__init__.py +7 -0
- danielutils-1.0.0/danielutils/University/computability_and_complexity/__init__.py +2 -0
- danielutils-1.0.0/danielutils/University/computability_and_complexity/discreate_finite_automaton.py +89 -0
- danielutils-1.0.0/danielutils/University/computability_and_complexity/languages/language.py +17 -0
- danielutils-1.0.0/danielutils/University/computability_and_complexity/languages/sat.py +71 -0
- danielutils-1.0.0/danielutils/University/computability_and_complexity/turing_machine.py +47 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/__init__.py +1 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/__init__.py +3 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/encoding.py +35 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossless/__init__.py +4 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossless/lossless_encoding.py +10 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossless/lzw.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossless/run_length.py +23 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossy/__init__.py +1 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossy/lossy_encoding.py +10 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/__init__.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/gaussian.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/gradient.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/hough.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/laplacian.py +0 -0
- danielutils-1.0.0/danielutils/University/image_proccesing/tansformations/transformation.py +11 -0
- danielutils-1.0.0/danielutils/University/linear_algebra/__init__.py +1 -0
- danielutils-1.0.0/danielutils/University/linear_algebra/matrix.py +398 -0
- danielutils-1.0.0/danielutils/University/machine_learning/__init__.py +0 -0
- danielutils-1.0.0/danielutils/University/machine_learning/activation_functions/__init__.py +2 -0
- danielutils-1.0.0/danielutils/University/machine_learning/activation_functions/activation_function.py +11 -0
- danielutils-1.0.0/danielutils/University/machine_learning/activation_functions/relu.py +11 -0
- danielutils-1.0.0/danielutils/University/machine_learning/neuron.py +15 -0
- danielutils-1.0.0/danielutils/University/oop/__init__.py +1 -0
- danielutils-1.0.0/danielutils/University/oop/observer.py +31 -0
- danielutils-1.0.0/danielutils/University/oop/strategy.py +9 -0
- danielutils-1.0.0/danielutils/University/probability/__init__.py +7 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/__init__.py +3 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/conditional_variable.py +110 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/continuous/__init__.py +0 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/__init__.py +7 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/bernoulli.py +38 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/binomial.py +40 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +36 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/discrete.py +42 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/geometric.py +43 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/poisson.py +32 -0
- danielutils-1.0.0/danielutils/University/probability/conditional_variable/discrete/uniform.py +33 -0
- danielutils-1.0.0/danielutils/University/probability/distributions.py +35 -0
- danielutils-1.0.0/danielutils/University/probability/expressions/__init__.py +2 -0
- danielutils-1.0.0/danielutils/University/probability/expressions/accumulation_expression.py +185 -0
- danielutils-1.0.0/danielutils/University/probability/expressions/probability_expression.py +110 -0
- danielutils-1.0.0/danielutils/University/probability/funcs/__init__.py +4 -0
- danielutils-1.0.0/danielutils/University/probability/funcs/covariance.py +12 -0
- danielutils-1.0.0/danielutils/University/probability/funcs/expected_value.py +41 -0
- danielutils-1.0.0/danielutils/University/probability/funcs/probability_function.py +14 -0
- danielutils-1.0.0/danielutils/University/probability/funcs/variance.py +17 -0
- danielutils-1.0.0/danielutils/University/probability/operator.py +79 -0
- danielutils-1.0.0/danielutils/University/probability/protocols.py +32 -0
- danielutils-1.0.0/danielutils/University/probability/supp.py +101 -0
- danielutils-1.0.0/danielutils/University/probability/transformation.py +44 -0
- danielutils-1.0.0/danielutils/__init__.py +47 -0
- danielutils-1.0.0/danielutils/abstractions/__init__.py +3 -0
- danielutils-1.0.0/danielutils/abstractions/database/__init__.py +2 -0
- danielutils-1.0.0/danielutils/abstractions/database/cached_database.py +75 -0
- danielutils-1.0.0/danielutils/abstractions/database/database.py +104 -0
- danielutils-1.0.0/danielutils/abstractions/database/redis_database.py +46 -0
- {danielutils-0.9.62/danielutils/threads → danielutils-1.0.0/danielutils/abstractions/multiprogramming}/__init__.py +1 -0
- danielutils-1.0.0/danielutils/abstractions/multiprogramming/multi_id.py +26 -0
- {danielutils-0.9.62/danielutils/threads → danielutils-1.0.0/danielutils/abstractions/multiprogramming}/worker.py +10 -9
- {danielutils-0.9.62/danielutils/threads → danielutils-1.0.0/danielutils/abstractions/multiprogramming}/worker_pool.py +12 -8
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/abstractions}/repl.py +13 -11
- danielutils-1.0.0/danielutils/better_builtins/__init__.py +3 -0
- danielutils-1.0.0/danielutils/better_builtins/frange.py +222 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/factory.py +9 -9
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/tdict.py +2 -2
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/tlist.py +3 -3
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/tset.py +1 -1
- danielutils-1.0.0/danielutils/context_managers/__init__.py +5 -0
- danielutils-1.0.0/danielutils/context_managers/attr_context.py +26 -0
- danielutils-1.0.0/danielutils/context_managers/multi_context.py +23 -0
- danielutils-1.0.0/danielutils/context_managers/optional_context.py +18 -0
- danielutils-1.0.0/danielutils/context_managers/state_context.py +16 -0
- danielutils-1.0.0/danielutils/context_managers/temporary_file.py +74 -0
- danielutils-1.0.0/danielutils/custom_types.py +18 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/data_structures/__init__.py +3 -2
- danielutils-1.0.0/danielutils/data_structures/algorithms.py +44 -0
- danielutils-1.0.0/danielutils/data_structures/comparer.py +40 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/data_structures/default_dict.py +4 -5
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/data_structures/functions.py +1 -1
- danielutils-1.0.0/danielutils/data_structures/graph/__init__.py +4 -0
- danielutils-1.0.0/danielutils/data_structures/graph/binary_node.py +71 -0
- {danielutils-0.9.62/danielutils/data_structures → danielutils-1.0.0/danielutils/data_structures/graph}/graph.py +79 -21
- danielutils-1.0.0/danielutils/data_structures/graph/multinode.py +101 -0
- danielutils-1.0.0/danielutils/data_structures/graph/node.py +60 -0
- danielutils-1.0.0/danielutils/data_structures/heap/__init__.py +3 -0
- {danielutils-0.9.62/danielutils/data_structures → danielutils-1.0.0/danielutils/data_structures/heap}/heap.py +13 -29
- danielutils-1.0.0/danielutils/data_structures/heap/max_heap.py +18 -0
- danielutils-1.0.0/danielutils/data_structures/heap/min_heap.py +18 -0
- danielutils-1.0.0/danielutils/data_structures/queue/__init__.py +3 -0
- danielutils-1.0.0/danielutils/data_structures/queue/atomic_queue.py +15 -0
- danielutils-0.9.62/danielutils/data_structures/queue.py → danielutils-1.0.0/danielutils/data_structures/queue/priority_queue.py +13 -79
- danielutils-1.0.0/danielutils/data_structures/queue/queue.py +72 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/data_structures/stack.py +24 -11
- danielutils-1.0.0/danielutils/data_structures/trees/__init__.py +2 -0
- danielutils-1.0.0/danielutils/data_structures/trees/binary_syntax_tree.py +84 -0
- danielutils-1.0.0/danielutils/data_structures/trees/binary_tree.py +63 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/date.py +2 -2
- danielutils-1.0.0/danielutils/file_specifications/__init__.py +71 -0
- danielutils-0.9.62/danielutils/IO.py → danielutils-1.0.0/danielutils/io_.py +74 -66
- danielutils-1.0.0/danielutils/java/__init__.py +8 -0
- danielutils-1.0.0/danielutils/java/interfaces/__init__.py +1 -0
- danielutils-1.0.0/danielutils/java/interfaces/comparable.py +31 -0
- danielutils-1.0.0/danielutils/java/java_interface.py +33 -0
- {danielutils-0.9.62/danielutils/Math → danielutils-1.0.0/danielutils/math_}/__init__.py +0 -1
- danielutils-0.9.62/danielutils/Math/Functions.py → danielutils-1.0.0/danielutils/math_/functions.py +1 -1
- {danielutils-0.9.62/danielutils/Math → danielutils-1.0.0/danielutils/math_}/math_print.py +1 -1
- {danielutils-0.9.62/danielutils/Math → danielutils-1.0.0/danielutils/math_}/math_symbols.py +5 -5
- danielutils-1.0.0/danielutils/mock_/__init__.py +2 -0
- danielutils-1.0.0/danielutils/mock_/mock_database.py +72 -0
- danielutils-1.0.0/danielutils/mock_/mock_module.py +18 -0
- danielutils-1.0.0/danielutils/print_.py +118 -0
- danielutils-1.0.0/danielutils/progress_bar/__init__.py +3 -0
- danielutils-1.0.0/danielutils/progress_bar/ascii_progress_bar.py +152 -0
- danielutils-1.0.0/danielutils/progress_bar/progress_bar.py +69 -0
- danielutils-1.0.0/danielutils/progress_bar/progress_bar_pool.py +64 -0
- danielutils-1.0.0/danielutils/protocols/__init__.py +3 -0
- danielutils-1.0.0/danielutils/protocols/dictable.py +20 -0
- danielutils-1.0.0/danielutils/protocols/evaluable.py +15 -0
- danielutils-1.0.0/danielutils/protocols/serializable.py +27 -0
- danielutils-1.0.0/danielutils/py.typed +0 -0
- danielutils-1.0.0/danielutils/random_.py +47 -0
- danielutils-1.0.0/danielutils/retry_executor/__init__.py +3 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/__init__.py +6 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/constant_backoff.py +20 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/exponential_backoff.py +20 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/functional_backoff.py +20 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/linear_backoff.py +18 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/multiplicative_backoff.py +18 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategies/no_backoff.py +12 -0
- danielutils-1.0.0/danielutils/retry_executor/backoff_strategy.py +22 -0
- danielutils-1.0.0/danielutils/retry_executor/retry_executor.py +37 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/__init__.py +1 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/independent.py +19 -18
- danielutils-1.0.0/danielutils/system/layered_command.py +118 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/windows/utils/filetime.py +2 -1
- danielutils-1.0.0/danielutils/testing/__init__.py +1 -0
- danielutils-1.0.0/danielutils/testing/unittest_/__init__.py +2 -0
- danielutils-1.0.0/danielutils/testing/unittest_/always_teardown_testcase.py +37 -0
- danielutils-1.0.0/danielutils/testing/unittest_/auto_cwd_testcase.py +49 -0
- danielutils-1.0.0/danielutils/versioned_imports.py +23 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils.egg-info/PKG-INFO +7 -7
- danielutils-1.0.0/danielutils.egg-info/SOURCES.txt +292 -0
- danielutils-1.0.0/pyproject.toml +31 -0
- danielutils-1.0.0/setup.py +3 -0
- danielutils-0.9.62/danielutils/Classes/__init__.py +0 -6
- danielutils-0.9.62/danielutils/Classes/frange.py +0 -61
- danielutils-0.9.62/danielutils/Classes/sorted_builtins/sset.py +0 -6
- danielutils-0.9.62/danielutils/Decorators/decorate_conditionally.py +0 -33
- danielutils-0.9.62/danielutils/Decorators/memo.py +0 -36
- danielutils-0.9.62/danielutils/Functions/__init__.py +0 -6
- danielutils-0.9.62/danielutils/MetaClasses/__init__.py +0 -5
- danielutils-0.9.62/danielutils/Print.py +0 -79
- danielutils-0.9.62/danielutils/Reflection/Class.py +0 -26
- danielutils-0.9.62/danielutils/Reflection/File.py +0 -43
- danielutils-0.9.62/danielutils/Reflection/System.py +0 -55
- danielutils-0.9.62/danielutils/Reflection/get_prev_frame.py +0 -30
- danielutils-0.9.62/danielutils/Reflection/get_traceback.py +0 -20
- danielutils-0.9.62/danielutils/University/__init__.py +0 -1
- danielutils-0.9.62/danielutils/__init__.py +0 -31
- danielutils-0.9.62/danielutils/data_structures/comparer.py +0 -37
- danielutils-0.9.62/danielutils/data_structures/node.py +0 -106
- danielutils-0.9.62/danielutils/multi_x.py +0 -16
- danielutils-0.9.62/danielutils/my_tqdm.py +0 -39
- danielutils-0.9.62/danielutils.egg-info/SOURCES.txt +0 -179
- danielutils-0.9.62/danielutils.egg-info/requires.txt +0 -1
- danielutils-0.9.62/pyproject.toml +0 -27
- danielutils-0.9.62/setup.py +0 -39
- /danielutils-0.9.62/LISENCE → /danielutils-1.0.0/LICENSE +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/chain_decorators.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Decorators/property.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Exceptions.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/check_foreach.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Functions/powerset.py +0 -0
- /danielutils-0.9.62/danielutils/Relations.py → /danielutils-1.0.0/danielutils/Functions/subseteq.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Generators/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Generators/conditional_generator.py +0 -0
- /danielutils-0.9.62/danielutils/MetaClasses/ImplicitDataDeleterMeta.py → /danielutils-1.0.0/danielutils/MetaClasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Path.py +0 -0
- /danielutils-0.9.62/danielutils/Signals.py → /danielutils-1.0.0/danielutils/Reflection/interpreter/signals.py +0 -0
- /danielutils-0.9.62/danielutils/Reflection/Module.py → /danielutils-1.0.0/danielutils/Reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Snippets/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Snippets/try_get.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/University/Databases/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Classes/sorted_builtins → danielutils-1.0.0/danielutils/University/computability_and_complexity/languages}/__init__.py +0 -0
- /danielutils-0.9.62/danielutils/Classes/Tree.py → /danielutils-1.0.0/danielutils/University/image_proccesing/encoding/lossless/huffman.py +0 -0
- /danielutils-0.9.62/danielutils/Classes/Counter.py → /danielutils-1.0.0/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-1.0.0/danielutils/better_builtins}/typed_builtins/ttuple.py +0 -0
- /danielutils-0.9.62/danielutils/Classes/Convenience.py → /danielutils-1.0.0/danielutils/convenience.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/date_time.py +0 -0
- /danielutils-0.9.62/danielutils/Math/Constants.py → /danielutils-1.0.0/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.62 → danielutils-1.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
recursive-include danielutils *.py
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
|
-
Home-page: https://github.com/danielnachumdev/danielutils
|
|
6
|
-
Author: danielnachumdev
|
|
7
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
8
6
|
License: MIT License
|
|
9
7
|
|
|
@@ -28,14 +26,13 @@ License: MIT License
|
|
|
28
26
|
SOFTWARE.
|
|
29
27
|
Project-URL: Homepage, https://github.com/danielnachumdev/danielutils
|
|
30
28
|
Project-URL: Bug Tracker, https://github.com/danielnachumdev/danielutils/issues
|
|
31
|
-
Keywords: functions,decorators,methods,classes,metaclasses
|
|
32
|
-
Platform: All
|
|
33
29
|
Classifier: Development Status :: 3 - Alpha
|
|
34
30
|
Classifier: Intended Audience :: Developers
|
|
35
31
|
Classifier: Programming Language :: Python :: 3
|
|
36
32
|
Classifier: Operating System :: Microsoft :: Windows
|
|
37
|
-
Requires-Python: >=3.8.
|
|
33
|
+
Requires-Python: >=3.8.0
|
|
38
34
|
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
39
36
|
|
|
40
37
|
|
|
41
38
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/python-package.yml)
|
|
@@ -43,12 +40,15 @@ Description-Content-Type: text/markdown
|
|
|
43
40
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
44
41
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
45
42
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
46
|
-
# danielutils v=0.
|
|
43
|
+
# danielutils v=1.0.0
|
|
47
44
|
A utils library for things that I find useful for my coding workflow.\
|
|
48
45
|
Feel free to use and / or contribute / improve my code :)
|
|
49
46
|
|
|
50
47
|
THIS PACKAGE IS IN DEVELOPMENT AND SUBJECT TO CHANGE, USE AT YOUR OWN RISK!
|
|
51
48
|
|
|
49
|
+
**Tested python versions**: `3.8.0`*, `3.9.0`, `3.10.13`
|
|
50
|
+
|
|
51
|
+
Versions marked with * are partially working
|
|
52
52
|
# Showcase
|
|
53
53
|
In [this](./READMES/) folder you can check out some more in depth showcase of some of the topics I have covered in this package
|
|
54
54
|
|
|
@@ -4,12 +4,15 @@
|
|
|
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.
|
|
7
|
+
# danielutils v=1.0.0
|
|
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
|
|
|
11
11
|
THIS PACKAGE IS IN DEVELOPMENT AND SUBJECT TO CHANGE, USE AT YOUR OWN RISK!
|
|
12
12
|
|
|
13
|
+
**Tested python versions**: `3.8.0`*, `3.9.0`, `3.10.13`
|
|
14
|
+
|
|
15
|
+
Versions marked with * are partially working
|
|
13
16
|
# Showcase
|
|
14
17
|
In [this](./READMES/) folder you can check out some more in depth showcase of some of the topics I have covered in this package
|
|
15
18
|
|
|
@@ -150,16 +150,15 @@ T = TypeVar("T")
|
|
|
150
150
|
|
|
151
151
|
Supplier = Callable[[], T]
|
|
152
152
|
Runnable = Supplier[None]
|
|
153
|
-
|
|
153
|
+
Consumer = Callable[[T], None]
|
|
154
154
|
UnaryFunction = Callable[[U], T]
|
|
155
|
-
UnaryOperator =
|
|
156
|
-
Predicate =
|
|
157
|
-
Consumer = UnaryFunction[T, None]
|
|
155
|
+
UnaryOperator = Callable[[T], T]
|
|
156
|
+
Predicate = Callable[[T], bool]
|
|
158
157
|
|
|
159
158
|
BinaryFunction = Callable[[A, B], T]
|
|
160
|
-
BinaryOperator =
|
|
161
|
-
Comparator =
|
|
162
|
-
BinaryConsumer =
|
|
159
|
+
BinaryOperator = Callable[[T, T], T]
|
|
160
|
+
Comparator = Callable[[A, B], int]
|
|
161
|
+
BinaryConsumer = Callable[[T, T], None]
|
|
163
162
|
|
|
164
163
|
__all__ = [
|
|
165
164
|
"UnaryFunction",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Optional, IO
|
|
2
|
-
from .decorators
|
|
3
|
-
|
|
2
|
+
from .decorators import validate
|
|
4
3
|
|
|
5
4
|
RESET = "\033[0m"
|
|
6
5
|
|
|
@@ -16,15 +15,16 @@ class ColoredText:
|
|
|
16
15
|
white,
|
|
17
16
|
black
|
|
18
17
|
"""
|
|
19
|
-
|
|
20
|
-
@
|
|
18
|
+
|
|
19
|
+
@staticmethod # type:ignore
|
|
20
|
+
@validate # type:ignore
|
|
21
21
|
def from_rgb(red: int, green: int, blue: int, text: str) -> str:
|
|
22
22
|
"""Applies an RGB color to the given text.
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
red (int): The red component of the color.
|
|
26
|
+
green (int): The green component of the color.
|
|
27
|
+
blue (int): The blue component of the color.
|
|
28
28
|
text (str): The text to apply the color to.
|
|
29
29
|
|
|
30
30
|
Returns:
|
|
@@ -178,7 +178,7 @@ def error(*args, sep: str = " ", end: str = "\n"):
|
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
def info(*args, sep: str = " ", end: str = "\n"):
|
|
181
|
-
"""print an
|
|
181
|
+
"""print an info message
|
|
182
182
|
|
|
183
183
|
Args:
|
|
184
184
|
sep (str, optional): print separator. Defaults to " ".
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from ..decorators import validate
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
@validate
|
|
4
|
+
@validate # type:ignore
|
|
5
5
|
def char_to_int(c: str) -> int:
|
|
6
6
|
"""convert char to its representing int value
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ def char_to_int(c: str) -> int:
|
|
|
14
14
|
return ord(c)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
@validate
|
|
17
|
+
@validate # type:ignore
|
|
18
18
|
def int_to_char(num: int) -> str:
|
|
19
19
|
"""convert int to its corresponding char
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ def int_to_char(num: int) -> str:
|
|
|
27
27
|
return chr(num)
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
@validate
|
|
30
|
+
@validate # type:ignore
|
|
31
31
|
def hex_to_char(h: str) -> str:
|
|
32
32
|
"""convert hex number to char
|
|
33
33
|
|
|
@@ -40,7 +40,7 @@ def hex_to_char(h: str) -> str:
|
|
|
40
40
|
return int_to_char(hex_to_dec(h))
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
@validate
|
|
43
|
+
@validate # type:ignore
|
|
44
44
|
def hex_to_dec(h: str) -> int:
|
|
45
45
|
"""convert hex to dec
|
|
46
46
|
|
|
@@ -53,7 +53,7 @@ def hex_to_dec(h: str) -> int:
|
|
|
53
53
|
return int(h, 16)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
@validate
|
|
56
|
+
@validate # type:ignore
|
|
57
57
|
def char_to_hex(c: str) -> str:
|
|
58
58
|
"""convert char to hex
|
|
59
59
|
|
|
@@ -66,7 +66,7 @@ def char_to_hex(c: str) -> str:
|
|
|
66
66
|
return int_to_hex(char_to_int(c))
|
|
67
67
|
|
|
68
68
|
|
|
69
|
-
@validate
|
|
69
|
+
@validate # type:ignore
|
|
70
70
|
def dec_to_hex(num: int) -> str:
|
|
71
71
|
"""convert decimal number to hex
|
|
72
72
|
|
|
@@ -79,7 +79,7 @@ def dec_to_hex(num: int) -> str:
|
|
|
79
79
|
return int_to_hex(num)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
@validate
|
|
82
|
+
@validate # type:ignore
|
|
83
83
|
def int_to_hex(num: int) -> str:
|
|
84
84
|
"""converts an int to it's hex representation
|
|
85
85
|
|
|
@@ -92,7 +92,7 @@ def int_to_hex(num: int) -> str:
|
|
|
92
92
|
return hex(num)
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
@validate
|
|
95
|
+
@validate # type:ignore
|
|
96
96
|
def bytes_to_str(b: bytes) -> str:
|
|
97
97
|
"""decodes bytes to str
|
|
98
98
|
|
|
@@ -105,7 +105,7 @@ def bytes_to_str(b: bytes) -> str:
|
|
|
105
105
|
return b.decode("utf-8")
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
@validate
|
|
108
|
+
@validate # type:ignore
|
|
109
109
|
def str_to_bytes(s: str) -> bytes:
|
|
110
110
|
"""encodes a string to bytes
|
|
111
111
|
|
{danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/specialized_conversions/to_hex.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ...metaclasses.
|
|
1
|
+
from ...metaclasses.overload_meta import OverloadMeta
|
|
2
2
|
from ..main_conversions import int_to_hex, char_to_hex
|
|
3
3
|
|
|
4
4
|
|
|
@@ -8,7 +8,7 @@ def to_hex(v: int) -> str:
|
|
|
8
8
|
return int_to_hex(v)
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
@to_hex.overload
|
|
11
|
+
@to_hex.overload # type:ignore
|
|
12
12
|
def to_hex2(v: str) -> str:
|
|
13
13
|
"""to_hex has several options:\n
|
|
14
14
|
1. type(v) == int\n
|
{danielutils-0.9.62 → danielutils-1.0.0}/danielutils/Conversions/specialized_conversions/to_int.py
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""functions that convert values to int"""
|
|
2
|
-
from typing import Union, List as
|
|
2
|
+
from typing import Union, List as List
|
|
3
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
|
-
from builtins import list as
|
|
6
|
+
from builtins import list as List
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def to_int(value: str) -> Union[int,
|
|
9
|
+
def to_int(value: str) -> Union[int, List[int]]:
|
|
10
10
|
"""converts a single character or a full string to an int or list of int respectively
|
|
11
11
|
"""
|
|
12
12
|
if len(value) == 1:
|
|
@@ -5,10 +5,13 @@ from .decorate_conditionally import *
|
|
|
5
5
|
from .limit_recursion import *
|
|
6
6
|
from .memo import *
|
|
7
7
|
from .overload import *
|
|
8
|
-
from .
|
|
8
|
+
from .partially_implemented import *
|
|
9
9
|
from .timeout import *
|
|
10
10
|
from .chain_decorators import *
|
|
11
11
|
from .threadify import *
|
|
12
12
|
from .delay_call import *
|
|
13
13
|
from .deprecate import *
|
|
14
14
|
from .processify import *
|
|
15
|
+
from .singleton import *
|
|
16
|
+
from .total_ordering import *
|
|
17
|
+
from .final import *
|
|
@@ -3,17 +3,14 @@ from typing import Callable, Any, TypeVar
|
|
|
3
3
|
import threading
|
|
4
4
|
from .validate import validate
|
|
5
5
|
|
|
6
|
-
from ..
|
|
7
|
-
|
|
8
|
-
from typing_extensions import ParamSpec
|
|
9
|
-
else:
|
|
10
|
-
from typing import ParamSpec # type:ignore # pylint: disable=ungrouped-imports
|
|
6
|
+
from ..versioned_imports import ParamSpec
|
|
7
|
+
|
|
11
8
|
T = TypeVar("T")
|
|
12
9
|
P = ParamSpec("P")
|
|
13
10
|
FuncT = Callable[P, T] # type:ignore
|
|
14
11
|
|
|
15
12
|
|
|
16
|
-
@validate
|
|
13
|
+
@validate # type:ignore
|
|
17
14
|
def atomic(func: FuncT) -> FuncT:
|
|
18
15
|
"""will make function thread safe by making it
|
|
19
16
|
accessible for only one thread at one time
|
|
@@ -26,10 +23,11 @@ def atomic(func: FuncT) -> FuncT:
|
|
|
26
23
|
"""
|
|
27
24
|
lock = threading.Lock()
|
|
28
25
|
|
|
29
|
-
@
|
|
26
|
+
@functools.wraps(func)
|
|
30
27
|
def wrapper(*args, **kwargs) -> Any:
|
|
31
28
|
with lock:
|
|
32
29
|
return func(*args, **kwargs)
|
|
30
|
+
|
|
33
31
|
return wrapper
|
|
34
32
|
|
|
35
33
|
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
from typing import Callable, Optional, TypeVar
|
|
3
|
-
import platform
|
|
4
3
|
from .validate import validate
|
|
5
|
-
from ..
|
|
6
|
-
|
|
7
|
-
from typing_extensions import ParamSpec
|
|
8
|
-
else:
|
|
9
|
-
from typing import ParamSpec # type:ignore # pylint: disable=ungrouped-imports
|
|
4
|
+
from ..versioned_imports import ParamSpec
|
|
5
|
+
|
|
10
6
|
T = TypeVar("T")
|
|
11
7
|
P = ParamSpec("P")
|
|
12
8
|
FuncT = Callable[P, T] # type:ignore
|
|
13
9
|
|
|
14
10
|
|
|
15
|
-
@validate(strict=False)
|
|
11
|
+
@validate(strict=False) # type:ignore
|
|
16
12
|
def attach(before: Optional[Callable] = None, after: Optional[Callable] = None) -> Callable[[FuncT], FuncT]:
|
|
17
13
|
"""attaching functions to a function
|
|
18
14
|
|
|
@@ -42,7 +38,9 @@ def attach(before: Optional[Callable] = None, after: Optional[Callable] = None)
|
|
|
42
38
|
if after is not None:
|
|
43
39
|
after()
|
|
44
40
|
return res
|
|
41
|
+
|
|
45
42
|
return wrapper
|
|
43
|
+
|
|
46
44
|
return attach_deco
|
|
47
45
|
|
|
48
46
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
from typing import Callable, Optional, Union
|
|
3
|
+
from .validate import validate
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@validate(strict=False) # type:ignore
|
|
7
|
+
def decorate_conditionally(decorator: Callable, predicate: Union[bool, Callable[[], bool]], *,
|
|
8
|
+
decorator_args: Optional[list] = None, decorator_kwargs: Optional[dict] = None):
|
|
9
|
+
"""will decorate a function iff the predicate is True or returns True
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
decorator (Callable): the decorator to use
|
|
13
|
+
predicate (bool | Callable[[], bool]): the predicate
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def deco(func):
|
|
17
|
+
if (predicate() if callable(predicate) else predicate):
|
|
18
|
+
nonlocal decorator_args, decorator_kwargs, decorator
|
|
19
|
+
if decorator_args is None:
|
|
20
|
+
decorator_args = []
|
|
21
|
+
if decorator_kwargs is None:
|
|
22
|
+
decorator_kwargs = {}
|
|
23
|
+
decorator = functools.wraps(func)(decorator)
|
|
24
|
+
return decorator(*decorator_args, **decorator_kwargs)(func)
|
|
25
|
+
return func
|
|
26
|
+
|
|
27
|
+
return deco
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"decorate_conditionally"
|
|
32
|
+
]
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
from typing import Callable, TypeVar, Union
|
|
2
|
-
import platform
|
|
3
2
|
import time
|
|
4
3
|
import functools
|
|
5
4
|
from .decorate_conditionally import decorate_conditionally
|
|
6
5
|
from .threadify import threadify
|
|
6
|
+
from ..versioned_imports import ParamSpec
|
|
7
7
|
|
|
8
|
-
from ..reflection import get_python_version
|
|
9
|
-
if get_python_version() < (3, 9):
|
|
10
|
-
from typing_extensions import ParamSpec
|
|
11
|
-
else:
|
|
12
|
-
from typing import ParamSpec # type:ignore# pylint: disable=ungrouped-imports
|
|
13
8
|
T = TypeVar("T")
|
|
14
9
|
P = ParamSpec("P")
|
|
15
10
|
FuncT = Callable[P, T] # type:ignore
|
|
@@ -23,13 +18,16 @@ def delay_call(seconds: Union[float, int], blocking: bool = True) -> Callable[[F
|
|
|
23
18
|
blocking (bool, optional): whether to block the main thread
|
|
24
19
|
when waiting or to wait in a different thread. Defaults to True.
|
|
25
20
|
"""
|
|
21
|
+
|
|
26
22
|
def deco(func: FuncT) -> FuncT:
|
|
27
23
|
@decorate_conditionally(threadify, not blocking)
|
|
28
24
|
@functools.wraps(func)
|
|
29
25
|
def wrapper(*args, **kwargs):
|
|
30
26
|
time.sleep(seconds)
|
|
31
27
|
func(*args, **kwargs)
|
|
28
|
+
|
|
32
29
|
return wrapper
|
|
30
|
+
|
|
33
31
|
return deco
|
|
34
32
|
|
|
35
33
|
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import platform
|
|
2
1
|
from typing import Callable, TypeVar
|
|
3
2
|
from ..colors import warning, ColoredText
|
|
3
|
+
from ..versioned_imports import ParamSpec
|
|
4
4
|
|
|
5
|
-
from ..reflection import get_python_version
|
|
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
|
|
10
5
|
T = TypeVar("T")
|
|
11
6
|
P = ParamSpec("P")
|
|
12
7
|
FuncT = Callable[P, T] # type:ignore
|
|
@@ -14,13 +9,16 @@ FuncT = Callable[P, T] # type:ignore
|
|
|
14
9
|
|
|
15
10
|
def deprecate_with(replacement_func) -> Callable[[FuncT], FuncT]:
|
|
16
11
|
"""will replace a deprecated function with the replacement func and will print a warning"""
|
|
12
|
+
|
|
17
13
|
def deco(func: FuncT) -> FuncT:
|
|
18
14
|
warning(f"{func.__module__}.{func.__qualname__} is deprecated,"
|
|
19
15
|
f" using {replacement_func.__module__}.{replacement_func.__qualname__} instead")
|
|
20
16
|
|
|
21
17
|
def wrapper(*args, **kwargs):
|
|
22
18
|
return replacement_func(*args, **kwargs)
|
|
19
|
+
|
|
23
20
|
return wrapper
|
|
21
|
+
|
|
24
22
|
return deco
|
|
25
23
|
|
|
26
24
|
|
|
@@ -30,12 +28,15 @@ def deprecate(deprecation_message: str) -> Callable[[FuncT], FuncT]:
|
|
|
30
28
|
Args:
|
|
31
29
|
deprecation_message (str): deprecation message
|
|
32
30
|
"""
|
|
31
|
+
|
|
33
32
|
def deco(func: FuncT) -> FuncT:
|
|
34
33
|
def wrapper(*args, **kwargs):
|
|
35
34
|
print(ColoredText.orange("Deprecation Warning") +
|
|
36
35
|
":", deprecation_message)
|
|
37
36
|
return func(*args, **kwargs)
|
|
37
|
+
|
|
38
38
|
return wrapper
|
|
39
|
+
|
|
39
40
|
return deco
|
|
40
41
|
|
|
41
42
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
def final(cls: type) -> type:
|
|
2
|
+
"""
|
|
3
|
+
A class Decorator to mark a class as final and add expected behavior
|
|
4
|
+
Args:
|
|
5
|
+
cls: the class to mark
|
|
6
|
+
|
|
7
|
+
Returns:
|
|
8
|
+
marked class
|
|
9
|
+
"""
|
|
10
|
+
def __init__subclass__(*args, **kwargs):
|
|
11
|
+
raise TypeError(f"'{cls.__qualname__}' is final. Can't create subclasses")
|
|
12
|
+
|
|
13
|
+
setattr(cls, "__init_subclass__", __init__subclass__)
|
|
14
|
+
return cls
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Final:
|
|
18
|
+
"""
|
|
19
|
+
A parent class to make direct child a Final class. will add expected behaviour.
|
|
20
|
+
"""
|
|
21
|
+
def __new__(cls, *args, **kwargs):
|
|
22
|
+
if cls is Final:
|
|
23
|
+
raise TypeError("Can't instantiate 'Final'")
|
|
24
|
+
return super().__new__(cls, *args, **kwargs)
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def __init_subclass__(cls, **kwargs):
|
|
28
|
+
def __init__subclass__(*args, **kwargs):
|
|
29
|
+
raise TypeError(f"'{cls.__qualname__}' is final. Can't create subclasses")
|
|
30
|
+
|
|
31
|
+
setattr(cls, "__init_subclass__", __init__subclass__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"final",
|
|
36
|
+
"Final"
|
|
37
|
+
]
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
import re
|
|
3
3
|
import traceback
|
|
4
|
-
import platform
|
|
5
4
|
from typing import Any, Callable, TypeVar
|
|
6
5
|
from .validate import validate
|
|
7
6
|
from ..colors import warning
|
|
7
|
+
from ..versioned_imports import ParamSpec
|
|
8
8
|
|
|
9
|
-
from ..reflection import get_python_version
|
|
10
|
-
if get_python_version() < (3, 9):
|
|
11
|
-
from typing_extensions import ParamSpec
|
|
12
|
-
else:
|
|
13
|
-
from typing import ParamSpec # type:ignore # pylint: disable=ungrouped-imports
|
|
14
9
|
T = TypeVar("T")
|
|
15
10
|
P = ParamSpec("P")
|
|
16
11
|
FuncT = Callable[P, T] # type:ignore
|
|
17
12
|
|
|
18
13
|
|
|
19
|
-
@validate
|
|
14
|
+
@validate # type:ignore
|
|
20
15
|
def limit_recursion(max_depth: int, return_value: Any = None, quiet: bool = True) -> Callable[[FuncT], FuncT]:
|
|
21
16
|
"""decorator to limit recursion of functions
|
|
22
17
|
|
|
@@ -28,12 +23,12 @@ def limit_recursion(max_depth: int, return_value: Any = None, quiet: bool = True
|
|
|
28
23
|
"""
|
|
29
24
|
|
|
30
25
|
def deco(func: FuncT) -> FuncT:
|
|
31
|
-
@
|
|
26
|
+
@functools.wraps(func)
|
|
32
27
|
def wrapper(*args, **kwargs):
|
|
33
28
|
depth = functools.reduce(
|
|
34
29
|
lambda count, line:
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
count + 1 if re.search(rf"{func.__name__}\(.*\)$", line)
|
|
31
|
+
else count,
|
|
37
32
|
traceback.format_stack(), 0
|
|
38
33
|
)
|
|
39
34
|
if depth >= max_depth:
|
|
@@ -45,7 +40,9 @@ def limit_recursion(max_depth: int, return_value: Any = None, quiet: bool = True
|
|
|
45
40
|
return return_value
|
|
46
41
|
return args, kwargs
|
|
47
42
|
return func(*args, **kwargs)
|
|
43
|
+
|
|
48
44
|
return wrapper
|
|
45
|
+
|
|
49
46
|
return deco
|
|
50
47
|
|
|
51
48
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
from typing import Callable, Any, TypeVar, Dict, Generator, List, Set, Optional
|
|
3
|
+
from copy import deepcopy
|
|
4
|
+
from .validate import validate
|
|
5
|
+
from ..versioned_imports import ParamSpec
|
|
6
|
+
|
|
7
|
+
T = TypeVar("T")
|
|
8
|
+
P = ParamSpec("P")
|
|
9
|
+
FuncT = Callable[P, T] # type:ignore
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@validate # type:ignore
|
|
13
|
+
def memo(func: FuncT) -> FuncT:
|
|
14
|
+
"""decorator to memorize function calls in order to improve performance by using more memory
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
func (Callable): function to memorize
|
|
18
|
+
"""
|
|
19
|
+
cache: Dict[tuple, Any] = {}
|
|
20
|
+
|
|
21
|
+
@functools.wraps(func)
|
|
22
|
+
def wrapper(*args, **kwargs):
|
|
23
|
+
if (args, *kwargs.items()) not in cache:
|
|
24
|
+
cache[(args, *kwargs.items())] = func(*args, **kwargs)
|
|
25
|
+
return deepcopy(cache[(args, *kwargs.items())])
|
|
26
|
+
|
|
27
|
+
return wrapper
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def memo_generator(func: Callable[P, Generator]) -> Callable[P, Generator]:
|
|
31
|
+
cache: Dict[tuple, Any] = {}
|
|
32
|
+
|
|
33
|
+
@functools.wraps(func)
|
|
34
|
+
def wrapper(*args: P.args, **kwargs: P.kwargs) -> Generator:
|
|
35
|
+
args = tuple(args)
|
|
36
|
+
if (args, *kwargs.items()) not in cache:
|
|
37
|
+
lst = []
|
|
38
|
+
for v in func(*args, **kwargs):
|
|
39
|
+
lst.append(v)
|
|
40
|
+
yield v
|
|
41
|
+
cache[(args, *kwargs.items())] = lst
|
|
42
|
+
else:
|
|
43
|
+
yield from cache[(args, *kwargs.items())]
|
|
44
|
+
|
|
45
|
+
return wrapper
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
"memo",
|
|
50
|
+
"memo_generator"
|
|
51
|
+
]
|