PythonTidy.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:alljoyn_python 作者: glennpierce 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号