danielutils 0.9.83__tar.gz → 0.9.90__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.83/danielutils.egg-info → danielutils-0.9.90}/PKG-INFO +2 -2
- {danielutils-0.9.83 → danielutils-0.9.90}/README.md +1 -1
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/__init__.py +2 -1
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker.py +2 -1
- danielutils-0.9.90/danielutils/context_managers/__init__.py +5 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/context_managers/attr_context.py +2 -1
- danielutils-0.9.90/danielutils/context_managers/multi_context.py +23 -0
- danielutils-0.9.90/danielutils/context_managers/optional_context.py +18 -0
- danielutils-0.9.90/danielutils/context_managers/state_context.py +16 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/context_managers/temporary_file.py +12 -11
- danielutils-0.9.90/danielutils/custom_types.py +22 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/__init__.py +1 -0
- danielutils-0.9.90/danielutils/data_structures/algorithms.py +44 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/decorate_conditionally.py +1 -1
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/memo.py +21 -2
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/overload.py +2 -2
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/processify.py +3 -1
- danielutils-0.9.90/danielutils/file_specifications/__init__.py +71 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/__init__.py +4 -1
- danielutils-0.9.90/danielutils/functions/factorial.py +5 -0
- danielutils-0.9.90/danielutils/functions/foreach.py +14 -0
- danielutils-0.9.90/danielutils/functions/partition.py +37 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/generators/join_generators.py +1 -1
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/print_.py +20 -17
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/progress_bar/ascii_progress_bar.py +63 -14
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/progress_bar/progress_bar.py +17 -7
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/progress_bar/progress_bar_pool.py +21 -3
- danielutils-0.9.90/danielutils/protocols/__init__.py +3 -0
- danielutils-0.9.90/danielutils/protocols/serializable.py +28 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/callstack.py +4 -2
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/layered_command.py +3 -3
- danielutils-0.9.90/danielutils/university/__init__.py +7 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/__init__.py +2 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/discreate_finite_automaton.py +89 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/languages/language.py +17 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/languages/sat.py +69 -0
- danielutils-0.9.90/danielutils/university/computability_and_complexity/turing_machine.py +47 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/databases/all.py +2 -2
- danielutils-0.9.90/danielutils/university/image_proccesing/__init__.py +1 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/__init__.py +3 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/encoding.py +35 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossless/__init__.py +4 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossless/huffman.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossless/lossless_encoding.py +10 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossless/lzw.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossless/run_length.py +23 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossy/__init__.py +1 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/encoding/lossy/lossy_encoding.py +10 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/__init__.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/gaussian.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/gradient.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/hough.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/laplacian.py +0 -0
- danielutils-0.9.90/danielutils/university/image_proccesing/tansformations/transformation.py +10 -0
- danielutils-0.9.90/danielutils/university/linear_algebra/__init__.py +1 -0
- danielutils-0.9.90/danielutils/university/linear_algebra/matrix.py +398 -0
- danielutils-0.9.90/danielutils/university/machine_learning/__init__.py +0 -0
- danielutils-0.9.90/danielutils/university/machine_learning/activation_functions/__init__.py +2 -0
- danielutils-0.9.90/danielutils/university/machine_learning/activation_functions/activation_function.py +11 -0
- danielutils-0.9.90/danielutils/university/machine_learning/activation_functions/relu.py +11 -0
- danielutils-0.9.90/danielutils/university/machine_learning/neuron.py +15 -0
- danielutils-0.9.90/danielutils/university/probability/conditional_variable/continuous/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/funcs/expected_value.py +1 -1
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/transformation.py +2 -2
- {danielutils-0.9.83 → danielutils-0.9.90/danielutils.egg-info}/PKG-INFO +2 -2
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils.egg-info/SOURCES.txt +39 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/pyproject.toml +1 -1
- danielutils-0.9.83/danielutils/context_managers/__init__.py +0 -2
- danielutils-0.9.83/danielutils/protocols/__init__.py +0 -2
- danielutils-0.9.83/danielutils/university/__init__.py +0 -3
- {danielutils-0.9.83 → danielutils-0.9.90}/LICENSE +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/MANIFEST.in +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/database/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/database/cached_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/database/database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/database/redis_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/multi_id.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker_pool.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/repl.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/aliases.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/counter.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/frange.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/factory.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tdict.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tlist.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/tset.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/better_builtins/typed_builtins/ttuple.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/colors.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/convenience.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/conversions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/conversions/main_conversions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/to_hex.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/conversions/specialized_conversions/to_int.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/comparer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/default_dict.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/functions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/graph/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/graph/binary_node.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/graph/graph.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/graph/multinode.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/graph/node.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/heap/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/heap/heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/heap/max_heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/heap/min_heap.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/queue/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/queue/atomic_queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/queue/priority_queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/queue/queue.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/stack.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/trees/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/trees/binary_syntax_tree.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/data_structures/trees/binary_tree.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/date.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/date_time.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/atomic.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/attach.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/chain_decorators.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/delay_call.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/deprecate.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/final.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/limit_recursion.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/partially_implemented.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/property.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/singleton.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/threadify.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/timeout.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/total_ordering.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/decorators/validate.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/exceptions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/areoneof.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/check_foreach.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/flatten.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/isoftype.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/isoneof.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/multiloop.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/parallel_for.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/powerset.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/subseteq.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/functions/types_subseteq.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/generators/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/generators/conditional_generator.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/generators/generator_from_stream.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/internet.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/io_.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/math_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/math_/constants.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/math_/functions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/math_/math_print.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/math_/math_symbols.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/atomic_class_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/implicit_data_deleter_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/instance_cache_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/interface.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/metaclasses/overload_meta.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/mock_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/mock_/mock_database.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/mock_/mock_module.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/path.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/progress_bar/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/protocols/dictable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/protocols/evaluable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/py.typed +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/class_/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/class_/class_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/file/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/file/file_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/function/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/function/function_reflections.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/get_traceback.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/os_.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/packages.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/python_version.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/signals.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/interpreter/tracer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/module/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/module/module_reflections.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/reflection/module/package_reflection.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/snippets/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/snippets/try_get.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/independent.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/windows/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/windows/utils/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/windows/utils/filetime.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/windows/win32_ctime.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/system/windows/windows.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/text.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/time.py +0 -0
- {danielutils-0.9.83/danielutils/university/probability/conditional_variable/continuous → danielutils-0.9.90/danielutils/university/computability_and_complexity/languages}/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/databases/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/oop/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/oop/observer.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/oop/strategy.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/conditional_variable.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/bernoulli.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/binomial.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/conditional_from_discrete_probability_func.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/discrete.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/geometric.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/poisson.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/conditional_variable/discrete/uniform.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/distributions.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/expressions/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/expressions/accumulation_expression.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/expressions/probability_expression.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/funcs/__init__.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/funcs/covariance.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/funcs/probability_function.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/funcs/variance.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/operator.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/protocols.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/university/probability/supp.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils/versioned_imports.py +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils.egg-info/dependency_links.txt +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/danielutils.egg-info/top_level.txt +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/setup.cfg +0 -0
- {danielutils-0.9.83 → danielutils-0.9.90}/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.90
|
|
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
|
|
|
@@ -18,11 +18,11 @@ from .protocols import *
|
|
|
18
18
|
from .reflection import *
|
|
19
19
|
from .decorators import *
|
|
20
20
|
# ========== NEEDS REFLECTION ==========
|
|
21
|
-
from .progress_bar import *
|
|
22
21
|
# ========== NEEDS DECORATORS ==========
|
|
23
22
|
from .colors import *
|
|
24
23
|
# ========== NEEDS BOTH ==========
|
|
25
24
|
|
|
25
|
+
from .progress_bar import *
|
|
26
26
|
from .functions import *
|
|
27
27
|
from .io_ import *
|
|
28
28
|
from .system import *
|
|
@@ -40,3 +40,4 @@ from .generators import *
|
|
|
40
40
|
from .university import *
|
|
41
41
|
from .mock_ import *
|
|
42
42
|
from .context_managers import *
|
|
43
|
+
from .file_specifications import *
|
{danielutils-0.9.83 → danielutils-0.9.90}/danielutils/abstractions/multiprogramming/worker.py
RENAMED
|
@@ -12,7 +12,7 @@ class Worker(ABC):
|
|
|
12
12
|
"""A Worker Interface
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
def __init__(self, id: int, pool: "danielutils.
|
|
15
|
+
def __init__(self, id: int, pool: "danielutils.abstractions.multiprogramming.worker_pool.WorkerPool") -> None: # pylint: disable=redefined-builtin #noqa
|
|
16
16
|
self.id = id
|
|
17
17
|
self.pool = pool
|
|
18
18
|
self.thread: Thread = Thread(target=self._loop)
|
|
@@ -57,6 +57,7 @@ class Worker(ABC):
|
|
|
57
57
|
to signal actions if needed
|
|
58
58
|
will call 'notification_function'
|
|
59
59
|
"""
|
|
60
|
+
# TODO
|
|
60
61
|
self.pool._notify_subscribers() # pylint: disable=protected-access
|
|
61
62
|
|
|
62
63
|
def acquire(self) -> Optional[Tuple[Any]]:
|
|
@@ -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,18 @@
|
|
|
1
|
+
from typing import ContextManager
|
|
2
|
+
class OptionalContext(ContextManager):
|
|
3
|
+
def __init__(self, predicate: bool, context: ContextManager):
|
|
4
|
+
self.predicate = predicate
|
|
5
|
+
self.context = context
|
|
6
|
+
|
|
7
|
+
def __enter__(self):
|
|
8
|
+
if self.predicate:
|
|
9
|
+
self.context.__enter__()
|
|
10
|
+
|
|
11
|
+
def __exit__(self, __exc_type, __exc_value, __traceback):
|
|
12
|
+
if self.predicate:
|
|
13
|
+
self.context.__exit__(__exc_type, __exc_value, __traceback)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__=[
|
|
17
|
+
"OptionalContext"
|
|
18
|
+
]
|
|
@@ -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
|
+
]
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
from ..io_ import file_exists, delete_file
|
|
2
1
|
import atexit
|
|
2
|
+
from typing import ContextManager, Set, List
|
|
3
|
+
from ..io_ import file_exists, delete_file
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
class TemporaryFile:
|
|
6
|
-
_instances:
|
|
6
|
+
class TemporaryFile(ContextManager):
|
|
7
|
+
_instances: Set['TemporaryFile'] = set()
|
|
7
8
|
|
|
8
9
|
def __init__(self, path: str):
|
|
9
10
|
if file_exists(path):
|
|
@@ -17,22 +18,16 @@ class TemporaryFile:
|
|
|
17
18
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
18
19
|
self.close()
|
|
19
20
|
|
|
20
|
-
@atexit.register
|
|
21
|
-
@staticmethod
|
|
22
|
-
def _global_close():
|
|
23
|
-
for inst in TemporaryFile._instances:
|
|
24
|
-
inst.close()
|
|
25
|
-
|
|
26
21
|
def close(self) -> None:
|
|
27
22
|
delete_file(self.path)
|
|
28
23
|
|
|
29
|
-
def read(self) ->
|
|
24
|
+
def read(self) -> List[str]:
|
|
30
25
|
if not file_exists(self.path):
|
|
31
26
|
return []
|
|
32
27
|
with open(self.path, 'r') as f:
|
|
33
28
|
return f.readlines()
|
|
34
29
|
|
|
35
|
-
def write(self, lines:
|
|
30
|
+
def write(self, lines: List[str]) -> None:
|
|
36
31
|
with open(self.path, 'a') as f:
|
|
37
32
|
f.writelines(lines)
|
|
38
33
|
|
|
@@ -41,6 +36,12 @@ class TemporaryFile:
|
|
|
41
36
|
pass
|
|
42
37
|
|
|
43
38
|
|
|
39
|
+
@atexit.register
|
|
40
|
+
def __close_all():
|
|
41
|
+
for inst in TemporaryFile._instances: # type:ignore #pylint: disable=all
|
|
42
|
+
inst.close()
|
|
43
|
+
|
|
44
|
+
|
|
44
45
|
__all__ = [
|
|
45
46
|
'TemporaryFile'
|
|
46
47
|
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from typing import Callable, TypeVar, Generic
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
from typing import TypeAlias
|
|
5
|
+
except ImportError:
|
|
6
|
+
from typing_extensions import TypeAlias
|
|
7
|
+
|
|
8
|
+
T = TypeVar('T')
|
|
9
|
+
U = TypeVar('U')
|
|
10
|
+
Procedure: TypeAlias = Callable[[], None]
|
|
11
|
+
Supplier: TypeAlias = Callable[[], T]
|
|
12
|
+
Consumer: TypeAlias = Callable[[T], None]
|
|
13
|
+
Predicate: TypeAlias = Callable[[], bool]
|
|
14
|
+
Mapper: TypeAlias = Callable[[T], U]
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'Procedure',
|
|
18
|
+
'Supplier',
|
|
19
|
+
'Consumer',
|
|
20
|
+
'Predicate',
|
|
21
|
+
'Mapper'
|
|
22
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from typing import TypeVar, List, Callable, Dict
|
|
3
|
+
from itertools import product
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
|
|
6
|
+
NodeT = TypeVar("NodeT")
|
|
7
|
+
|
|
8
|
+
DistanceMatrix = Dict[NodeT, Dict[NodeT, float]]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def bellman_ford(nodes: List[NodeT], weight_func: Callable[[NodeT, NodeT], float],
|
|
12
|
+
iteration_callback: Callable[[DistanceMatrix], None],
|
|
13
|
+
poisoned_reverse: bool = False) -> DistanceMatrix:
|
|
14
|
+
dist: Dict[NodeT, Dict[NodeT, float]] = defaultdict(defaultdict)
|
|
15
|
+
prev: Dict[NodeT, Dict[NodeT, NodeT]] = defaultdict(defaultdict)
|
|
16
|
+
|
|
17
|
+
for u, v in product(nodes, nodes):
|
|
18
|
+
dist[u][v] = weight_func(u, v)
|
|
19
|
+
|
|
20
|
+
iteration_callback(dist)
|
|
21
|
+
|
|
22
|
+
for _ in range(len(nodes) - 1):
|
|
23
|
+
tmp = deepcopy(dist)
|
|
24
|
+
for u, v in product(nodes, nodes):
|
|
25
|
+
if u == v:
|
|
26
|
+
continue
|
|
27
|
+
|
|
28
|
+
for mid in nodes:
|
|
29
|
+
if mid == u or mid == v:
|
|
30
|
+
continue
|
|
31
|
+
|
|
32
|
+
if dist[u][v] > dist[u][mid] + dist[mid][v]:
|
|
33
|
+
tmp[u][v] = dist[u][mid] + dist[mid][v]
|
|
34
|
+
prev[u][v] = mid
|
|
35
|
+
|
|
36
|
+
dist = tmp
|
|
37
|
+
iteration_callback(dist)
|
|
38
|
+
|
|
39
|
+
iteration_callback(prev)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
"bellman_ford"
|
|
44
|
+
]
|
|
@@ -3,7 +3,7 @@ from typing import Callable, Optional, Union
|
|
|
3
3
|
from .validate import validate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
@validate # type:ignore
|
|
6
|
+
@validate(strict=False) # type:ignore
|
|
7
7
|
def decorate_conditionally(decorator: Callable, predicate: Union[bool, Callable[[], bool]], *,
|
|
8
8
|
decorator_args: Optional[list] = None, decorator_kwargs: Optional[dict] = None):
|
|
9
9
|
"""will decorate a function iff the predicate is True or returns True
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import functools
|
|
2
|
-
from typing import Callable, Any, TypeVar, Dict
|
|
2
|
+
from typing import Callable, Any, TypeVar, Dict, Generator, List, Set, Optional
|
|
3
3
|
from copy import deepcopy
|
|
4
4
|
from .validate import validate
|
|
5
5
|
from ..versioned_imports import ParamSpec
|
|
@@ -27,6 +27,25 @@ def memo(func: FuncT) -> FuncT:
|
|
|
27
27
|
return wrapper
|
|
28
28
|
|
|
29
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
|
+
|
|
30
48
|
__all__ = [
|
|
31
|
-
"memo"
|
|
49
|
+
"memo",
|
|
50
|
+
"memo_generator"
|
|
32
51
|
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Callable, cast, Any, TypeVar, Dict
|
|
1
|
+
from typing import Callable, cast, Any, TypeVar, Dict, List
|
|
2
2
|
import inspect
|
|
3
3
|
import functools
|
|
4
4
|
from ..reflection import is_function_annotated_properly
|
|
@@ -122,7 +122,7 @@ class overload:
|
|
|
122
122
|
overload._validate(func)
|
|
123
123
|
self._qualname = func.__qualname__
|
|
124
124
|
self._moudle = func.__module__
|
|
125
|
-
self._functions: Dict[int,
|
|
125
|
+
self._functions: Dict[int, List[Callable]] = {}
|
|
126
126
|
self._functions[overload._get_key(func)] = [func]
|
|
127
127
|
functools.wraps(func)(self)
|
|
128
128
|
|
|
@@ -35,12 +35,14 @@ def processify(func):
|
|
|
35
35
|
return wrapper
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
def _run_func(main_pid: int, dct: dict, func_name: str, args, kwargs) -> None:
|
|
40
39
|
return dct[func_name](*args, __main_pid=main_pid, **kwargs)
|
|
41
40
|
|
|
41
|
+
|
|
42
42
|
def debug_info(include_builtins: bool = False) -> dict:
|
|
43
43
|
f = get_prev_frame(2)
|
|
44
|
+
if f is None:
|
|
45
|
+
raise RuntimeError("Failed to get frame")
|
|
44
46
|
g = {k: v for k, v in f.f_globals.items() if k != "__builtins__"} if not include_builtins else dict(f.f_globals)
|
|
45
47
|
return {
|
|
46
48
|
"file": f.f_code.co_filename,
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional, List
|
|
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,
|
|
38
|
+
sections: List[Section]) -> None:
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
long_name:
|
|
43
|
+
short_name:
|
|
44
|
+
extension:
|
|
45
|
+
specification:
|
|
46
|
+
sections:
|
|
47
|
+
"""
|
|
48
|
+
self.long_name = long_name
|
|
49
|
+
self.short_name = short_name
|
|
50
|
+
self.extension = extension
|
|
51
|
+
self.specification = specification
|
|
52
|
+
self.sections = sections
|
|
53
|
+
|
|
54
|
+
def open(self, path: str):
|
|
55
|
+
if not path.endswith(self.extension):
|
|
56
|
+
raise ValueError(f"Invalid file extension, expected {self.extension}")
|
|
57
|
+
with open(path, "rb") as f:
|
|
58
|
+
lines = f.readlines()
|
|
59
|
+
for line in lines:
|
|
60
|
+
for b in line:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
return lines
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
__all__ = [
|
|
67
|
+
"Field",
|
|
68
|
+
"Section",
|
|
69
|
+
"FileSpecification",
|
|
70
|
+
"FileSpecification",
|
|
71
|
+
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from typing import List, Generator, Tuple, Union
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def partitions(n: int, k: int) -> Generator[List[int], None, None]:
|
|
5
|
+
from ..decorators import memo_generator
|
|
6
|
+
|
|
7
|
+
@memo_generator()
|
|
8
|
+
def helper(n: int, target_sum: int, current_sum: int, topLevel: int, arr: Union[List[int], Tuple[int]]) -> \
|
|
9
|
+
Generator[List[int], None, None]:
|
|
10
|
+
arr = list(arr)
|
|
11
|
+
if n == 1:
|
|
12
|
+
if current_sum <= target_sum:
|
|
13
|
+
if topLevel == 1 or (target_sum - current_sum >= arr[-2]):
|
|
14
|
+
arr[-1] = target_sum - current_sum
|
|
15
|
+
yield tuple(arr)
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
start = 0
|
|
19
|
+
if n != topLevel:
|
|
20
|
+
start = arr[-1 * n - 1]
|
|
21
|
+
|
|
22
|
+
for i in range(start, target_sum + 1):
|
|
23
|
+
arr[-1 * n] = i
|
|
24
|
+
yield from helper(n - 1, target_sum, current_sum + i, topLevel, tuple(arr))
|
|
25
|
+
|
|
26
|
+
arr: List[int] = [0] * k
|
|
27
|
+
yield from helper(k, n, 0, k, tuple(arr))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def num_partitions(n: int, k: int) -> int:
|
|
31
|
+
return len(list(partitions(n, k)))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"partitions",
|
|
36
|
+
"num_partitions"
|
|
37
|
+
]
|
|
@@ -44,7 +44,7 @@ def join_generators(*generators) -> Generator[Tuple[int, Any], None, None]:
|
|
|
44
44
|
Yields:
|
|
45
45
|
Generator[Any, None, None]: one generator that combines all of the given ones
|
|
46
46
|
"""
|
|
47
|
-
queue = Queue()
|
|
47
|
+
queue: Queue = Queue()
|
|
48
48
|
edit_queue_semaphore = Semaphore(1)
|
|
49
49
|
queue_status_semaphore = Semaphore(0)
|
|
50
50
|
finished_threads_counter = AtomicCounter()
|
|
@@ -26,7 +26,7 @@ def mprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
|
26
26
|
stream.write(sep.join([mprint_parse_one(s) for s in args]) + end)
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
@deprecate("The built-in 'print' function has an argument called 'file', use this instead")
|
|
29
|
+
@deprecate("The built-in 'print' function has an argument called 'file', use this instead") # type:ignore
|
|
30
30
|
def sprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
31
31
|
"""Writes a string representation of the given arguments to the specified stream.
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ def sprint(*args, sep: str = " ", end: str = "\n", stream=sys.stdout) -> None:
|
|
|
42
42
|
stream.write(sep.join(args) + end)
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
@atomic
|
|
45
|
+
@atomic # type:ignore
|
|
46
46
|
def aprint(*args, sep=" ", end="\n") -> None:
|
|
47
47
|
"""Prints a string representation of the given arguments to the console.
|
|
48
48
|
|
|
@@ -58,17 +58,18 @@ def aprint(*args, sep=" ", end="\n") -> None:
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
class BetterPrinter:
|
|
61
|
-
def __init__(self, thread_safe: bool = False):
|
|
61
|
+
def __init__(self, stream: IO = sys.stdout, thread_safe: bool = False):
|
|
62
|
+
self.stream: IO = stream
|
|
62
63
|
if thread_safe:
|
|
63
|
-
self.__call__ = atomic(self.__call__)
|
|
64
|
+
self.__call__ = atomic(self.__call__) # type:ignore
|
|
64
65
|
self._current_row: int = 0
|
|
65
66
|
self.rows: list[str] = []
|
|
66
67
|
|
|
67
|
-
def clear(self,
|
|
68
|
-
if not stream.isatty():
|
|
69
|
-
warning(f"Cannot clear because {stream} is not a terminal stream")
|
|
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")
|
|
70
71
|
return
|
|
71
|
-
self.write("\033[2J",
|
|
72
|
+
self.write("\033[2J", flush=flush)
|
|
72
73
|
self.rows.pop()
|
|
73
74
|
|
|
74
75
|
def clear_line(self) -> None:
|
|
@@ -80,27 +81,29 @@ class BetterPrinter:
|
|
|
80
81
|
self.rows.pop()
|
|
81
82
|
self._current_row -= 1
|
|
82
83
|
|
|
83
|
-
def write(self, *args, sep: str = " ", end: str = "\n",
|
|
84
|
+
def write(self, *args, sep: str = " ", end: str = "\n", flush: bool = True):
|
|
84
85
|
text = sep.join(args) + end
|
|
85
86
|
self._current_row += text.count("\n")
|
|
86
87
|
self.rows.extend([f"{s}\n" for s in text.splitlines() if len(s) > 0])
|
|
87
|
-
stream.write(text)
|
|
88
|
+
self.stream.write(text)
|
|
88
89
|
if flush:
|
|
89
|
-
stream.flush()
|
|
90
|
+
self.stream.flush()
|
|
90
91
|
|
|
91
|
-
def __call__(self, *args,
|
|
92
|
-
self.write(*args,
|
|
92
|
+
def __call__(self, *args, sep: str = " ", end: str = "\n", flush: bool = True) -> None:
|
|
93
|
+
self.write(*args, sep=sep, end=end, flush=flush)
|
|
93
94
|
|
|
94
95
|
@property
|
|
95
96
|
def current_row(self) -> int:
|
|
96
97
|
return self._current_row
|
|
97
98
|
|
|
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()
|
|
99
103
|
self.rows.insert(row, text)
|
|
100
|
-
|
|
101
|
-
self.
|
|
102
|
-
|
|
103
|
-
for _ in range(num_rows):
|
|
104
|
+
num = len(self.rows)
|
|
105
|
+
self.write(*self.rows, end="")
|
|
106
|
+
for _ in range(num):
|
|
104
107
|
self.rows.pop()
|
|
105
108
|
|
|
106
109
|
|