Package google :: Package protobuf :: Module symbol_database :: Class SymbolDatabase
[hide private]
[frames] | no frames]

Class SymbolDatabase

source code

                    object --+    
                             |    
message_factory.MessageFactory --+
                                 |
                                SymbolDatabase

A database of Python generated symbols.

Instance Methods [hide private]
 
RegisterMessage(self, message)
Registers the given message type in the local database.
source code
 
RegisterMessageDescriptor(self, message_descriptor)
Registers the given message descriptor in the local database.
source code
 
RegisterEnumDescriptor(self, enum_descriptor)
Registers the given enum descriptor in the local database.
source code
 
RegisterServiceDescriptor(self, service_descriptor)
Registers the given service descriptor in the local database.
source code
 
RegisterFileDescriptor(self, file_descriptor)
Registers the given file descriptor in the local database.
source code
 
GetSymbol(self, symbol)
Tries to find a symbol in the local database.
source code
 
GetMessages(self, files)
Gets all registered messages from a specified file.
source code

Inherited from message_factory.MessageFactory: GetPrototype, __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

RegisterMessage(self, message)

source code 
Registers the given message type in the local database.

Calls to GetSymbol() and GetMessages() will return messages registered here.

Args:
  message: a message.Message, to be registered.

Returns:
  The provided message.

RegisterMessageDescriptor(self, message_descriptor)

source code 
Registers the given message descriptor in the local database.

Args:
  message_descriptor: a descriptor.MessageDescriptor.

RegisterEnumDescriptor(self, enum_descriptor)

source code 
Registers the given enum descriptor in the local database.

Args:
  enum_descriptor: a descriptor.EnumDescriptor.

Returns:
  The provided descriptor.

RegisterServiceDescriptor(self, service_descriptor)

source code 
Registers the given service descriptor in the local database.

Args:
  service_descriptor: a descriptor.ServiceDescriptor.

Returns:
  The provided descriptor.

RegisterFileDescriptor(self, file_descriptor)

source code 
Registers the given file descriptor in the local database.

Args:
  file_descriptor: a descriptor.FileDescriptor.

Returns:
  The provided descriptor.

GetSymbol(self, symbol)

source code 
Tries to find a symbol in the local database.

Currently, this method only returns message.Message instances, however, if
may be extended in future to support other symbol types.

Args:
  symbol: A str, a protocol buffer symbol.

Returns:
  A Python class corresponding to the symbol.

Raises:
  KeyError: if the symbol could not be found.

GetMessages(self, files)

source code 
Gets all registered messages from a specified file.

Only messages already created and registered will be returned; (this is the
case for imported _pb2 modules)
But unlike MessageFactory, this version also returns already defined nested
messages, but does not register any message extensions.

Args:
  files: The file names to extract messages from.

Returns:
  A dictionary mapping proto names to the message classes.

Raises:
  KeyError: if a file could not be found.

Overrides: message_factory.MessageFactory.GetMessages