<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Error ( Exception ) : <EOL> pass <EOL> class DescriptorDatabaseConflictingDefinitionError ( Error ) : <EOL> """<STR_LIT>""" <EOL> class DescriptorDatabase ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _file_desc_protos_by_file = { } <EOL> self . _file_desc_protos_by_symbol = { } <EOL> def Add ( self , file_desc_proto ) : <EOL> """<STR_LIT>""" <EOL> proto_name = file_desc_proto . name <EOL> if proto_name not in self . _file_desc_protos_by_file : <EOL> self . _file_desc_protos_by_file [ proto_name ] = file_desc_proto <EOL> elif self . _file_desc_protos_by_file [ proto_name ] != file_desc_proto : <EOL> raise DescriptorDatabaseConflictingDefinitionError ( <EOL> '<STR_LIT>' % proto_name ) <EOL> package = file_desc_proto . package <EOL> for message in file_desc_proto . message_type : <EOL> self . _file_desc_protos_by_symbol . update ( <EOL> ( name , file_desc_proto ) for name in _ExtractSymbols ( message , package ) ) <EOL> for enum in file_desc_proto . enum_type : <EOL> self . _file_desc_protos_by_symbol [ <EOL> '<STR_LIT:.>' . join ( ( package , enum . name ) ) ] = file_desc_proto <EOL> def FindFileByName ( self , name ) : <EOL> """<STR_LIT>""" <EOL> return self . _file_desc_protos_by_file [ name ] <EOL> def FindFileContainingSymbol ( self , symbol ) : <EOL> """<STR_LIT>""" <EOL> return self . _file_desc_protos_by_symbol [ symbol ] <EOL> def _ExtractSymbols ( desc_proto , package ) : <EOL> """<STR_LIT>""" <EOL> message_name = '<STR_LIT:.>' . join ( ( package , desc_proto . name ) ) <EOL> yield message_name <EOL> for nested_type in desc_proto . nested_type : <EOL> for symbol in _ExtractSymbols ( nested_type , message_name ) : <EOL> yield symbol <EOL> for enum_type in desc_proto . enum_type : <EOL> yield '<STR_LIT:.>' . join ( ( message_name , enum_type . name ) ) </s>
