httk.workflow.runtime_utils

Safe replacements for small conveniences used by shell runners.

Functions

evaluate_expression(expression)

Evaluate a bounded arithmetic expression without Python eval.

render_template(template_path, output_path, values)

Render string.Template placeholders from an explicit mapping.

compress_files(paths, *[, method, remove_source])

Compress regular files atomically with a stdlib codec.

decompress_files(paths, *[, remove_source])

Decompress .bz2, .gz, or .xz files atomically.

Module Contents

httk.workflow.runtime_utils.evaluate_expression(expression)[source]

Evaluate a bounded arithmetic expression without Python eval.

Parameters:

expression (str) – Supply the arithmetic expression to evaluate.

Returns:

The evaluated scalar result.

Raises:

ValueError – If the expression contains an unsupported element.

Return type:

int | float | bool

httk.workflow.runtime_utils.render_template(template_path, output_path, values)[source]

Render string.Template placeholders from an explicit mapping.

Parameters:
Returns:

The rendered output path.

Raises:

KeyError – If the template names a missing value.

Return type:

pathlib.Path

httk.workflow.runtime_utils.compress_files(paths, *, method='bz2', remove_source=False)[source]

Compress regular files atomically with a stdlib codec.

Parameters:
Returns:

The compressed output paths.

Raises:

ValueError – If a method or source file is invalid.

Return type:

tuple[pathlib.Path, Ellipsis]

httk.workflow.runtime_utils.decompress_files(paths, *, remove_source=False)[source]

Decompress .bz2, .gz, or .xz files atomically.

Parameters:
Returns:

The decompressed output paths.

Raises:
  • ValueError – If a source is not a supported regular compressed file.

  • FileExistsError – If a decompressed output already exists.

Return type:

tuple[pathlib.Path, Ellipsis]