romtools.workflows.formatting#

Functions

format_file(path, variables[, output_path, ...])

Replace RTVAR placeholders in a file and write the result.

format_files(paths, variables[, output_dir, ...])

Replace RTVAR placeholders in multiple files.

format_text(text, variables[, strict])

Replace RTVAR placeholders in the input text with provided values.

main([argv])

romtools.workflows.formatting.format_file(path, variables, output_path=None, strict=True, encoding='utf-8')[source]#

Replace RTVAR placeholders in a file and write the result.

If output_path is None, the input file is modified in-place.

Parameters:
  • path (str)

  • variables (Mapping[str, Any])

  • output_path (str | None)

  • strict (bool)

  • encoding (str)

Return type:

Path

romtools.workflows.formatting.format_files(paths, variables, output_dir=None, strict=True, encoding='utf-8')[source]#

Replace RTVAR placeholders in multiple files.

If output_dir is provided, formatted files are written there using the original filenames.

Parameters:
  • paths (Iterable[str])

  • variables (Mapping[str, Any])

  • output_dir (str | None)

  • strict (bool)

  • encoding (str)

Return type:

List[Path]

romtools.workflows.formatting.format_text(text, variables, strict=True)[source]#

Replace RTVAR placeholders in the input text with provided values.

Placeholders are of the form: {RTVAR:variable_name}

Parameters:
  • text (str)

  • variables (Mapping[str, Any])

  • strict (bool)

Return type:

str