8000 mininet/util/unpep8 at devel/iplink · ZWeKing/mininet · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
executable file
·
198 lines (166 loc) · 6.78 KB

unpep8

File metadata and controls

executable file
·
198 lines (166 loc) · 6.78 KB
comment = indentExp.sub( indent, comment )
return originalIndent + trailingQuotes.sub( '"""', comment )
def fixCommentIndents( text ):
"Fix multiline comment indentation."
comments = re.compile( r'^([ ]*)("""[^"]*""")$', re.MULTILINE )
return comments.sub( fixComment, text )
def removeBogusLinefeeds( text ):
"Remove extra linefeeds at the end of single-line comments."
bogusLfs = re.compile( r'"([^"\n]*)\n"', re.MULTILINE )
return bogusLfs.sub( '"\1"', text)
def convertFromPep8( program ):
oldProgram = program
# Program text transforms
program = reinstateCapWords( program )
program = fixKeywords( program )
program = insertExtraSpaces( program )
# Undo string damage
program = restoreStrings( oldProgram, program )
# Docstring transforms
program = replaceTripleApostrophes( program )
program = simplifyTripleQuotes( program )
program = fixDoxygen( program )
program = fixCommentIndents( program )
program = removeBogusLinefeeds( program )
# Destructive transforms (these can delete lines)
program = removeCommentFirstBlankLine( program )
return program
if __name__ == '__main__':
print convertFromPep8( sys.stdin.read() )
0