<s> """<STR_LIT>""" <EOL> __author__ = "<STR_LIT>" <EOL> from . import support <EOL> import os <EOL> import sys <EOL> import logging <EOL> from . . import pytree <EOL> import pgen2 <EOL> from pgen2 import driver <EOL> logging . basicConfig ( ) <EOL> def main ( ) : <EOL> gr = driver . load_grammar ( "<STR_LIT>" ) <EOL> dr = driver . Driver ( gr , convert = pytree . convert ) <EOL> fn = "<STR_LIT>" <EOL> tree = dr . parse_file ( fn , debug = True ) <EOL> if not diff ( fn , tree ) : <EOL> print "<STR_LIT>" <EOL> if not sys . argv [ <NUM_LIT:1> : ] : <EOL> return <EOL> problems = [ ] <EOL> for name in sys . modules : <EOL> mod = sys . modules [ name ] <EOL> if mod is None or not hasattr ( mod , "<STR_LIT>" ) : <EOL> continue <EOL> fn = mod . __file__ <EOL> if fn . endswith ( "<STR_LIT>" ) : <EOL> fn = fn [ : - <NUM_LIT:1> ] <EOL> if not fn . endswith ( "<STR_LIT>" ) : <EOL> continue <EOL> print >> sys . stderr , "<STR_LIT>" , fn <EOL> tree = dr . parse_file ( fn , debug = True ) <EOL> if diff ( fn , tree ) : <EOL> problems . append ( fn ) <EOL> for dir in sys . path : <EOL> try : <EOL> names = os . listdir ( dir ) <EOL> except os . error : <EOL> continue <EOL> print >> sys . stderr , "<STR_LIT>" , dir , "<STR_LIT>" <EOL> for name in names : <EOL> if not name . endswith ( "<STR_LIT>" ) : <EOL> continue <EOL> print >> sys . stderr , "<STR_LIT>" , name <EOL> fn = os . path . join ( dir , name ) <EOL> try : <EOL> tree = dr . parse_file ( fn , debug = True ) <EOL> except pgen2 . parse . ParseError , err : <EOL> print "<STR_LIT>" , err <EOL> else : <EOL> if diff ( fn , tree ) : <EOL> problems . append ( fn ) <EOL> if not problems : <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" <EOL> for fn in problems : <EOL> print "<STR_LIT>" , fn <EOL> def diff ( fn , tree ) : <EOL> f = open ( "<STR_LIT:@>" , "<STR_LIT:w>" ) <EOL> try : <EOL> f . write ( str ( tree ) ) <EOL> finally : <EOL> f . close ( ) <EOL> try : <EOL> return os . system ( "<STR_LIT>" % fn ) <EOL> finally : <EOL> os . remove ( "<STR_LIT:@>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
