stubber.minify
¶
Processing for createstubs.py Minimizes and cross-compiles a MicroPyton file.
Module Contents¶
Functions¶
|
Get whitespace count of lines surrounding index |
|
Edit string by list of edits |
|
Minifies createstubs.py and variants |
|
|
|
Minifies and compiles a script |
|
Runs mpy-cross on a (minified) script |
|
Run mpy-cross using pipx |
|
Writes a string to a temp file and returns the Path object |
|
Get temp file and returns the Path object |
Attributes¶
- stubber.minify.StubSource¶
- stubber.minify.XCompileDest¶
- stubber.minify.LineEdits¶
- stubber.minify.get_whitespace_context(content: List[str], index: int)¶
Get whitespace count of lines surrounding index
- stubber.minify.edit_lines(content: str, edits: LineEdits, diff: bool = 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:
- stubber.minify.minify_script(source_script: StubSource, keep_report: bool = True, diff: bool = False) str ¶
Minifies createstubs.py and variants
Args: source_script:
(str): content to edit
(Path): path to file to edit
(IOBase): file-like object to edit
- keep_report (bool, optional): Keeps single report line in createstubs
Defaults to True.
diff (bool, optional): Print diff from edits. Defaults to False.
- Returns:
minified source text
- Return type:
- Parameters:
source_script (StubSource) –
keep_report (bool) –
diff (bool) –
- stubber.minify.reduce_log_print(keep_report, diff, source_content)¶
- stubber.minify.minify(source: StubSource, target: StubSource, keep_report: bool = True, diff: bool = False)¶
Minifies and compiles a script
- Parameters:
source (StubSource) –
target (StubSource) –
keep_report (bool) –
diff (bool) –
- stubber.minify.cross_compile(source: StubSource, target: XCompileDest, version: str = '')¶
Runs mpy-cross on a (minified) script
- Parameters:
source (StubSource) –
target (XCompileDest) –
version (str) –
- stubber.minify.pipx_mpy_cross(version: str, source_file, _target)¶
Run mpy-cross using pipx
- Parameters:
version (str) –