danielutils 0.9.82__tar.gz → 0.9.84__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.82/danielutils.egg-info → danielutils-0.9.84}/PKG-INFO +2 -2
- {danielutils-0.9.82 → danielutils-0.9.84}/README.md +1 -1
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/__init__.py +2 -2
- danielutils-0.9.84/danielutils/context_managers/__init__.py +3 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/context_managers/attr_context.py +2 -1
- danielutils-0.9.84/danielutils/context_managers/multi_context.py +23 -0
- danielutils-0.9.84/danielutils/context_managers/state_context.py +16 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/context_managers/temporary_file.py +2 -1
- danielutils-0.9.84/danielutils/custom_types.py +17 -0
- danielutils-0.9.84/danielutils/file_specifications/__init__.py +70 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/__init__.py +2 -0
- danielutils-0.9.84/danielutils/functions/foreach.py +14 -0
- danielutils-0.9.84/danielutils/functions/parallel_for.py +37 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/math_/__init__.py +0 -1
- danielutils-0.9.84/danielutils/print_.py +118 -0
- danielutils-0.9.84/danielutils/progress_bar/__init__.py +3 -0
- danielutils-0.9.84/danielutils/progress_bar/ascii_progress_bar.py +141 -0
- danielutils-0.9.84/danielutils/progress_bar/progress_bar.py +64 -0
- danielutils-0.9.84/danielutils/progress_bar/progress_bar_pool.py +64 -0
- danielutils-0.9.84/danielutils/protocols/__init__.py +3 -0
- danielutils-0.9.84/danielutils/protocols/serializable.py +28 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/layered_command.py +14 -6
- danielutils-0.9.84/danielutils/university/__init__.py +7 -0
- danielutils-0.9.84/danielutils/university/computability_and_complexity/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/computability_and_complexity/discreate_finite_automaton.py +68 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/__init__.py +3 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/encoding.py +35 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/__init__.py +4 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/lossless_encoding.py +10 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/lzw.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/run_length.py +22 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossy/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossy/lossy_encoding.py +10 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/__init__.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/gaussian.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/gradient.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/hough.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/laplacian.py +0 -0
- danielutils-0.9.84/danielutils/university/image_proccesing/tansformations/transformation.py +10 -0
- danielutils-0.9.84/danielutils/university/linear_algebra/__init__.py +1 -0
- danielutils-0.9.84/danielutils/university/linear_algebra/matrix.py +398 -0
- danielutils-0.9.84/danielutils/university/machine_learning/__init__.py +0 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/__init__.py +2 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/activation_function.py +11 -0
- danielutils-0.9.84/danielutils/university/machine_learning/activation_functions/relu.py +11 -0
- danielutils-0.9.84/danielutils/university/machine_learning/neuron.py +15 -0
- danielutils-0.9.84/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84/danielutils.egg-info}/PKG-INFO +2 -2
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils.egg-info/SOURCES.txt +36 -3
- {danielutils-0.9.82 → danielutils-0.9.84}/pyproject.toml +1 -1
- danielutils-0.9.82/danielutils/context_managers/__init__.py +0 -2
- danielutils-0.9.82/danielutils/math_/polynomial/__init__.py +0 -1
- danielutils-0.9.82/danielutils/math_/polynomial/polinomial.py +0 -33
- danielutils-0.9.82/danielutils/print_.py +0 -79
- danielutils-0.9.82/danielutils/protocols/__init__.py +0 -2
- danielutils-0.9.82/danielutils/tqdm_.py +0 -51
- danielutils-0.9.82/danielutils/university/__init__.py +0 -3
- {danielutils-0.9.82 → danielutils-0.9.84}/LICENSE +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/MANIFEST.in +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/database/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/database/cached_database.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/database/database.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/database/redis_database.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/multi_id.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/worker.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/multiprogramming/worker_pool.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/abstractions/repl.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/aliases.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/frange.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/factory.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/tset.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/better_builtins/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/colors.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/convenience.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/graph/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/graph/binary_node.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/graph/graph.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/graph/multinode.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/graph/node.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/heap/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/heap/heap.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/heap/max_heap.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/heap/min_heap.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/queue/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/queue/atomic_queue.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/queue/priority_queue.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/queue/queue.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/stack.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/trees/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/trees/binary_syntax_tree.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/data_structures/trees/binary_tree.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/date.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/date_time.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/decorate_conditionally.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/final.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/memo.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/overload.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/processify.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/singleton.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/timeout.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/total_ordering.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/flatten.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/isoftype.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/multiloop.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/generators/join_generators.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/internet.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/io_.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/math_/functions.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/math_/math_print.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/math_/math_symbols.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/interface.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/mock_/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/mock_/mock_database.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/mock_/mock_module.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/path.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/protocols/dictable.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/protocols/evaluable.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/py.typed +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/class_/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/class_/class_reflection.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/file/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/file/file_reflection.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/function/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/function/function_reflections.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/callstack.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/get_traceback.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/os_.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/packages.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/python_version.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/signals.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/interpreter/tracer.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/module/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/reflection/module/package_reflection.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/text.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/time.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/databases/all.py +0 -0
- /danielutils-0.9.82/danielutils/university/probability/conditional_variable/continuous/__init__.py → /danielutils-0.9.84/danielutils/university/image_proccesing/encoding/lossless/huffman.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/oop/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/oop/observer.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/oop/strategy.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/conditional_variable.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/binomial.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/discrete.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/geometric.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/poisson.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/conditional_variable/discrete/uniform.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/distributions.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/expressions/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/expressions/accumulation_expression.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/expressions/probability_expression.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/funcs/__init__.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/funcs/covariance.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/funcs/expected_value.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/funcs/probability_function.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/funcs/variance.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/operator.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/protocols.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/supp.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/university/probability/transformation.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils/versioned_imports.py +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/setup.cfg +0 -0
- {danielutils-0.9.82 → danielutils-0.9.84}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: danielutils
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.84
|
|
4
4
|
Summary: A python utils library for things I find useful
|
|
5
5
|
Author-email: danielnachumdev <danielnachumdev@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -41,7 +41,7 @@ License-File: LICENSE
|
|
|
41
41
|
[](https://www.python.org/downloads/release/python-31011/)
|
|
42
42
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/gitleaks.yml)
|
|
43
43
|
[](https://github.com/danielnachumdev/danielutils/actions/workflows/github-code-scanning/codeql)
|
|
44
|
-
# danielutils v=0.9.
|
|
44
|
+
# danielutils v=0.9.84
|
|
45
45
|
A utils library for things that I find useful for my coding workflow.\
|
|
46
46
|
Feel free to use and / or contribute / improve my code :)
|
|
47
47
|
|
|
@@ -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.84
|
|
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
|
|
|
@@ -17,13 +17,12 @@ from .protocols import *
|
|
|
17
17
|
|
|
18
18
|
from .reflection import *
|
|
19
19
|
from .decorators import *
|
|
20
|
-
|
|
21
20
|
# ========== NEEDS REFLECTION ==========
|
|
22
|
-
from .tqdm_ import *
|
|
23
21
|
# ========== NEEDS DECORATORS ==========
|
|
24
22
|
from .colors import *
|
|
25
23
|
# ========== NEEDS BOTH ==========
|
|
26
24
|
|
|
25
|
+
from .progress_bar import *
|
|
27
26
|
from .functions import *
|
|
28
27
|
from .io_ import *
|
|
29
28
|
from .system import *
|
|
@@ -41,3 +40,4 @@ from .generators import *
|
|
|
41
40
|
from .university import *
|
|
42
41
|
from .mock_ import *
|
|
43
42
|
from .context_managers import *
|
|
43
|
+
from .file_specifications import *
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import ContextManager
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MultiContext(ContextManager):
|
|
5
|
+
def __init__(self, *contexts: ContextManager):
|
|
6
|
+
self.contexts = contexts
|
|
7
|
+
|
|
8
|
+
def __enter__(self):
|
|
9
|
+
for context in self.contexts:
|
|
10
|
+
context.__enter__()
|
|
11
|
+
return self
|
|
12
|
+
|
|
13
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
14
|
+
for context in self.contexts:
|
|
15
|
+
context.__exit__(exc_type, exc_val, exc_tb)
|
|
16
|
+
|
|
17
|
+
def __getitem__(self, index):
|
|
18
|
+
return self.contexts[index]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"MultiContext",
|
|
23
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from contextlib import contextmanager
|
|
2
|
+
from ..custom_types import Procedure
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@contextmanager
|
|
6
|
+
def StateContext(set_state: Procedure, restore_state: Procedure):
|
|
7
|
+
try:
|
|
8
|
+
set_state()
|
|
9
|
+
yield
|
|
10
|
+
finally:
|
|
11
|
+
restore_state()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
'StateContext'
|
|
16
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from typing import TypeAlias, Callable, TypeVar, Generic
|
|
2
|
+
|
|
3
|
+
T = TypeVar('T')
|
|
4
|
+
U = TypeVar('U')
|
|
5
|
+
Procedure: TypeAlias = Callable[[], None]
|
|
6
|
+
Supplier: TypeAlias = Callable[[], T]
|
|
7
|
+
Consumer: TypeAlias = Callable[[T], None]
|
|
8
|
+
Predicate: TypeAlias = Callable[[], bool]
|
|
9
|
+
Mapper: TypeAlias = Callable[[T], U]
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'Procedure',
|
|
13
|
+
'Supplier',
|
|
14
|
+
'Consumer',
|
|
15
|
+
'Predicate',
|
|
16
|
+
'Mapper'
|
|
17
|
+
]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class Field:
|
|
8
|
+
"""
|
|
9
|
+
A Field object for a Section in a file
|
|
10
|
+
|
|
11
|
+
Params:
|
|
12
|
+
name (str): The name of the field
|
|
13
|
+
size (int): The size of the field in bytes
|
|
14
|
+
type (Field.Type): The type of the field
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
class Type(Enum):
|
|
18
|
+
INTEGER = "INTEGER"
|
|
19
|
+
FLOAT = "FLOAT"
|
|
20
|
+
STRING = "STRING"
|
|
21
|
+
BOOL = "BOOL"
|
|
22
|
+
|
|
23
|
+
name: str
|
|
24
|
+
size: int
|
|
25
|
+
type: Type = Type.INTEGER
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class Section:
|
|
30
|
+
name: str
|
|
31
|
+
prefix: bytes
|
|
32
|
+
fields: Optional[list[Field]]
|
|
33
|
+
is_optional: bool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FileSpecification:
|
|
37
|
+
def __init__(self, long_name: str, short_name: str, extension: str, specification: str, sections: list[Section]):
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
long_name:
|
|
42
|
+
short_name:
|
|
43
|
+
extension:
|
|
44
|
+
specification:
|
|
45
|
+
sections:
|
|
46
|
+
"""
|
|
47
|
+
self.long_name = long_name
|
|
48
|
+
self.short_name = short_name
|
|
49
|
+
self.extension = extension
|
|
50
|
+
self.specification = specification
|
|
51
|
+
self.sections = sections
|
|
52
|
+
|
|
53
|
+
def open(self, path: str):
|
|
54
|
+
if not path.endswith(self.extension):
|
|
55
|
+
raise ValueError(f"Invalid file extension, expected {self.extension}")
|
|
56
|
+
with open(path, "rb") as f:
|
|
57
|
+
lines = f.readlines()
|
|
58
|
+
for line in lines:
|
|
59
|
+
for b in line:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
return lines
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
"Field",
|
|
67
|
+
"Section",
|
|
68
|
+
"FileSpecification",
|
|
69
|
+
"FileSpecification",
|
|
70
|
+
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
from typing import TypeVar, Callable
|
|
3
|
+
|
|
4
|
+
T = TypeVar("T")
|
|
5
|
+
Consumer = Callable[[T], None]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def parallel_for(func: Consumer[T], *args: T, wait: bool = True) -> None:
|
|
9
|
+
"""
|
|
10
|
+
This function will run 'func' in parallel with the given args individually
|
|
11
|
+
Args:
|
|
12
|
+
func: function to run in parallel
|
|
13
|
+
*args: args to call the function each time
|
|
14
|
+
wait: whether to wait for all the threads to join before returning
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
|
|
18
|
+
"""
|
|
19
|
+
# this is safer... What if some other threads that were running will also end in the meantime?
|
|
20
|
+
threads = [threading.Thread(target=func, args=[arg]) for arg in args]
|
|
21
|
+
for t in threads:
|
|
22
|
+
t.start()
|
|
23
|
+
if wait:
|
|
24
|
+
for t in threads:
|
|
25
|
+
t.join()
|
|
26
|
+
# before = threading.active_count()
|
|
27
|
+
# for arg in args:
|
|
28
|
+
# threadify(func)(arg)
|
|
29
|
+
#
|
|
30
|
+
# if wait:
|
|
31
|
+
# while threading.active_count() > before:
|
|
32
|
+
# pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
'parallel_for'
|
|
37
|
+
]
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from typing import IO
|
|
3
|
+
from .functions.areoneof import areoneof
|
|
4
|
+
from .math_.math_print import mprint_parse_one
|
|
5
|
+
from .decorators import atomic, deprecate
|
|
6
|
+
from .colors import warning
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def mprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
10
|
+
"""Prints a formatted representation of mathematical expressions to the specified stream.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
*args: The mathematical expressions to print.
|
|
14
|
+
sep (str, optional): The separator to use between the expressions. Defaults to " ".
|
|
15
|
+
end (str, optional): The string to append to the end of the printed expressions. Defaults to "\n".
|
|
16
|
+
stream (file object, optional): The stream to write the output to. Defaults to sys.stdout.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
TypeError: If any of the arguments is not a string.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
None
|
|
23
|
+
"""
|
|
24
|
+
if not areoneof(args, [str]):
|
|
25
|
+
raise TypeError("s must be a string")
|
|
26
|
+
stream.write(sep.join([mprint_parse_one(s) for s in args]) + end)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@deprecate("The built-in 'print' function has an argument called 'file', use this instead") # type:ignore
|
|
30
|
+
def sprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
31
|
+
"""Writes a string representation of the given arguments to the specified stream.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
*args: The arguments to print.
|
|
35
|
+
sep (str, optional): The separator to use between the arguments. Defaults to " ".
|
|
36
|
+
end (str, optional): The string to append to the end of the printed arguments. Defaults to "\n".
|
|
37
|
+
stream (file object, optional): The stream to write the output to. Defaults to sys.stdout.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
None
|
|
41
|
+
"""
|
|
42
|
+
stream.write(sep.join(args) + end)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@atomic # type:ignore
|
|
46
|
+
def aprint(*args, sep=" ", end="\n") -> None:
|
|
47
|
+
"""Prints a string representation of the given arguments to the console.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
*args: The arguments to print.
|
|
51
|
+
sep (str, optional): The separator to use between the arguments. Defaults to " ".
|
|
52
|
+
end (str, optional): The string to append to the end of the printed arguments. Defaults to "\n".
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
None
|
|
56
|
+
"""
|
|
57
|
+
print(*args, sep=sep, end=end)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class BetterPrinter:
|
|
61
|
+
def __init__(self, stream: IO = sys.stdout, thread_safe: bool = False):
|
|
62
|
+
self.stream: IO = stream
|
|
63
|
+
if thread_safe:
|
|
64
|
+
self.__call__ = atomic(self.__call__) # type:ignore
|
|
65
|
+
self._current_row: int = 0
|
|
66
|
+
self.rows: list[str] = []
|
|
67
|
+
|
|
68
|
+
def clear(self, flush: bool = True) -> None:
|
|
69
|
+
if not self.stream.isatty():
|
|
70
|
+
warning(f"Cannot clear because {self.stream} is not a terminal stream")
|
|
71
|
+
return
|
|
72
|
+
self.write("\033[2J", flush=flush)
|
|
73
|
+
self.rows.pop()
|
|
74
|
+
|
|
75
|
+
def clear_line(self) -> None:
|
|
76
|
+
self.write("\033[2K", end="")
|
|
77
|
+
self.rows.pop()
|
|
78
|
+
|
|
79
|
+
def move_up(self, num_lines: int = 1) -> None:
|
|
80
|
+
self.write(f"\033[{num_lines}A", end="")
|
|
81
|
+
self.rows.pop()
|
|
82
|
+
self._current_row -= 1
|
|
83
|
+
|
|
84
|
+
def write(self, *args, sep: str = " ", end: str = "\n", flush: bool = True):
|
|
85
|
+
text = sep.join(args) + end
|
|
86
|
+
self._current_row += text.count("\n")
|
|
87
|
+
self.rows.extend([f"{s}\n" for s in text.splitlines() if len(s) > 0])
|
|
88
|
+
self.stream.write(text)
|
|
89
|
+
if flush:
|
|
90
|
+
self.stream.flush()
|
|
91
|
+
|
|
92
|
+
def __call__(self, *args, sep: str = " ", end: str = "\n", flush: bool = True) -> None:
|
|
93
|
+
self.write(*args, sep=sep, end=end, flush=flush)
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def current_row(self) -> int:
|
|
97
|
+
return self._current_row
|
|
98
|
+
|
|
99
|
+
def insert(self, text: str, row: int) -> None:
|
|
100
|
+
for _ in range(len(self.rows)):
|
|
101
|
+
bprint.move_up()
|
|
102
|
+
bprint.clear_line()
|
|
103
|
+
self.rows.insert(row, text)
|
|
104
|
+
num = len(self.rows)
|
|
105
|
+
self.write(*self.rows, end="")
|
|
106
|
+
for _ in range(num):
|
|
107
|
+
self.rows.pop()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
bprint = BetterPrinter()
|
|
111
|
+
|
|
112
|
+
__all__ = [
|
|
113
|
+
"sprint",
|
|
114
|
+
"mprint",
|
|
115
|
+
"aprint",
|
|
116
|
+
"bprint",
|
|
117
|
+
'BetterPrinter'
|
|
118
|
+
]
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from typing import Optional, Iterable, Sized
|
|
3
|
+
|
|
4
|
+
from .progress_bar import ProgressBar
|
|
5
|
+
from .progress_bar_pool import ProgressBarPool
|
|
6
|
+
from ..print_ import bprint
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsciiProgressBar(ProgressBar):
|
|
10
|
+
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
iterable: Iterable,
|
|
14
|
+
position: int,
|
|
15
|
+
*,
|
|
16
|
+
total: Optional[float] = None,
|
|
17
|
+
desc: str = "",
|
|
18
|
+
leave: bool = True,
|
|
19
|
+
num_bars: int = 1,
|
|
20
|
+
ncols: int = 50,
|
|
21
|
+
pool: Optional = None,
|
|
22
|
+
**kwargs
|
|
23
|
+
):
|
|
24
|
+
total_ = 1
|
|
25
|
+
if isinstance(iterable, Sized):
|
|
26
|
+
total_ = len(iterable)
|
|
27
|
+
if total is not None:
|
|
28
|
+
total_ = total
|
|
29
|
+
ProgressBar.__init__(self, total_, position)
|
|
30
|
+
self.iterable: Iterable = iterable
|
|
31
|
+
self.pool: ProgressBarPool = pool
|
|
32
|
+
self.num_bars: int = num_bars
|
|
33
|
+
self.leave: bool = leave
|
|
34
|
+
self.desc: str = desc
|
|
35
|
+
self.initial_value: float = 0
|
|
36
|
+
self.current_value: float = 0
|
|
37
|
+
self.ncols: int = ncols
|
|
38
|
+
self.unit: str = "it"
|
|
39
|
+
self.pbar_format = "{l_bar} |{bar}| {n_fmt:.2f}/{total_fmt:.2f}{unit}" \
|
|
40
|
+
" [{elapsed:.2f}<{remaining}, {rate_fmt:.2f}{unit}{postfix}]"
|
|
41
|
+
self.__dict__.update(kwargs)
|
|
42
|
+
self.initial_start_time = time.time()
|
|
43
|
+
self.prev_update: float = self.initial_start_time
|
|
44
|
+
self.delta: float = 0
|
|
45
|
+
self.prev_value: float = self.initial_value
|
|
46
|
+
self.bprint_row_index = bprint.current_row
|
|
47
|
+
|
|
48
|
+
def __iter__(self):
|
|
49
|
+
self.bprint_row_index = bprint.current_row
|
|
50
|
+
for v in self.iterable:
|
|
51
|
+
self.update(0)
|
|
52
|
+
yield v
|
|
53
|
+
bprint.move_up()
|
|
54
|
+
bprint.clear_line()
|
|
55
|
+
bprint.rows.pop()
|
|
56
|
+
self.update(1)
|
|
57
|
+
bprint.move_up()
|
|
58
|
+
bprint.clear_line()
|
|
59
|
+
bprint.rows.pop()
|
|
60
|
+
if self.position > 0:
|
|
61
|
+
self.reset()
|
|
62
|
+
else:
|
|
63
|
+
self.draw()
|
|
64
|
+
|
|
65
|
+
def draw(self, *, refresh: bool = False) -> None:
|
|
66
|
+
percent = self.current_value / self.total
|
|
67
|
+
num_to_fill = int(percent * self.ncols)
|
|
68
|
+
progress_str = num_to_fill * "#" + (self.ncols - num_to_fill) * " "
|
|
69
|
+
to_print = self.pbar_format.format(
|
|
70
|
+
l_bar=self.desc,
|
|
71
|
+
bar=progress_str,
|
|
72
|
+
n_fmt=self.current_value,
|
|
73
|
+
total_fmt=self.total,
|
|
74
|
+
elapsed=self.prev_update - self.initial_start_time,
|
|
75
|
+
remaining="?",
|
|
76
|
+
rate_fmt=(self.current_value - self.prev_value) /
|
|
77
|
+
self.delta if self.delta != 0 else 0,
|
|
78
|
+
postfix="/s",
|
|
79
|
+
unit=self.unit
|
|
80
|
+
)
|
|
81
|
+
if refresh and self.pool is not None and len(self.pool.bars) > 1:
|
|
82
|
+
for w in self.writes:
|
|
83
|
+
bprint(w, end="")
|
|
84
|
+
bprint(to_print)
|
|
85
|
+
|
|
86
|
+
def update(self, amount: float = 1, refresh: bool = False):
|
|
87
|
+
self.prev_value = self.current_value
|
|
88
|
+
self.current_value = min(
|
|
89
|
+
self.current_value + amount, self.total) # type:ignore
|
|
90
|
+
current_time = time.time()
|
|
91
|
+
self.delta = current_time - self.prev_update
|
|
92
|
+
self.prev_update = current_time
|
|
93
|
+
self.draw(refresh=refresh)
|
|
94
|
+
|
|
95
|
+
def _write(self, *args: str, sep: str = " ", end: str = "\n") -> None:
|
|
96
|
+
if not end.endswith("\n"):
|
|
97
|
+
end += "\n"
|
|
98
|
+
if self.pool is not None and len(self.pool.bars) > 0:
|
|
99
|
+
succeeding_bars = self.pool.bars[self.position + 1:]
|
|
100
|
+
if succeeding_bars:
|
|
101
|
+
for succeeding_bar in succeeding_bars:
|
|
102
|
+
# clear child
|
|
103
|
+
bprint.move_up()
|
|
104
|
+
bprint.clear_line()
|
|
105
|
+
bprint.rows.pop()
|
|
106
|
+
for _ in range(succeeding_bar.num_writes):
|
|
107
|
+
# clear child's writes
|
|
108
|
+
bprint.move_up()
|
|
109
|
+
bprint.clear_line()
|
|
110
|
+
bprint.rows.pop()
|
|
111
|
+
# clear self
|
|
112
|
+
bprint.move_up()
|
|
113
|
+
bprint.clear_line()
|
|
114
|
+
bprint.rows.pop()
|
|
115
|
+
bprint(sep.join(map(str, args)), end=end)
|
|
116
|
+
self.draw()
|
|
117
|
+
for succeeding_bar in succeeding_bars:
|
|
118
|
+
succeeding_bar.update(0, refresh=True)
|
|
119
|
+
return
|
|
120
|
+
|
|
121
|
+
bprint.move_up()
|
|
122
|
+
bprint.clear_line()
|
|
123
|
+
bprint.rows.pop()
|
|
124
|
+
bprint(sep.join(map(str, args)), end=end)
|
|
125
|
+
self.draw()
|
|
126
|
+
|
|
127
|
+
def reset(self) -> None:
|
|
128
|
+
self.current_value = self.initial_value
|
|
129
|
+
self.initial_start_time = time.time()
|
|
130
|
+
self.delta = 0
|
|
131
|
+
self.prev_value = self.initial_value
|
|
132
|
+
for _ in range(self.num_writes):
|
|
133
|
+
bprint.move_up()
|
|
134
|
+
bprint.clear_line()
|
|
135
|
+
bprint.rows.pop()
|
|
136
|
+
self.writes.clear()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
__all__ = [
|
|
140
|
+
'AsciiProgressBar'
|
|
141
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import time
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from typing import Optional, Type, List, Iterable, Any
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
from tqdm import tqdm
|
|
8
|
+
except ImportError:
|
|
9
|
+
from ..mock_ import MockImportObject
|
|
10
|
+
|
|
11
|
+
tqdm = MockImportObject("`tqdm` is not installed") # type:ignore
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ProgressBar(ABC):
|
|
15
|
+
"""An interface
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
ABC (_type_): _description_
|
|
19
|
+
"""
|
|
20
|
+
DEFAULT_BAR_FORMAT = "{desc}: {percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}"
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def __init__(self, total, position: int, unit="it", bar_format: str = DEFAULT_BAR_FORMAT, **kwargs) -> None:
|
|
24
|
+
self.total = total
|
|
25
|
+
self.position = position
|
|
26
|
+
self.unit = unit
|
|
27
|
+
self.bar_format = bar_format
|
|
28
|
+
self.writes: list[str] = []
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def num_writes(self):
|
|
32
|
+
return len(self.writes)
|
|
33
|
+
|
|
34
|
+
@abstractmethod
|
|
35
|
+
def update(self, amount: float = 1) -> None:
|
|
36
|
+
"""A function to update the progress-bar's value by a positive relative amount
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def _write(self, *args: str, sep: str = " ", end: str = "\n") -> None: ...
|
|
41
|
+
|
|
42
|
+
def write(self, *args: Any, sep: str = " ", end: str = "\n") -> None:
|
|
43
|
+
"""A function to write additional text with the progress bar
|
|
44
|
+
"""
|
|
45
|
+
processed = list(map(str, args))
|
|
46
|
+
self._write(*processed, sep=sep, end=end)
|
|
47
|
+
self.writes.append(sep.join(processed) + end)
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def reset(self) -> None:
|
|
51
|
+
"""A function to reset the progress-bar's progress
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
from tqdm import tqdm
|
|
57
|
+
|
|
58
|
+
ProgressBar.register(tqdm)
|
|
59
|
+
except ImportError:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
'ProgressBar',
|
|
64
|
+
]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from typing import Type, List, Optional, Iterator
|
|
2
|
+
from .progress_bar import ProgressBar
|
|
3
|
+
from ..print_ import bprint
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ProgressBarPool:
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
pbar_class: Type[ProgressBar],
|
|
10
|
+
num_of_bars: int = 1,
|
|
11
|
+
global_options: Optional[dict] = None,
|
|
12
|
+
individual_options: Optional[List[Optional[dict]]] = None
|
|
13
|
+
) -> None:
|
|
14
|
+
self.bars: List[ProgressBar] = []
|
|
15
|
+
if global_options is None:
|
|
16
|
+
global_options = {}
|
|
17
|
+
if individual_options is None:
|
|
18
|
+
individual_options = [{} for _ in range(num_of_bars)]
|
|
19
|
+
if len(individual_options) != num_of_bars:
|
|
20
|
+
raise ValueError(
|
|
21
|
+
"must supply the same number of options as there are bars")
|
|
22
|
+
for i in range(num_of_bars):
|
|
23
|
+
if individual_options[i] is None:
|
|
24
|
+
individual_options[i] = {}
|
|
25
|
+
max_desc_length: int = max([len(individual_options[i].get("desc", f"pbar {i}")) for i in range(num_of_bars)])
|
|
26
|
+
for i in range(num_of_bars):
|
|
27
|
+
final_options: dict = global_options.copy()
|
|
28
|
+
final_options.update(individual_options[i]) # type:ignore
|
|
29
|
+
if "desc" not in final_options:
|
|
30
|
+
final_options["desc"] = f"pbar {i}"
|
|
31
|
+
final_options["desc"] = final_options["desc"].ljust(max_desc_length, " ")
|
|
32
|
+
t = pbar_class(
|
|
33
|
+
position=i,
|
|
34
|
+
pool=self,
|
|
35
|
+
**final_options
|
|
36
|
+
)
|
|
37
|
+
self.bars.append(t)
|
|
38
|
+
self.writes: list[str] = []
|
|
39
|
+
|
|
40
|
+
def __getitem__(self, index: int) -> ProgressBar:
|
|
41
|
+
return self.bars[index]
|
|
42
|
+
|
|
43
|
+
def write(self, msg: str, end: str = "\n") -> None:
|
|
44
|
+
prev_rows = bprint.rows.copy()
|
|
45
|
+
for w in self.writes:
|
|
46
|
+
prev_rows.remove(w)
|
|
47
|
+
self.writes.append(msg + end)
|
|
48
|
+
rows = self.writes.copy() + prev_rows
|
|
49
|
+
for _ in bprint.rows:
|
|
50
|
+
bprint.move_up()
|
|
51
|
+
bprint.clear_line()
|
|
52
|
+
bprint.rows.clear()
|
|
53
|
+
|
|
54
|
+
for row in rows:
|
|
55
|
+
bprint(row, end="")
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
def __iter__(self) -> Iterator[ProgressBar]:
|
|
59
|
+
return iter(self.bars)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
__all__ = [
|
|
63
|
+
"ProgressBarPool",
|
|
64
|
+
]
|