danielutils 0.9.62__tar.gz → 0.9.94__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.94/MANIFEST.in +1 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/PKG-INFO +7 -7
- {danielutils-0.9.62 → danielutils-0.9.94}/README.md +4 -1
- danielutils-0.9.94/danielutils/__init__.py +47 -0
- danielutils-0.9.94/danielutils/abstractions/__init__.py +3 -0
- danielutils-0.9.94/danielutils/abstractions/database/__init__.py +2 -0
- danielutils-0.9.94/danielutils/abstractions/database/cached_database.py +75 -0
- danielutils-0.9.94/danielutils/abstractions/database/database.py +104 -0
- danielutils-0.9.94/danielutils/abstractions/database/redis_database.py +46 -0
- {danielutils-0.9.62/danielutils/threads → danielutils-0.9.94/danielutils/abstractions/multiprogramming}/__init__.py +1 -0
- danielutils-0.9.94/danielutils/abstractions/multiprogramming/multi_id.py +26 -0
- {danielutils-0.9.62/danielutils/threads → danielutils-0.9.94/danielutils/abstractions/multiprogramming}/worker.py +10 -9
- {danielutils-0.9.62/danielutils/threads → danielutils-0.9.94/danielutils/abstractions/multiprogramming}/worker_pool.py +12 -8
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/abstractions}/repl.py +13 -11
- danielutils-0.9.62/danielutils/Aliases.py → danielutils-0.9.94/danielutils/aliases.py +6 -7
- danielutils-0.9.94/danielutils/better_builtins/__init__.py +3 -0
- danielutils-0.9.94/danielutils/better_builtins/frange.py +222 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/factory.py +9 -9
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/tdict.py +2 -2
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/tlist.py +3 -3
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/tset.py +1 -1
- danielutils-0.9.62/danielutils/Colors.py → danielutils-0.9.94/danielutils/colors.py +8 -8
- danielutils-0.9.94/danielutils/context_managers/__init__.py +5 -0
- danielutils-0.9.94/danielutils/context_managers/attr_context.py +26 -0
- danielutils-0.9.94/danielutils/context_managers/multi_context.py +23 -0
- danielutils-0.9.94/danielutils/context_managers/optional_context.py +18 -0
- danielutils-0.9.94/danielutils/context_managers/state_context.py +16 -0
- danielutils-0.9.94/danielutils/context_managers/temporary_file.py +74 -0
- {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.94/danielutils/conversions}/main_conversions.py +9 -9
- {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.94/danielutils/conversions}/specialized_conversions/to_hex.py +2 -2
- {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.94/danielutils/conversions}/specialized_conversions/to_int.py +3 -3
- danielutils-0.9.94/danielutils/custom_types.py +22 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/data_structures/__init__.py +3 -2
- danielutils-0.9.94/danielutils/data_structures/algorithms.py +44 -0
- danielutils-0.9.94/danielutils/data_structures/comparer.py +40 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/data_structures/default_dict.py +4 -5
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/data_structures/functions.py +1 -1
- danielutils-0.9.94/danielutils/data_structures/graph/__init__.py +4 -0
- danielutils-0.9.94/danielutils/data_structures/graph/binary_node.py +71 -0
- {danielutils-0.9.62/danielutils/data_structures → danielutils-0.9.94/danielutils/data_structures/graph}/graph.py +79 -21
- danielutils-0.9.94/danielutils/data_structures/graph/multinode.py +101 -0
- danielutils-0.9.94/danielutils/data_structures/graph/node.py +60 -0
- danielutils-0.9.94/danielutils/data_structures/heap/__init__.py +3 -0
- {danielutils-0.9.62/danielutils/data_structures → danielutils-0.9.94/danielutils/data_structures/heap}/heap.py +13 -29
- danielutils-0.9.94/danielutils/data_structures/heap/max_heap.py +18 -0
- danielutils-0.9.94/danielutils/data_structures/heap/min_heap.py +18 -0
- danielutils-0.9.94/danielutils/data_structures/queue/__init__.py +3 -0
- danielutils-0.9.94/danielutils/data_structures/queue/atomic_queue.py +15 -0
- danielutils-0.9.62/danielutils/data_structures/queue.py → danielutils-0.9.94/danielutils/data_structures/queue/priority_queue.py +13 -79
- danielutils-0.9.94/danielutils/data_structures/queue/queue.py +72 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/data_structures/stack.py +24 -11
- danielutils-0.9.94/danielutils/data_structures/trees/__init__.py +2 -0
- danielutils-0.9.94/danielutils/data_structures/trees/binary_syntax_tree.py +84 -0
- danielutils-0.9.94/danielutils/data_structures/trees/binary_tree.py +63 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/date.py +2 -2
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/__init__.py +4 -1
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/atomic.py +5 -7
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/attach.py +5 -7
- danielutils-0.9.94/danielutils/decorators/decorate_conditionally.py +32 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/delay_call.py +4 -6
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/deprecate.py +7 -6
- danielutils-0.9.94/danielutils/decorators/final.py +37 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/limit_recursion.py +7 -10
- danielutils-0.9.94/danielutils/decorators/memo.py +51 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/overload.py +35 -28
- danielutils-0.9.62/danielutils/Decorators/PartiallyImplemented.py → danielutils-0.9.94/danielutils/decorators/partially_implemented.py +4 -8
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/processify.py +11 -9
- danielutils-0.9.94/danielutils/decorators/singleton.py +24 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/threadify.py +3 -6
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/timeout.py +12 -8
- danielutils-0.9.94/danielutils/decorators/total_ordering.py +82 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/validate.py +91 -93
- danielutils-0.9.94/danielutils/file_specifications/__init__.py +71 -0
- danielutils-0.9.94/danielutils/functions/__init__.py +13 -0
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/areoneof.py +3 -3
- danielutils-0.9.94/danielutils/functions/factorial.py +5 -0
- danielutils-0.9.94/danielutils/functions/flatten.py +28 -0
- danielutils-0.9.94/danielutils/functions/foreach.py +14 -0
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/isoftype.py +133 -20
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/isoneof.py +4 -4
- danielutils-0.9.62/danielutils/loops.py → danielutils-0.9.94/danielutils/functions/multiloop.py +3 -26
- danielutils-0.9.94/danielutils/functions/parallel_for.py +37 -0
- danielutils-0.9.94/danielutils/functions/partition.py +37 -0
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/types_subseteq.py +4 -4
- {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.94/danielutils/generators}/generator_from_stream.py +1 -1
- {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.94/danielutils/generators}/join_generators.py +10 -9
- danielutils-0.9.62/danielutils/Internet.py → danielutils-0.9.94/danielutils/internet.py +7 -7
- danielutils-0.9.62/danielutils/IO.py → danielutils-0.9.94/danielutils/io_.py +74 -66
- danielutils-0.9.94/danielutils/java/__init__.py +2 -0
- danielutils-0.9.94/danielutils/java/interfaces/__init__.py +1 -0
- danielutils-0.9.94/danielutils/java/interfaces/comparable.py +31 -0
- danielutils-0.9.94/danielutils/java/java_interface.py +25 -0
- {danielutils-0.9.62/danielutils/Math → danielutils-0.9.94/danielutils/math_}/__init__.py +0 -1
- danielutils-0.9.62/danielutils/Math/Functions.py → danielutils-0.9.94/danielutils/math_/functions.py +1 -1
- {danielutils-0.9.62/danielutils/Math → danielutils-0.9.94/danielutils/math_}/math_print.py +1 -1
- {danielutils-0.9.62/danielutils/Math → danielutils-0.9.94/danielutils/math_}/math_symbols.py +5 -5
- danielutils-0.9.94/danielutils/metaclasses/__init__.py +5 -0
- danielutils-0.9.62/danielutils/MetaClasses/AtomicClassMeta.py → danielutils-0.9.94/danielutils/metaclasses/atomic_class_meta.py +2 -2
- danielutils-0.9.62/danielutils/MetaClasses/InstanceCacheMeta.py → danielutils-0.9.94/danielutils/metaclasses/instance_cache_meta.py +1 -1
- danielutils-0.9.62/danielutils/MetaClasses/Interface.py → danielutils-0.9.94/danielutils/metaclasses/interface.py +7 -7
- danielutils-0.9.62/danielutils/MetaClasses/OverloadMeta.py → danielutils-0.9.94/danielutils/metaclasses/overload_meta.py +6 -4
- danielutils-0.9.94/danielutils/mock_/__init__.py +2 -0
- danielutils-0.9.94/danielutils/mock_/mock_database.py +72 -0
- danielutils-0.9.94/danielutils/mock_/mock_module.py +18 -0
- danielutils-0.9.94/danielutils/print_.py +118 -0
- danielutils-0.9.94/danielutils/progress_bar/__init__.py +3 -0
- danielutils-0.9.94/danielutils/progress_bar/ascii_progress_bar.py +152 -0
- danielutils-0.9.94/danielutils/progress_bar/progress_bar.py +69 -0
- danielutils-0.9.94/danielutils/progress_bar/progress_bar_pool.py +64 -0
- danielutils-0.9.94/danielutils/protocols/__init__.py +3 -0
- danielutils-0.9.94/danielutils/protocols/dictable.py +20 -0
- danielutils-0.9.94/danielutils/protocols/evaluable.py +15 -0
- danielutils-0.9.94/danielutils/protocols/serializable.py +27 -0
- danielutils-0.9.94/danielutils/random_.py +35 -0
- {danielutils-0.9.62/danielutils/Reflection → danielutils-0.9.94/danielutils/reflection}/__init__.py +6 -7
- danielutils-0.9.94/danielutils/reflection/class_/__init__.py +1 -0
- danielutils-0.9.94/danielutils/reflection/class_/class_reflection.py +226 -0
- danielutils-0.9.94/danielutils/reflection/file/__init__.py +1 -0
- danielutils-0.9.94/danielutils/reflection/file/file_reflection.py +58 -0
- danielutils-0.9.94/danielutils/reflection/function/__init__.py +1 -0
- danielutils-0.9.62/danielutils/Reflection/Function.py → danielutils-0.9.94/danielutils/reflection/function/function_reflections.py +56 -66
- danielutils-0.9.94/danielutils/reflection/interpreter/__init__.py +9 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/callstack.py +42 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/get_traceback.py +27 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/interpreter.py +41 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/is_debugging.py +13 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/os_.py +33 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/packages.py +33 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/python_version.py +26 -0
- danielutils-0.9.94/danielutils/reflection/interpreter/tracer.py +175 -0
- danielutils-0.9.94/danielutils/reflection/module/__init__.py +2 -0
- danielutils-0.9.94/danielutils/reflection/module/package_reflection.py +157 -0
- danielutils-0.9.94/danielutils/retry_executor/__init__.py +3 -0
- danielutils-0.9.94/danielutils/retry_executor/backoff_strategies/__init__.py +3 -0
- danielutils-0.9.94/danielutils/retry_executor/backoff_strategies/constant_backoff.py +19 -0
- danielutils-0.9.94/danielutils/retry_executor/backoff_strategies/exponential_backoff.py +21 -0
- danielutils-0.9.94/danielutils/retry_executor/backoff_strategies/no_backoff.py +12 -0
- danielutils-0.9.94/danielutils/retry_executor/backoff_strategy.py +22 -0
- danielutils-0.9.94/danielutils/retry_executor/retry_executor.py +37 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/__init__.py +1 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/independent.py +19 -18
- danielutils-0.9.94/danielutils/system/layered_command.py +118 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/windows/utils/filetime.py +2 -1
- danielutils-0.9.94/danielutils/testing/__init__.py +1 -0
- danielutils-0.9.94/danielutils/testing/unittest_/__init__.py +2 -0
- danielutils-0.9.94/danielutils/testing/unittest_/always_teardown_testcase.py +37 -0
- danielutils-0.9.94/danielutils/testing/unittest_/auto_cwd_testcase.py +49 -0
- danielutils-0.9.62/danielutils/Text.py → danielutils-0.9.94/danielutils/text.py +8 -8
- danielutils-0.9.62/danielutils/Time.py → danielutils-0.9.94/danielutils/time.py +1 -5
- danielutils-0.9.94/danielutils/university/__init__.py +7 -0
- danielutils-0.9.94/danielutils/university/computability_and_complexity/__init__.py +2 -0
- danielutils-0.9.94/danielutils/university/computability_and_complexity/discreate_finite_automaton.py +89 -0
- danielutils-0.9.94/danielutils/university/computability_and_complexity/languages/language.py +17 -0
- danielutils-0.9.94/danielutils/university/computability_and_complexity/languages/sat.py +71 -0
- danielutils-0.9.94/danielutils/university/computability_and_complexity/turing_machine.py +47 -0
- {danielutils-0.9.62/danielutils/University/Databases → danielutils-0.9.94/danielutils/university/databases}/all.py +22 -22
- danielutils-0.9.94/danielutils/university/image_proccesing/__init__.py +1 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/__init__.py +3 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/encoding.py +35 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossless/__init__.py +4 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossless/huffman.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossless/lossless_encoding.py +10 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossless/lzw.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossless/run_length.py +23 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossy/__init__.py +1 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/encoding/lossy/lossy_encoding.py +10 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/__init__.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/gaussian.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/gradient.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/hough.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/laplacian.py +0 -0
- danielutils-0.9.94/danielutils/university/image_proccesing/tansformations/transformation.py +11 -0
- danielutils-0.9.94/danielutils/university/linear_algebra/__init__.py +1 -0
- danielutils-0.9.94/danielutils/university/linear_algebra/matrix.py +398 -0
- danielutils-0.9.94/danielutils/university/machine_learning/__init__.py +0 -0
- danielutils-0.9.94/danielutils/university/machine_learning/activation_functions/__init__.py +2 -0
- danielutils-0.9.94/danielutils/university/machine_learning/activation_functions/activation_function.py +11 -0
- danielutils-0.9.94/danielutils/university/machine_learning/activation_functions/relu.py +11 -0
- danielutils-0.9.94/danielutils/university/machine_learning/neuron.py +15 -0
- danielutils-0.9.94/danielutils/university/oop/__init__.py +1 -0
- danielutils-0.9.94/danielutils/university/oop/observer.py +31 -0
- danielutils-0.9.94/danielutils/university/oop/strategy.py +9 -0
- danielutils-0.9.94/danielutils/university/probability/__init__.py +7 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/__init__.py +3 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/conditional_variable.py +110 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/__init__.py +7 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +38 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/binomial.py +40 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +36 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/discrete.py +42 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/geometric.py +43 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/poisson.py +32 -0
- danielutils-0.9.94/danielutils/university/probability/conditional_variable/discrete/uniform.py +33 -0
- danielutils-0.9.94/danielutils/university/probability/distributions.py +35 -0
- danielutils-0.9.94/danielutils/university/probability/expressions/__init__.py +2 -0
- danielutils-0.9.94/danielutils/university/probability/expressions/accumulation_expression.py +185 -0
- danielutils-0.9.94/danielutils/university/probability/expressions/probability_expression.py +110 -0
- danielutils-0.9.94/danielutils/university/probability/funcs/__init__.py +4 -0
- danielutils-0.9.94/danielutils/university/probability/funcs/covariance.py +12 -0
- danielutils-0.9.94/danielutils/university/probability/funcs/expected_value.py +41 -0
- danielutils-0.9.94/danielutils/university/probability/funcs/probability_function.py +14 -0
- danielutils-0.9.94/danielutils/university/probability/funcs/variance.py +17 -0
- danielutils-0.9.94/danielutils/university/probability/operator.py +79 -0
- danielutils-0.9.94/danielutils/university/probability/protocols.py +32 -0
- danielutils-0.9.94/danielutils/university/probability/supp.py +101 -0
- danielutils-0.9.94/danielutils/university/probability/transformation.py +44 -0
- danielutils-0.9.94/danielutils/versioned_imports.py +12 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils.egg-info/PKG-INFO +7 -7
- danielutils-0.9.94/danielutils.egg-info/SOURCES.txt +243 -0
- danielutils-0.9.94/pyproject.toml +31 -0
- danielutils-0.9.94/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-0.9.94/LICENSE +0 -0
- /danielutils-0.9.62/danielutils/Classes/Counter.py → /danielutils-0.9.94/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/better_builtins}/typed_builtins/ttuple.py +0 -0
- /danielutils-0.9.62/danielutils/Classes/Convenience.py → /danielutils-0.9.94/danielutils/convenience.py +0 -0
- {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.94/danielutils/conversions}/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Conversions → danielutils-0.9.94/danielutils/conversions}/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/date_time.py +0 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/chain_decorators.py +0 -0
- {danielutils-0.9.62/danielutils/Decorators → danielutils-0.9.94/danielutils/decorators}/property.py +0 -0
- /danielutils-0.9.62/danielutils/Exceptions.py → /danielutils-0.9.94/danielutils/exceptions.py +0 -0
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/check_foreach.py +0 -0
- {danielutils-0.9.62/danielutils/Functions → danielutils-0.9.94/danielutils/functions}/powerset.py +0 -0
- /danielutils-0.9.62/danielutils/Relations.py → /danielutils-0.9.94/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.94/danielutils/generators}/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Generators → danielutils-0.9.94/danielutils/generators}/conditional_generator.py +0 -0
- /danielutils-0.9.62/danielutils/Math/Constants.py → /danielutils-0.9.94/danielutils/math_/constants.py +0 -0
- /danielutils-0.9.62/danielutils/MetaClasses/ImplicitDataDeleterMeta.py → /danielutils-0.9.94/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- /danielutils-0.9.62/danielutils/Path.py → /danielutils-0.9.94/danielutils/path.py +0 -0
- /danielutils-0.9.62/danielutils/Classes/Tree.py → /danielutils-0.9.94/danielutils/py.typed +0 -0
- /danielutils-0.9.62/danielutils/Signals.py → /danielutils-0.9.94/danielutils/reflection/interpreter/signals.py +0 -0
- /danielutils-0.9.62/danielutils/Reflection/Module.py → /danielutils-0.9.94/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.62/danielutils/Snippets → danielutils-0.9.94/danielutils/snippets}/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/Snippets → danielutils-0.9.94/danielutils/snippets}/try_get.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.62/danielutils/Classes/sorted_builtins → danielutils-0.9.94/danielutils/university/computability_and_complexity/languages}/__init__.py +0 -0
- {danielutils-0.9.62/danielutils/University/Databases → danielutils-0.9.94/danielutils/university/databases}/__init__.py +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.62 → danielutils-0.9.94}/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.9.
|
|
3
|
+
Version: 0.9.94
|
|
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.9.
|
|
43
|
+
# danielutils v=0.9.92
|
|
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.9.
|
|
7
|
+
# danielutils v=0.9.92
|
|
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
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""danielutils is a convenience library of functions decorators
|
|
2
|
+
data-structures and more that make my development workflow faster
|
|
3
|
+
"""
|
|
4
|
+
# =================================================================
|
|
5
|
+
# ============================= LEAFS =============================
|
|
6
|
+
# =================================================================
|
|
7
|
+
from .path import *
|
|
8
|
+
from .date_time import *
|
|
9
|
+
from .aliases import *
|
|
10
|
+
from .exceptions import PrintCatchOne
|
|
11
|
+
from .snippets import *
|
|
12
|
+
from .abstractions import *
|
|
13
|
+
from .protocols import *
|
|
14
|
+
# =================================================================
|
|
15
|
+
# ========================= ORDER MATTERS =========================
|
|
16
|
+
# =================================================================
|
|
17
|
+
|
|
18
|
+
from .reflection import *
|
|
19
|
+
from .decorators import *
|
|
20
|
+
# ========== NEEDS REFLECTION ==========
|
|
21
|
+
# ========== NEEDS DECORATORS ==========
|
|
22
|
+
from .colors import *
|
|
23
|
+
# ========== NEEDS BOTH ==========
|
|
24
|
+
|
|
25
|
+
from .progress_bar import *
|
|
26
|
+
from .functions import *
|
|
27
|
+
from .io_ import *
|
|
28
|
+
from .system import *
|
|
29
|
+
from .text import *
|
|
30
|
+
from .conversions import *
|
|
31
|
+
from .better_builtins import *
|
|
32
|
+
from .time import *
|
|
33
|
+
from .date import *
|
|
34
|
+
from .data_structures import *
|
|
35
|
+
from .math_ import *
|
|
36
|
+
from .system import *
|
|
37
|
+
from .print_ import *
|
|
38
|
+
from .metaclasses import *
|
|
39
|
+
from .generators import *
|
|
40
|
+
from .university import *
|
|
41
|
+
from .mock_ import *
|
|
42
|
+
from .context_managers import *
|
|
43
|
+
from .file_specifications import *
|
|
44
|
+
from .testing import *
|
|
45
|
+
from .retry_executor import *
|
|
46
|
+
from .java import *
|
|
47
|
+
from .random_ import *
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from typing import Any, TypeVar, Optional
|
|
2
|
+
|
|
3
|
+
from .database import Database
|
|
4
|
+
|
|
5
|
+
K = TypeVar('K')
|
|
6
|
+
V = TypeVar('V')
|
|
7
|
+
|
|
8
|
+
class CachedDatabase(Database[K, V]):
|
|
9
|
+
"""
|
|
10
|
+
A database that is composed of two types of databases.
|
|
11
|
+
Args:
|
|
12
|
+
primary (Database): is intended to be the "real" database which is usually slower than the `cache`
|
|
13
|
+
cache (Database): is intended to be a cache layer over `primary` which will be faster when reading
|
|
14
|
+
*
|
|
15
|
+
notify_primary (bool): if a single Database instance is as `primary` for multiple CachedDatabase and the
|
|
16
|
+
current CachedDatabase instance 'set' method is used, it will also update the cache on different
|
|
17
|
+
CachedDatabase instances. Defaults to False
|
|
18
|
+
notify_cache (bool): same as `notify_primary` but will update other primaries on different
|
|
19
|
+
CachedDatabase instances
|
|
20
|
+
Returns:
|
|
21
|
+
None
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def _on_notify(self, updater: 'Database', obj: Any) -> None:
|
|
25
|
+
key, value = obj
|
|
26
|
+
if self._cache is not updater:
|
|
27
|
+
if not self._cache == updater:
|
|
28
|
+
self._cache.set(key, value)
|
|
29
|
+
|
|
30
|
+
if self._primary is not updater:
|
|
31
|
+
if not self._primary == updater:
|
|
32
|
+
self._primary.set(key, value)
|
|
33
|
+
|
|
34
|
+
def __init__(self, primary: Database, cache: Database, *, notify_primary: bool = False, notify_cache: bool = False):
|
|
35
|
+
super().__init__()
|
|
36
|
+
primary._register_subscriber(self)
|
|
37
|
+
cache._register_subscriber(self)
|
|
38
|
+
self._primary = primary
|
|
39
|
+
self._cache = cache
|
|
40
|
+
self._notify_primary = notify_primary
|
|
41
|
+
self._notify_cache = notify_cache
|
|
42
|
+
|
|
43
|
+
def get(self, key: K, default: Any = Database.DEFAULT) -> Optional[V]:
|
|
44
|
+
res = self._cache.get(key, default)
|
|
45
|
+
if res is not default:
|
|
46
|
+
return res
|
|
47
|
+
res = self._primary.get(key, default)
|
|
48
|
+
if res is not default:
|
|
49
|
+
self._cache.set(key, res)
|
|
50
|
+
return res
|
|
51
|
+
|
|
52
|
+
def set(self, key: K, value: V) -> None:
|
|
53
|
+
self._cache.set(key, value)
|
|
54
|
+
if self._notify_cache:
|
|
55
|
+
self._cache._notify_subscribers((key, value)) # pylint: disable=protected-access
|
|
56
|
+
self._primary.set(key, value)
|
|
57
|
+
if self._notify_primary:
|
|
58
|
+
self._primary._notify_subscribers((key, value)) # pylint: disable=protected-access
|
|
59
|
+
|
|
60
|
+
def delete(self, key: K) -> None:
|
|
61
|
+
self._cache.delete(key)
|
|
62
|
+
self._primary.delete(key)
|
|
63
|
+
|
|
64
|
+
def contains(self, key: K) -> bool:
|
|
65
|
+
if self._cache.contains(key):
|
|
66
|
+
return True
|
|
67
|
+
if (res := self.get(key)) is not Database.DEFAULT:
|
|
68
|
+
self._cache.set(key, res)
|
|
69
|
+
return True
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
__all__ = [
|
|
74
|
+
"CachedDatabase"
|
|
75
|
+
]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Any, TypeVar, Generic, Optional, Set
|
|
3
|
+
|
|
4
|
+
K = TypeVar('K')
|
|
5
|
+
V = TypeVar('V')
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Database(ABC, Generic[K, V]):
|
|
9
|
+
"""
|
|
10
|
+
Abstract base class for database objects.
|
|
11
|
+
"""
|
|
12
|
+
DEFAULT = None
|
|
13
|
+
|
|
14
|
+
def __init__(self) -> None:
|
|
15
|
+
self._subscribers: Set[Database] = set()
|
|
16
|
+
|
|
17
|
+
def _register_subscriber(self, subscriber: 'Database') -> None:
|
|
18
|
+
self._subscribers.add(subscriber)
|
|
19
|
+
|
|
20
|
+
def _notify_subscribers(self, obj: Any) -> None:
|
|
21
|
+
for subscriber in self._subscribers:
|
|
22
|
+
subscriber._notify(self, obj) # pylint: disable=protected-access
|
|
23
|
+
|
|
24
|
+
def _notify(self, updater: 'Database', obj: Any) -> None:
|
|
25
|
+
"""
|
|
26
|
+
Notify all subscribers of an object.
|
|
27
|
+
Args:
|
|
28
|
+
updater: the object calling this method.
|
|
29
|
+
obj: the event to notify.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
None
|
|
33
|
+
"""
|
|
34
|
+
self._on_notify(updater, obj)
|
|
35
|
+
|
|
36
|
+
@abstractmethod
|
|
37
|
+
def _on_notify(self, updater: 'Database', obj: Any) -> None:
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
@abstractmethod
|
|
41
|
+
def get(self, key: K, default: Any = DEFAULT) -> Optional[V]:
|
|
42
|
+
"""
|
|
43
|
+
Get a value from the database by key.
|
|
44
|
+
Args:
|
|
45
|
+
key (K): The key to get the value from.:
|
|
46
|
+
default (Any): The default value to return if the key is not found. Defaults to Database.DEFAULT.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
Optional[V]
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
@abstractmethod
|
|
53
|
+
def set(self, key: K, value: V) -> None:
|
|
54
|
+
"""
|
|
55
|
+
Set a value in the database.
|
|
56
|
+
Args:
|
|
57
|
+
key (K): The key to set.
|
|
58
|
+
value (V): The value to set.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
None
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def delete(self, key: K) -> None:
|
|
66
|
+
"""
|
|
67
|
+
Delete an item from the database.
|
|
68
|
+
Args:
|
|
69
|
+
key (K): The key to delete.:
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
None
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
@abstractmethod
|
|
76
|
+
def contains(self, key: K) -> bool:
|
|
77
|
+
"""
|
|
78
|
+
Check if a key is contained in this database.
|
|
79
|
+
Args:
|
|
80
|
+
key (K): Key to be checked.:
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
bool
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
def __getitem__(self, key: K) -> V:
|
|
87
|
+
res = self.get(key)
|
|
88
|
+
if res is Database.DEFAULT:
|
|
89
|
+
raise KeyError(key)
|
|
90
|
+
return res
|
|
91
|
+
|
|
92
|
+
def __setitem__(self, key: K, value: V) -> None:
|
|
93
|
+
self.set(key, value)
|
|
94
|
+
|
|
95
|
+
def __delitem__(self, key: K) -> None:
|
|
96
|
+
self.delete(key)
|
|
97
|
+
|
|
98
|
+
def __contains__(self, key: K) -> bool:
|
|
99
|
+
return self.contains(key)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
__all__ = [
|
|
103
|
+
"Database",
|
|
104
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Any, Optional, TypeVar
|
|
2
|
+
|
|
3
|
+
from danielutils import serialize, deserialize
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
import redis
|
|
7
|
+
except ImportError:
|
|
8
|
+
from ...mock_ import MockImportObject
|
|
9
|
+
|
|
10
|
+
redis = MockImportObject("`redis` is not installed") # type:ignore
|
|
11
|
+
from .database import Database
|
|
12
|
+
|
|
13
|
+
K = TypeVar('K')
|
|
14
|
+
V = TypeVar('V')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RedisDatabase(Database[K, V]):
|
|
18
|
+
"""
|
|
19
|
+
An implementation of the `Database` interface using Redis.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
super().__init__()
|
|
24
|
+
self._db = redis.StrictRedis(host='localhost', port=6379, db=0)
|
|
25
|
+
|
|
26
|
+
def _on_notify(self, updater: 'Database', obj: Any) -> None:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
def get(self, key: K, default: Any = Database.DEFAULT) -> Optional[V]:
|
|
30
|
+
if key not in self:
|
|
31
|
+
return default
|
|
32
|
+
return deserialize(self._db.get(serialize(key))) # type: ignore
|
|
33
|
+
|
|
34
|
+
def set(self, key: K, value: V) -> None:
|
|
35
|
+
self._db.set(serialize(key), serialize(value))
|
|
36
|
+
|
|
37
|
+
def delete(self, key: K) -> None:
|
|
38
|
+
self._db.delete(serialize(key))
|
|
39
|
+
|
|
40
|
+
def contains(self, key: K) -> bool:
|
|
41
|
+
return bool(self._db.exists(serialize(key)))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"RedisDatabase"
|
|
46
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import threading
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def process_id() -> int:
|
|
6
|
+
"""
|
|
7
|
+
will return the current process' id
|
|
8
|
+
Returns:
|
|
9
|
+
int
|
|
10
|
+
"""
|
|
11
|
+
return os.getpid()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def thread_id() -> int:
|
|
15
|
+
"""
|
|
16
|
+
will return the current thread's id
|
|
17
|
+
Returns:
|
|
18
|
+
int
|
|
19
|
+
"""
|
|
20
|
+
return threading.get_ident()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"process_id",
|
|
25
|
+
"thread_id"
|
|
26
|
+
]
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
from threading import Thread
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
|
-
from typing import Optional, Any
|
|
3
|
+
from typing import Optional, Any, Tuple as Tuple
|
|
4
4
|
from logging import error
|
|
5
|
-
import danielutils
|
|
6
|
-
from
|
|
5
|
+
import danielutils # this is explicitly this way to prevent circular import
|
|
6
|
+
from ...reflection import get_python_version
|
|
7
|
+
|
|
7
8
|
if get_python_version() >= (3, 9):
|
|
8
|
-
from builtins import tuple as
|
|
9
|
-
else:
|
|
10
|
-
from typing import Tuple as t_tuple
|
|
9
|
+
from builtins import tuple as Tuple # type:ignore
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
class Worker(ABC):
|
|
14
13
|
"""A Worker Interface
|
|
15
14
|
"""
|
|
16
15
|
|
|
17
|
-
def __init__(self, id: int,
|
|
16
|
+
def __init__(self, id: int,
|
|
17
|
+
pool: "danielutils.abstractions.multiprogramming.worker_pool.WorkerPool") -> None: # pylint: disable=redefined-builtin #noqa
|
|
18
18
|
self.id = id
|
|
19
19
|
self.pool = pool
|
|
20
20
|
self.thread: Thread = Thread(target=self._loop)
|
|
@@ -59,9 +59,10 @@ class Worker(ABC):
|
|
|
59
59
|
to signal actions if needed
|
|
60
60
|
will call 'notification_function'
|
|
61
61
|
"""
|
|
62
|
-
|
|
62
|
+
# TODO
|
|
63
|
+
self.pool._notify_subscribers() # type:ignore # pylint: disable=protected-access
|
|
63
64
|
|
|
64
|
-
def acquire(self) -> Optional[
|
|
65
|
+
def acquire(self) -> Optional[Tuple[Any]]:
|
|
65
66
|
"""acquire a new job object to work on from the pool
|
|
66
67
|
will return a tuple of only one object (the job) or None if there are no more jobs
|
|
67
68
|
Returns:
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
from queue import Queue
|
|
2
|
-
from typing import Optional, Any
|
|
2
|
+
from typing import Optional, Any, Type as t_type, Tuple as Tuple, List as List
|
|
3
3
|
from threading import Semaphore
|
|
4
4
|
from .worker import Worker
|
|
5
|
-
from
|
|
5
|
+
from ...reflection import get_python_version
|
|
6
|
+
|
|
6
7
|
if get_python_version() >= (3, 9):
|
|
7
|
-
from builtins import type as t_type, tuple as
|
|
8
|
-
else:
|
|
9
|
-
from typing import Type as t_type, Tuple as t_tuple, List as t_list
|
|
8
|
+
from builtins import type as t_type, tuple as Tuple, list as List # type:ignore
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
class WorkerPool:
|
|
@@ -16,9 +15,9 @@ class WorkerPool:
|
|
|
16
15
|
def __init__(self, num_workers: int, worker_class: t_type[Worker], w_kwargs: dict, global_variables: dict) -> None:
|
|
17
16
|
self.num_workers = num_workers
|
|
18
17
|
self.global_variables: dict = global_variables
|
|
19
|
-
self.q: Queue[
|
|
18
|
+
self.q: Queue[Tuple[Any]] = Queue()
|
|
20
19
|
self.worker_class = worker_class
|
|
21
|
-
self.workers:
|
|
20
|
+
self.workers: List[Worker] = []
|
|
22
21
|
self.sem = Semaphore(0)
|
|
23
22
|
self.w_kwargs = w_kwargs
|
|
24
23
|
|
|
@@ -35,7 +34,7 @@ class WorkerPool:
|
|
|
35
34
|
self.q.put((job,))
|
|
36
35
|
self.sem.release()
|
|
37
36
|
|
|
38
|
-
def _acquire(self) -> Optional[
|
|
37
|
+
def _acquire(self) -> Optional[Tuple[Any]]:
|
|
39
38
|
"""acquire a new job from the pool
|
|
40
39
|
|
|
41
40
|
Returns:
|
|
@@ -63,6 +62,11 @@ class WorkerPool:
|
|
|
63
62
|
self.sem.release(self.num_workers)
|
|
64
63
|
|
|
65
64
|
def join(self) -> None:
|
|
65
|
+
"""
|
|
66
|
+
waits for all the workers to finish and will return afterwards
|
|
67
|
+
Returns:
|
|
68
|
+
None
|
|
69
|
+
"""
|
|
66
70
|
for w in self.workers:
|
|
67
71
|
w.thread.join()
|
|
68
72
|
|
{danielutils-0.9.62/danielutils/Classes → danielutils-0.9.94/danielutils/abstractions}/repl.py
RENAMED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
from ..reflection import get_python_version
|
|
1
|
+
import copy, re
|
|
2
|
+
from typing import Any, Callable, Union, Tuple as Tuple, List as List, Dict as Dict
|
|
3
|
+
from ..reflection import get_python_version # pylint :disable=relative-beyond-top-level
|
|
4
|
+
|
|
4
5
|
if get_python_version() >= (3, 9):
|
|
5
|
-
from builtins import tuple as
|
|
6
|
+
from builtins import tuple as Tuple, list as List, dict as Dict # type:ignore
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class Argument:
|
|
@@ -19,7 +20,7 @@ class Command:
|
|
|
19
20
|
"""
|
|
20
21
|
|
|
21
22
|
def __init__(self, command: Union[Argument, str], callback: Callable,
|
|
22
|
-
explanation: str = "", *, options:
|
|
23
|
+
explanation: str = "", *, options: Tuple[Argument, ...] = tuple()) -> None:
|
|
23
24
|
self.command = command if isinstance(
|
|
24
25
|
command, Argument) else Argument(command)
|
|
25
26
|
self.callback = callback
|
|
@@ -39,10 +40,11 @@ class REPL:
|
|
|
39
40
|
"""a class to easily create a shell application and get functionality for free
|
|
40
41
|
"""
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
# pylint: disable=dangerous-default-value
|
|
44
|
+
def __init__(self, routes: List[Command], *, prompt_symbol: str = ">>> ", exit_keywords: set = {"exit", "quit"}):
|
|
43
45
|
self.prompt_symbol = prompt_symbol
|
|
44
|
-
self.exit_keywords = exit_keywords
|
|
45
|
-
self.routes:
|
|
46
|
+
self.exit_keywords = copy.copy(exit_keywords)
|
|
47
|
+
self.routes: Dict[str, Command] = {
|
|
46
48
|
com.command.name: com for com in routes}
|
|
47
49
|
|
|
48
50
|
def run(self) -> None:
|
|
@@ -58,7 +60,7 @@ class REPL:
|
|
|
58
60
|
|
|
59
61
|
if prompt == "help":
|
|
60
62
|
print("Available commands:")
|
|
61
|
-
for com in list(self.routes.keys())+list(self.exit_keywords):
|
|
63
|
+
for com in list(self.routes.keys()) + list(self.exit_keywords):
|
|
62
64
|
print(f"\t{com}")
|
|
63
65
|
continue
|
|
64
66
|
|
|
@@ -70,9 +72,9 @@ class REPL:
|
|
|
70
72
|
except TypeError as e:
|
|
71
73
|
msg = str(e)
|
|
72
74
|
if re.match(r".*missing.*required.*argument.*", msg):
|
|
73
|
-
print(f"'{command}' "+msg[msg.find("missing"):])
|
|
75
|
+
print(f"'{command}' " + msg[msg.find("missing"):])
|
|
74
76
|
elif re.match(r".*takes.*arguments but.*given", msg):
|
|
75
|
-
print(f"'{command}' "+msg[msg.find("takes"):])
|
|
77
|
+
print(f"'{command}' " + msg[msg.find("takes"):])
|
|
76
78
|
else:
|
|
77
79
|
raise e
|
|
78
80
|
|
|
@@ -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",
|