def tidy_up(file_in=sys.stdin, file_out=sys.stdout): # 2007 Jan 22
"""Clean up, regularize, and reformat the text of a Python script.
File_in is a file name or a file-like object with a *read* method,
which contains the input script.
File_out is a file name or a file-like object with a *write*
method to contain the output script.
"""
global INPUT, OUTPUT, COMMENTS, NAME_SPACE, INPUT_CODING # 2007 May 23
INPUT = InputUnit(file_in)
OUTPUT = OutputUnit(file_out)
COMMENTS = Comments()
NAME_SPACE = NameSpace()
module = compiler.parse(str(INPUT))
module = transform(indent=ZERO, lineno=ZERO, node=module)
INPUT_CODING = INPUT.coding # 2007 May 23
del INPUT
module.push_scope().marshal_names().put().pop_scope()
COMMENTS.merge(fin=True)
OUTPUT.close()
return
评论列表
文章目录