def _ConvertFileProtoToFileDescriptor(self, file_proto):
if file_proto.name not in self._file_descriptors:<EOL><INDENT>built_deps = list(self._GetDeps(file_proto.dependency))<EOL>direct_deps = [self.FindFileByName(n) for n in file_proto.dependency]<EOL>public_deps = [direct_deps[i] for i in file_proto.public_dependency]<EOL>file_descriptor = descriptor.FileDescriptor(<EOL>pool=self,<EOL>name=file_proto.name,<EOL>package=file_proto.package,<EOL>syntax=file_proto.syntax,<EOL>options=file_proto.options,<EOL>serialized_pb=file_proto.SerializeToString(),<EOL>dependencies=direct_deps,<EOL>public_dependencies=public_deps)<EOL>if _USE_C_DESCRIPTORS:<EOL><INDENT>def _AddMessageDescriptor(message_desc):<EOL><INDENT>self._descriptors[message_desc.full_name] = message_desc<EOL>for nested in message_desc.nested_types:<EOL><INDENT>_AddMessageDescriptor(nested)<EOL><DEDENT>for enum_type in message_desc.enum_types:<EOL><INDENT>_AddEnumDescriptor(enum_type)<EOL><DEDENT><DEDENT>def _AddEnumDescriptor(enum_desc):<EOL><INDENT>self._enum_descriptors[enum_desc.full_name] = enum_desc<EOL><DEDENT>for message_type in file_descriptor.message_types_by_name.values():<EOL><INDENT>_AddMessageDescriptor(message_type)<EOL><DEDENT>for enum_type in file_descriptor.enum_types_by_name.values():<EOL><INDENT>_AddEnumDescriptor(enum_type)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>scope = {}<EOL>for dependency in built_deps:<EOL><INDENT>scope.update(self._ExtractSymbols(<EOL>dependency.message_types_by_name.values()))<EOL>scope.update((_PrefixWithDot(enum.full_name), enum)<EOL>for enum in dependency.enum_types_by_name.values())<EOL><DEDENT>for message_type in file_proto.message_type:<EOL><INDENT>message_desc = self._ConvertMessageDescriptor(<EOL>message_type, file_proto.package, file_descriptor, scope,<EOL>file_proto.syntax)<EOL>file_descriptor.message_types_by_name[message_desc.name] = (<EOL>message_desc)<EOL><DEDENT>for enum_type in file_proto.enum_type:<EOL><INDENT>file_descriptor.enum_types_by_name[enum_type.name] = (<EOL>self._ConvertEnumDescriptor(enum_type, file_proto.package,<EOL>file_descriptor, None, scope))<EOL><DEDENT>for index, extension_proto in enumerate(file_proto.extension):<EOL><INDENT>extension_desc = self._MakeFieldDescriptor(<EOL>extension_proto, file_proto.package, index, is_extension=True)<EOL>extension_desc.containing_type = self._GetTypeFromScope(<EOL>file_descriptor.package, extension_proto.extendee, scope)<EOL>self._SetFieldType(extension_proto, extension_desc,<EOL>file_descriptor.package, scope)<EOL>file_descriptor.extensions_by_name[extension_desc.name] = (<EOL>extension_desc)<EOL><DEDENT>for desc_proto in file_proto.message_type:<EOL><INDENT>self._SetAllFieldTypes(file_proto.package, desc_proto, scope)<EOL><DEDENT>if file_proto.package:<EOL><INDENT>desc_proto_prefix = _PrefixWithDot(file_proto.package)<EOL><DEDENT>else:<EOL><INDENT>desc_proto_prefix = '<STR_LIT>'<EOL><DEDENT>for desc_proto in file_proto.message_type:<EOL><INDENT>desc = self._GetTypeFromScope(<EOL>desc_proto_prefix, desc_proto.name, scope)<EOL>file_descriptor.message_types_by_name[desc_proto.name] = desc<EOL><DEDENT><DEDENT>self.Add(file_proto)<EOL>self._file_descriptors[file_proto.name] = file_descriptor<EOL><DEDENT>return self._file_descriptors[file_proto.name]<EOL>
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.