| Index: third_party/protobuf/python/google/protobuf/descriptor_database.py
|
| diff --git a/third_party/protobuf/python/google/protobuf/descriptor_database.py b/third_party/protobuf/python/google/protobuf/descriptor_database.py
|
| index 8665d3c59d0a9d631c3f28d07fc3df8d3a87aa68..b10021e98a9c39b512cd40dbaa1bf26ca4d782f3 100644
|
| --- a/third_party/protobuf/python/google/protobuf/descriptor_database.py
|
| +++ b/third_party/protobuf/python/google/protobuf/descriptor_database.py
|
| @@ -1,6 +1,6 @@
|
| # Protocol Buffers - Google's data interchange format
|
| # Copyright 2008 Google Inc. All rights reserved.
|
| -# http://code.google.com/p/protobuf/
|
| +# https://developers.google.com/protocol-buffers/
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -33,6 +33,14 @@
|
| __author__ = 'matthewtoia@google.com (Matt Toia)'
|
|
|
|
|
| +class Error(Exception):
|
| + pass
|
| +
|
| +
|
| +class DescriptorDatabaseConflictingDefinitionError(Error):
|
| + """Raised when a proto is added with the same name & different descriptor."""
|
| +
|
| +
|
| class DescriptorDatabase(object):
|
| """A container accepting FileDescriptorProtos and maps DescriptorProtos."""
|
|
|
| @@ -45,9 +53,18 @@ class DescriptorDatabase(object):
|
|
|
| Args:
|
| file_desc_proto: The FileDescriptorProto to add.
|
| + Raises:
|
| + DescriptorDatabaseException: if an attempt is made to add a proto
|
| + with the same name but different definition than an exisiting
|
| + proto in the database.
|
| """
|
| + proto_name = file_desc_proto.name
|
| + if proto_name not in self._file_desc_protos_by_file:
|
| + self._file_desc_protos_by_file[proto_name] = file_desc_proto
|
| + elif self._file_desc_protos_by_file[proto_name] != file_desc_proto:
|
| + raise DescriptorDatabaseConflictingDefinitionError(
|
| + '%s already added, but with different descriptor.' % proto_name)
|
|
|
| - self._file_desc_protos_by_file[file_desc_proto.name] = file_desc_proto
|
| package = file_desc_proto.package
|
| for message in file_desc_proto.message_type:
|
| self._file_desc_protos_by_symbol.update(
|
| @@ -116,5 +133,5 @@ def _ExtractSymbols(desc_proto, package):
|
| for nested_type in desc_proto.nested_type:
|
| for symbol in _ExtractSymbols(nested_type, message_name):
|
| yield symbol
|
| - for enum_type in desc_proto.enum_type:
|
| - yield '.'.join((message_name, enum_type.name))
|
| + for enum_type in desc_proto.enum_type:
|
| + yield '.'.join((message_name, enum_type.name))
|
|
|