<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import re <EOL> _BASE_REGEX_STRING = '<STR_LIT>' <EOL> _PROVIDE_REGEX = re . compile ( _BASE_REGEX_STRING % '<STR_LIT>' ) <EOL> _REQUIRES_REGEX = re . compile ( _BASE_REGEX_STRING % '<STR_LIT>' ) <EOL> _GOOG_BASE_LINE = ( <EOL> '<STR_LIT>' ) <EOL> class Source ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , source ) : <EOL> """<STR_LIT>""" <EOL> self . provides = set ( ) <EOL> self . requires = set ( ) <EOL> self . _source = source <EOL> self . _ScanSource ( ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % self . _path <EOL> def GetSource ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _source <EOL> def _ScanSource ( self ) : <EOL> """<STR_LIT>""" <EOL> source = self . GetSource ( ) <EOL> source_lines = source . splitlines ( ) <EOL> for line in source_lines : <EOL> match = _PROVIDE_REGEX . match ( line ) <EOL> if match : <EOL> self . provides . add ( match . group ( <NUM_LIT:1> ) ) <EOL> match = _REQUIRES_REGEX . match ( line ) <EOL> if match : <EOL> self . requires . add ( match . group ( <NUM_LIT:1> ) ) <EOL> for line in source_lines : <EOL> if line == _GOOG_BASE_LINE : <EOL> if len ( self . provides ) or len ( self . requires ) : <EOL> raise Exception ( <EOL> '<STR_LIT>' ) <EOL> self . provides . add ( '<STR_LIT>' ) <EOL> def GetFileContents ( path ) : <EOL> """<STR_LIT>""" <EOL> fileobj = open ( path ) <EOL> try : <EOL> return fileobj . read ( ) <EOL> finally : <EOL> fileobj . close ( ) </s>
