MCPcopy Create free account
hub / github.com/SplootCode/splootcode / convertSplootToText

Function convertSplootToText

python/text_generator.py:456–466  ·  view source on GitHub ↗
(tree: dict)

Source from the content-addressed store, hash-verified

454empty_lines = re.compile('^\s*##SPLOOTCODEEMPTYLINE$', flags=re.MULTILINE)
455
456def convertSplootToText(tree: dict) -> str:
457 if tree["type"] != "PYTHON_FILE":
458 raise Exception("Invalid file type")
459
460 statements = getStatementsFromBlock(tree["childSets"]["body"], insert_pass=False)
461
462 mods = ast.Module(body=statements, type_ignores=[])
463 ast.fix_missing_locations(mods)
464 code_string = ast_comments.unparse(mods)
465 code_string = re.sub(empty_lines, '', code_string)
466 return code_string
467
468
469result = None

Callers 7

testHelloWorldMethod · 0.90
testCommentsMethod · 0.90
testLineGapsMethod · 0.90
test_empty_if_blockMethod · 0.90
text_generator.pyFile · 0.85

Calls 1

getStatementsFromBlockFunction · 0.70

Tested by 6

testHelloWorldMethod · 0.72
testCommentsMethod · 0.72
testLineGapsMethod · 0.72
test_empty_if_blockMethod · 0.72