stubber.minify

Processing for createstubs.py minimizes and cross-compiles a micropyton file.

Module Contents

Functions

edit_lines(content, edits[, diff])

Edit string by list of edits

minify_script(→ str)

minifies createstubs.py

minify(source, target[, keep_report, diff, cross_compile])

Attributes

python_minifier

stubber.minify.python_minifier
stubber.minify.edit_lines(content, edits, diff=False)

Edit string by list of edits

Parameters
  • content (str) – content to edit

  • edits ([(str, str)]) – List of edits to make. The first string in the tuple representsthe type of edit to make, can be either: - comment - comment text out (removed on minify) - rprint - replace text with print - rpass - replace text with pass The second string is the matching text to replace

  • diff (bool, optional) – Prints diff of each edit. Defaults to False.

Returns

edited string

Return type

str

stubber.minify.minify_script(source_script: pathlib.Path, keep_report=True, diff=False) str

minifies createstubs.py

Parameters
  • keep_report (bool, optional) – Keeps single report line in createstubs Defaults to True.

  • diff (bool, optional) – Print diff from edits. Defaults to False.

  • source_script (pathlib.Path) –

Returns

minified source text

Return type

str

stubber.minify.minify(source: Union[str, pathlib.Path], target: Union[str, pathlib.Path], keep_report: bool = True, diff: bool = False, cross_compile: bool = False)
Parameters