def MakeClass(descriptor):
  """Construct a class object for a protobuf described by descriptor.

  DEPRECATED: use MessageFactory.GetPrototype() instead.

  Args:
    descriptor: A descriptor.Descriptor object describing the protobuf.
  Returns:
    The Message class object described by the descriptor.
  """



  return symbol_database.Default().GetPrototype(descriptor)
def _InternalUnpackAny(msg):
  """Unpacks Any message and returns the unpacked message.

  This internal method is different from public Any Unpack method which takes
  the target message as argument. _InternalUnpackAny method does not have
  target message type and need to find the message type in descriptor pool.

  Args:
    msg: An Any message to be unpacked.

  Returns:
    The unpacked message.
  """




  from google.net.proto2.python.public import symbol_database
  factory = symbol_database.Default()

  type_url = msg.type_url

  if not type_url:
    return None



  type_name = type_url.split('/')[-1]
  descriptor = factory.pool.FindMessageTypeByName(type_name)

  if descriptor is None:
    return None

  message_class = factory.GetPrototype(descriptor)
  message = message_class()

  message.ParseFromString(msg.value)
  return message
Beispiel #3
0
def _BuildMessageFromTypeName(type_name, descriptor_pool):
  """Returns a protobuf message instance.

  Args:
    type_name: Fully-qualified protobuf  message type name string.
    descriptor_pool: DescriptorPool instance.

  Returns:
    A Message instance of type matching type_name, or None if the a Descriptor
    wasn't found matching type_name.
  """

  if descriptor_pool is None:
    from google.net.proto2.python.public import descriptor_pool as pool_mod
    descriptor_pool = pool_mod.Default()
  from google.net.proto2.python.public import symbol_database
  database = symbol_database.Default()
  try:
    message_descriptor = descriptor_pool.FindMessageTypeByName(type_name)
  except KeyError:
    return None
  message_type = database.GetPrototype(message_descriptor)
  return message_type()
Beispiel #4
0
  __import__('google.net.rpc.python.proto_python_api_2_stub')
  __import__('google.net.rpc.python.pywraprpc')
  proto_python_api_2_stub = sys.modules.get('google.net.rpc.python.proto_python_api_2_stub')
  pywraprpc = sys.modules.get('google.net.rpc.python.pywraprpc')
  _client_stub_base_class = proto_python_api_2_stub.Stub
except ImportError:
  _client_stub_base_class = object
try:
  __import__('google.net.rpc.python.rpcserver')
  rpcserver = sys.modules.get('google.net.rpc.python.rpcserver')
  _server_stub_base_class = rpcserver.BaseRpcServer
except ImportError:
  _server_stub_base_class = object


_sym_db = _symbol_database.Default()


from google.appengine.api import api_base_pb2 as google_dot_apphosting_dot_api_dot_api__base__pb2


DESCRIPTOR = _descriptor.FileDescriptor(
  name='apphosting/api/blobstore/blobstore_stub_service.proto',
  package='apphosting',
  syntax='proto2',
  serialized_options=_b('\n\"com.google.appengine.api.blobstoreB\026BlobstoreStubServicePb'),
  serialized_pb=_b('\n5apphosting/api/blobstore/blobstore_stub_service.proto\x12\napphosting\x1a\x1d\x61pphosting/api/api_base.proto\"5\n\x10StoreBlobRequest\x12\x10\n\x08\x62lob_key\x18\x01 \x02(\t\x12\x0f\n\x07\x63ontent\x18\x02 \x01(\x0c\"\x89\x01\n\x19SetBlobStorageTypeRequest\x12G\n\x0cstorage_type\x18\x01 \x02(\x0e\x32\x31.apphosting.SetBlobStorageTypeRequest.StorageType\"#\n\x0bStorageType\x12\n\n\x06MEMORY\x10\x00\x12\x08\n\x04\x46ILE\x10\x01\x32\xba\x01\n\x14\x42lobstoreStubService\x12G\n\tStoreBlob\x12\x1c.apphosting.StoreBlobRequest\x1a\x1a.apphosting.base.VoidProto\"\x00\x12Y\n\x12SetBlobStorageType\x12%.apphosting.SetBlobStorageTypeRequest\x1a\x1a.apphosting.base.VoidProto\"\x00\x42<\n\"com.google.appengine.api.blobstoreB\x16\x42lobstoreStubServicePb')
  ,
  dependencies=[google_dot_apphosting_dot_api_dot_api__base__pb2.DESCRIPTOR,])

Beispiel #5
0
def _InternalConstructMessage(full_name):
    """Constructs a nested message."""
    from google.net.proto2.python.public import symbol_database

    return symbol_database.Default().GetSymbol(full_name)()