util_pkgs#

pyufunc includes selected wrappers around third-party utility packages. These packages are maintained by their original projects; pyufunc documents source package, repository, documentation, and license information in wrapper docstrings. The wrappers are included as convenience APIs and should not be read as a claim that every wrapped function is widely used or performance-improving. Users should evaluate optional dependencies and project-specific tradeoffs before using a wrapper in production code.

psutil#

pyhelpers#

Common filesystem, serialization, string, and dictionary helpers#

cd(*args, **kwargs)

Forward to pyhelpers.dirs.cd.

confirmed(*args, **kwargs)

Forward to pyhelpers.ops.confirmed.

fake_requests_headers(*args, **kwargs)

Forward to pyhelpers.ops.fake_requests_headers.

find_similar_str(*args, **kwargs)

Forward to pyhelpers.text.find_similar_str.

load_data(*args, **kwargs)

Forward to pyhelpers.store.load_data.

load_pickle(*args, **kwargs)

Forward to pyhelpers.store.load_pickle.

merge_dicts(*args, **kwargs)

Forward to pyhelpers.ops.merge_dicts.

osgb36_to_wgs84(*args, **kwargs)

Forward to pyhelpers.geom.osgb36_to_wgs84.

remove_punctuation(*args, **kwargs)

Forward to pyhelpers.text.remove_punctuation.

resolve_dir(*args, **kwargs)

Forward to pyhelpers.dirs.resolve_dir.

save_data(*args, **kwargs)

Forward to pyhelpers.store.save_data.

save_pickle(*args, **kwargs)

Forward to pyhelpers.store.save_pickle.

update_dict_keys(*args, **kwargs)

Forward to pyhelpers.ops.update_dict_keys.

wgs84_to_osgb36(*args, **kwargs)

Forward to pyhelpers.geom.wgs84_to_osgb36.

pyutil#

General-purpose helpers from pyutil#

Version(*args, **kwargs)

Instantiate pyutil.version_class.Version.

log_ceil(*args, **kwargs)

Forward to pyutil.mathutil.log_ceil.

pad_size(*args, **kwargs)

Forward to pyutil.mathutil.pad_size.

precondition(*args, **kwargs)

Forward to pyutil.assertutil.precondition.

imutils#

Image and OpenCV convenience helpers#

auto_canny(*args, **kwargs)

Forward to imutils.auto_canny.

grab_contours(*args, **kwargs)

Forward to imutils.grab_contours.

is_cv2(*args, **kwargs)

Forward to imutils.is_cv2.

is_cv3(*args, **kwargs)

Forward to imutils.is_cv3.

is_cv4(*args, **kwargs)

Forward to imutils.is_cv4.

opencv2matplotlib(*args, **kwargs)

Forward to imutils.opencv2matplotlib.

resize(*args, **kwargs)

Forward to imutils.resize.

rotate(*args, **kwargs)

Forward to imutils.rotate.

rotate_bound(*args, **kwargs)

Forward to imutils.rotate_bound.

skeletonize(*args, **kwargs)

Forward to imutils.skeletonize.

translate(*args, **kwargs)

Forward to imutils.translate.

url_to_image(*args, **kwargs)

Forward to imutils.url_to_image.

platformdirs#

Platform-specific application directories#

get_user_cache_dir([app_name, app_author])

Return the platform-specific user cache directory for an app.

get_user_config_dir([app_name, app_author])

Return the platform-specific user config directory for an app.

get_user_data_dir([app_name, app_author])

Return the platform-specific user data directory for an app.

get_user_log_dir([app_name, app_author])

Return the platform-specific user log directory for an app.

filelock#

File locking and safe writes#

safe_write_json_with_lock(path, data, *[, ...])

Write JSON while holding a file lock.

safe_write_pickle_with_lock(path, data, *[, ...])

Write pickle data while holding a file lock.

safe_write_text_with_lock(path, text, *[, ...])

Write text while holding a file lock.

with_file_lock(lock_path[, timeout])

Return a file lock context manager.

pathspec#

Gitignore-style pattern matching#

collect_files_excluding_gitignore(root_dir)

Collect files under a directory while excluding gitignore matches.

filter_paths_by_gitignore(paths, patterns, *)

Return paths that are not ignored by gitignore-style patterns.

is_path_ignored(path, patterns, *[, root])

Return whether a path matches gitignore-style patterns.

load_gitignore_patterns(gitignore_path)

Load a gitignore-style file into a pathspec matcher.

more-itertools#

Iterable recipes and grouping helpers#

iter_chunked(iterable, chunk_size, *[, strict])

Split an iterable into fixed-size chunks.

iter_flatten(iterable, *[, base_type])

Flatten nested iterables.

iter_split_when(iterable, predicate, *[, ...])

Split an iterable when a pair-wise predicate is true.

iter_unique(iterable[, key])

Yield unique items while preserving first-seen order.

iter_windowed(iterable, window_size, *[, ...])

Return sliding windows over an iterable.

humanize#

Human-readable formatting helpers#

human_file_size(value, *[, binary, gnu, ...])

Format a byte count as a human-readable file size.

human_intcomma(value[, ndigits])

Format a number with comma separators.

human_number(value, *[, format_str])

Format a large number as human-readable text.

human_time_delta(value, **kwargs)

Format a duration as human-readable text.

tenacity#

Retry helpers#

retry_call(function, *args[, attempts, ...])

Call a function with retry attempts.

retry_on_exception([function, attempts, ...])

Decorate a function to retry on selected exceptions.

retry_with_backoff([function, attempts, ...])

Decorate a function with exponential backoff retry behavior.

boltons#

Nested data, atomic file, string, and time helpers#

atomic_save_file(path, data, *[, text_mode, ...])

Atomically write text or bytes to a file.

flatten_iterable(iterable)

Flatten one level of nested iterables.

parse_timedelta_text(text)

Parse human-readable duration text into datetime.timedelta.

remap_nested_dict(mapping, **kwargs)

Transform nested mappings and sequences with boltons.iterutils.remap.

slugify_text(text, *[, delim, lower, ascii])

Convert text to a slug with boltons.strutils.slugify.

toolz#

Functional data helpers#

toolz_count_frequencies(sequence)

Count item frequencies in a sequence.

toolz_groupby_key(key, sequence)

Group items by a key function or mapping key.

toolz_merge_dicts(*dicts, **kwargs)

Merge dictionaries with later values taking precedence.

toolz_pipe_call(value, *functions)

Pipe a value through a sequence of functions.

toolz_sliding_window(window_size, sequence)

Return a sliding window over a sequence.

python-benedict#

Nested dictionary key-path helpers#

dict_flatten(mapping, *[, separator, indexes])

Flatten a nested dictionary.

dict_get_by_path(mapping, key_path[, ...])

Get a nested dictionary value by key path.

dict_set_by_path(mapping, key_path, value, *)

Set a nested dictionary value by key path.

dict_to_json_safe(mapping, **kwargs)

Serialize a mapping to JSON with python-benedict.

dict_unflatten(mapping, *[, separator])

Unflatten a dictionary.

loguru#

Logger setup helpers#

disable_logger([name])

Disable loguru logging for a logger name.

enable_logger([name])

Enable loguru logging for a logger name.

setup_file_logger(log_file, *[, level, ...])

Add a file sink to the loguru logger.

setup_simple_logger(*[, level, format_str, ...])

Add a simple stderr loguru logger.

Package inspection#

Package public-function discovery and dependent usage helpers#

pkg_dependents_func_usage(github_link, *[, ...])

Collect dependent repositories and detect target package function usage.

pkg_public_func(pkg_name, *[, import_name, ...])

Show package-level public functions defined by a Python package.

save_dict_to_json(filename, data, *[, ...])

Save a dictionary to a JSON file with pretty formatting.