parameters: (self, file_proto)
return_statement: return self._file_descriptors[file_proto.name]
docstring: Creates a FileDescriptor from a proto or returns a cached copy.
  
      This method also has the side effect of loading all the symbols found in
      the file into the appropriate dictionaries in the pool.
  
      Args:
        file_proto: The proto to convert.
  
      Returns:
        A FileDescriptor matching the passed in proto.
docstring_summary: Creates a FileDescriptor from a proto or returns a cached copy.
docstring_tokens: Creates a FileDescriptor from a proto or returns a cached copy .
function: def _ConvertFileProtoToFileDescriptor(self, file_proto):
      """Creates a FileDescriptor from a proto or returns a cached copy.
  
      This method also has the side effect of loading all the symbols found in
      the file into the appropriate dictionaries in the pool.
  
      Args:
        file_proto: The proto to convert.
  
      Returns:
        A FileDescriptor matching the passed in proto.
      """
  
      if file_proto.name not in self._file_descriptors:
        built_deps = list(self._GetDeps(file_proto.dependency))
        direct_deps = [self.FindFileByName(n) for n in file_proto.dependency]
        public_deps = [direct_deps[i] for i in file_proto.public_dependency]
  
        file_descriptor = descriptor.FileDescriptor(
            pool=self,
            name=file_proto.name,
            package=file_proto.package,
            syntax=file_proto.syntax,
            options=file_proto.options,
            serialized_pb=file_proto.SerializeToString(),
            dependencies=direct_deps,
            public_dependencies=public_deps)
        if _USE_C_DESCRIPTORS:
          # When using C++ descriptors, all objects defined in the file were added
          # to the C++ database when the FileDescriptor was built above.
          # Just add them to this descriptor pool.
          def _AddMessageDescriptor(message_desc):
            self._descriptors[message_desc.full_name] = message_desc
            for nested in message_desc.nested_types:
              _AddMessageDescriptor(nested)
            for enum_type in message_desc.enum_types:
              _AddEnumDescriptor(enum_type)
          def _AddEnumDescriptor(enum_desc):
            self._enum_descriptors[enum_desc.full_name] = enum_desc
          for message_type in file_descriptor.message_types_by_name.values():
            _AddMessageDescriptor(message_type)
          for enum_type in file_descriptor.enum_types_by_name.values():
            _AddEnumDescriptor(enum_type)
        else:
          scope = {}
  
          # This loop extracts all the message and enum types from all the
          # dependencies of the file_proto. This is necessary to create the
          # scope of available message types when defining the passed in
          # file proto.
          for dependency in built_deps:
            scope.update(self._ExtractSymbols(
                dependency.message_types_by_name.values()))
            scope.update((_PrefixWithDot(enum.full_name), enum)
                         for enum in dependency.enum_types_by_name.values())
  
          for message_type in file_proto.message_type:
            message_desc = self._ConvertMessageDescriptor(
                message_type, file_proto.package, file_descriptor, scope,
                file_proto.syntax)
            file_descriptor.message_types_by_name[message_desc.name] = (
                message_desc)
  
          for enum_type in file_proto.enum_type:
            file_descriptor.enum_types_by_name[enum_type.name] = (
                self._ConvertEnumDescriptor(enum_type, file_proto.package,
                                            file_descriptor, None, scope))
  
          for index, extension_proto in enumerate(file_proto.extension):
            extension_desc = self._MakeFieldDescriptor(
                extension_proto, file_proto.package, index, is_extension=True)
            extension_desc.containing_type = self._GetTypeFromScope(
                file_descriptor.package, extension_proto.extendee, scope)
            self._SetFieldType(extension_proto, extension_desc,
                              file_descriptor.package, scope)
            file_descriptor.extensions_by_name[extension_desc.name] = (
                extension_desc)
  
          for desc_proto in file_proto.message_type:
            self._SetAllFieldTypes(file_proto.package, desc_proto, scope)
  
          if file_proto.package:
            desc_proto_prefix = _PrefixWithDot(file_proto.package)
          else:
            desc_proto_prefix = ''
  
          for desc_proto in file_proto.message_type:
            desc = self._GetTypeFromScope(
                desc_proto_prefix, desc_proto.name, scope)
            file_descriptor.message_types_by_name[desc_proto.name] = desc
  
          for index, service_proto in enumerate(file_proto.service):
            file_descriptor.services_by_name[service_proto.name] = (
                self._MakeServiceDescriptor(service_proto, index, scope,
                                            file_proto.package, file_descriptor))
  
        self.Add(file_proto)
        self._file_descriptors[file_proto.name] = file_descriptor
  
      return self._file_descriptors[file_proto.name]
function_tokens: def _ConvertFileProtoToFileDescriptor ( self , file_proto ) : if file_proto . name not in self . _file_descriptors : built_deps = list ( self . _GetDeps ( file_proto . dependency ) ) direct_deps = [ self . FindFileByName ( n ) for n in file_proto . dependency ] public_deps = [ direct_deps [ i ] for i in file_proto . public_dependency ] file_descriptor = descriptor . FileDescriptor ( pool = self , name = file_proto . name , package = file_proto . package , syntax = file_proto . syntax , options = file_proto . options , serialized_pb = file_proto . SerializeToString ( ) , dependencies = direct_deps , public_dependencies = public_deps ) if _USE_C_DESCRIPTORS : # When using C++ descriptors, all objects defined in the file were added # to the C++ database when the FileDescriptor was built above. # Just add them to this descriptor pool. def _AddMessageDescriptor ( message_desc ) : self . _descriptors [ message_desc . full_name ] = message_desc for nested in message_desc . nested_types : _AddMessageDescriptor ( nested ) for enum_type in message_desc . enum_types : _AddEnumDescriptor ( enum_type ) def _AddEnumDescriptor ( enum_desc ) : self . _enum_descriptors [ enum_desc . full_name ] = enum_desc for message_type in file_descriptor . message_types_by_name . values ( ) : _AddMessageDescriptor ( message_type ) for enum_type in file_descriptor . enum_types_by_name . values ( ) : _AddEnumDescriptor ( enum_type ) else : scope = { } # This loop extracts all the message and enum types from all the # dependencies of the file_proto. This is necessary to create the # scope of available message types when defining the passed in # file proto. for dependency in built_deps : scope . update ( self . _ExtractSymbols ( dependency . message_types_by_name . values ( ) ) ) scope . update ( ( _PrefixWithDot ( enum . full_name ) , enum ) for enum in dependency . enum_types_by_name . values ( ) ) for message_type in file_proto . message_type : message_desc = self . _ConvertMessageDescriptor ( message_type , file_proto . package , file_descriptor , scope , file_proto . syntax ) file_descriptor . message_types_by_name [ message_desc . name ] = ( message_desc ) for enum_type in file_proto . enum_type : file_descriptor . enum_types_by_name [ enum_type . name ] = ( self . _ConvertEnumDescriptor ( enum_type , file_proto . package , file_descriptor , None , scope ) ) for index , extension_proto in enumerate ( file_proto . extension ) : extension_desc = self . _MakeFieldDescriptor ( extension_proto , file_proto . package , index , is_extension = True ) extension_desc . containing_type = self . _GetTypeFromScope ( file_descriptor . package , extension_proto . extendee , scope ) self . _SetFieldType ( extension_proto , extension_desc , file_descriptor . package , scope ) file_descriptor . extensions_by_name [ extension_desc . name ] = ( extension_desc ) for desc_proto in file_proto . message_type : self . _SetAllFieldTypes ( file_proto . package , desc_proto , scope ) if file_proto . package : desc_proto_prefix = _PrefixWithDot ( file_proto . package ) else : desc_proto_prefix = '' for desc_proto in file_proto . message_type : desc = self . _GetTypeFromScope ( desc_proto_prefix , desc_proto . name , scope ) file_descriptor . message_types_by_name [ desc_proto . name ] = desc for index , service_proto in enumerate ( file_proto . service ) : file_descriptor . services_by_name [ service_proto . name ] = ( self . _MakeServiceDescriptor ( service_proto , index , scope , file_proto . package , file_descriptor ) ) self . Add ( file_proto ) self . _file_descriptors [ file_proto . name ] = file_descriptor return self . _file_descriptors [ file_proto . name ]