Module uim.codec.format.WILL_2_0_0_pb2

Generated protocol buffer code.

Expand source code
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: will-message-format.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()




DESCRIPTOR = _descriptor.FileDescriptor(
  name='will-message-format.proto',
  package='WacomInkFormat',
  syntax='proto2',
  serialized_options=b'H\003',
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n\x19will-message-format.proto\x12\x0eWacomInkFormat\"\xef\x02\n\x0eParticlesPaint\x12\r\n\x05shape\x18\x01 \x03(\x0c\x12\x12\n\x07spacing\x18\x02 \x01(\x02:\x01\x32\x12\x15\n\nscattering\x18\x03 \x01(\x02:\x01\x30\x12?\n\x08rotation\x18\x04 \x01(\x0e\x32\'.WacomInkFormat.ParticlesPaint.Rotation:\x04NONE\x12\x0c\n\x04\x66ill\x18\x05 \x03(\x0c\x12\x14\n\tfillWidth\x18\x06 \x01(\x02:\x01\x34\x12\x15\n\nfillHeight\x18\x07 \x01(\x02:\x01\x34\x12\x1c\n\rrandomizeFill\x18\x08 \x01(\x08:\x05\x66\x61lse\x12K\n\x12\x63ompositeOperation\x18\t \x01(\x0e\x32\".WacomInkFormat.CompositeOperation:\x0bSOURCE_OVER\x12\n\n\x02id\x18\x64 \x01(\r\"0\n\x08Rotation\x12\x08\n\x04NONE\x10\x00\x12\n\n\x06RANDOM\x10\x01\x12\x0e\n\nTRAJECTORY\x10\x02\"\xac\x02\n\x04Path\x12\x19\n\x0estartParameter\x18\x01 \x01(\x02:\x01\x30\x12\x17\n\x0c\x65ndParameter\x18\x02 \x01(\x02:\x01\x31\x12\x1b\n\x10\x64\x65\x63imalPrecision\x18\x03 \x01(\r:\x01\x32\x12\x10\n\x04\x64\x61ta\x18\x04 \x03(\x11\x42\x02\x10\x01\x12\x17\n\x0bstrokeWidth\x18\x05 \x03(\x11\x42\x02\x10\x01\x12\x17\n\x0bstrokeColor\x18\x06 \x03(\x11\x42\x02\x10\x01\x12\x13\n\x0bstrokePaint\x18\x07 \x01(\r\x12!\n\x19strokeParticlesRandomSeed\x18\x08 \x01(\r\x12K\n\x12\x63ompositeOperation\x18\t \x01(\x0e\x32\".WacomInkFormat.CompositeOperation:\x0bSOURCE_OVER\x12\n\n\x02id\x18\x64 \x01(\r*\xfa\x01\n\x12\x43ompositeOperation\x12\x08\n\x04\x43OPY\x10\x01\x12\x0f\n\x0bSOURCE_OVER\x10\x02\x12\x14\n\x10\x44\x45STINATION_OVER\x10\x03\x12\x13\n\x0f\x44\x45STINATION_OUT\x10\x07\x12\x0b\n\x07LIGHTER\x10\x0b\x12\x13\n\x0f\x44IRECT_MULTIPLY\x10\x0c\x12!\n\x1d\x44IRECT_INVERT_SOURCE_MULTIPLY\x10\r\x12\x11\n\rDIRECT_DARKEN\x10\x0e\x12\x12\n\x0e\x44IRECT_LIGHTEN\x10\x0f\x12\x14\n\x10\x44IRECT_SUBSTRACT\x10\x10\x12\x1c\n\x18\x44IRECT_REVERSE_SUBSTRACT\x10\x11\x42\x02H\x03'
)

_COMPOSITEOPERATION = _descriptor.EnumDescriptor(
  name='CompositeOperation',
  full_name='WacomInkFormat.CompositeOperation',
  filename=None,
  file=DESCRIPTOR,
  create_key=_descriptor._internal_create_key,
  values=[
    _descriptor.EnumValueDescriptor(
      name='COPY', index=0, number=1,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='SOURCE_OVER', index=1, number=2,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DESTINATION_OVER', index=2, number=3,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DESTINATION_OUT', index=3, number=7,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='LIGHTER', index=4, number=11,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_MULTIPLY', index=5, number=12,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_INVERT_SOURCE_MULTIPLY', index=6, number=13,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_DARKEN', index=7, number=14,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_LIGHTEN', index=8, number=15,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_SUBSTRACT', index=9, number=16,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='DIRECT_REVERSE_SUBSTRACT', index=10, number=17,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=719,
  serialized_end=969,
)
_sym_db.RegisterEnumDescriptor(_COMPOSITEOPERATION)

CompositeOperation = enum_type_wrapper.EnumTypeWrapper(_COMPOSITEOPERATION)
COPY = 1
SOURCE_OVER = 2
DESTINATION_OVER = 3
DESTINATION_OUT = 7
LIGHTER = 11
DIRECT_MULTIPLY = 12
DIRECT_INVERT_SOURCE_MULTIPLY = 13
DIRECT_DARKEN = 14
DIRECT_LIGHTEN = 15
DIRECT_SUBSTRACT = 16
DIRECT_REVERSE_SUBSTRACT = 17


_PARTICLESPAINT_ROTATION = _descriptor.EnumDescriptor(
  name='Rotation',
  full_name='WacomInkFormat.ParticlesPaint.Rotation',
  filename=None,
  file=DESCRIPTOR,
  create_key=_descriptor._internal_create_key,
  values=[
    _descriptor.EnumValueDescriptor(
      name='NONE', index=0, number=0,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='RANDOM', index=1, number=1,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='TRAJECTORY', index=2, number=2,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=365,
  serialized_end=413,
)
_sym_db.RegisterEnumDescriptor(_PARTICLESPAINT_ROTATION)


_PARTICLESPAINT = _descriptor.Descriptor(
  name='ParticlesPaint',
  full_name='WacomInkFormat.ParticlesPaint',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='shape', full_name='WacomInkFormat.ParticlesPaint.shape', index=0,
      number=1, type=12, cpp_type=9, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='spacing', full_name='WacomInkFormat.ParticlesPaint.spacing', index=1,
      number=2, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(2),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='scattering', full_name='WacomInkFormat.ParticlesPaint.scattering', index=2,
      number=3, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(0),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='rotation', full_name='WacomInkFormat.ParticlesPaint.rotation', index=3,
      number=4, type=14, cpp_type=8, label=1,
      has_default_value=True, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='fill', full_name='WacomInkFormat.ParticlesPaint.fill', index=4,
      number=5, type=12, cpp_type=9, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='fillWidth', full_name='WacomInkFormat.ParticlesPaint.fillWidth', index=5,
      number=6, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(4),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='fillHeight', full_name='WacomInkFormat.ParticlesPaint.fillHeight', index=6,
      number=7, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(4),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='randomizeFill', full_name='WacomInkFormat.ParticlesPaint.randomizeFill', index=7,
      number=8, type=8, cpp_type=7, label=1,
      has_default_value=True, default_value=False,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='compositeOperation', full_name='WacomInkFormat.ParticlesPaint.compositeOperation', index=8,
      number=9, type=14, cpp_type=8, label=1,
      has_default_value=True, default_value=2,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='id', full_name='WacomInkFormat.ParticlesPaint.id', index=9,
      number=100, type=13, cpp_type=3, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
    _PARTICLESPAINT_ROTATION,
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto2',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=46,
  serialized_end=413,
)


_PATH = _descriptor.Descriptor(
  name='Path',
  full_name='WacomInkFormat.Path',
  filename=None,
  file=DESCRIPTOR,
  containing_type=None,
  create_key=_descriptor._internal_create_key,
  fields=[
    _descriptor.FieldDescriptor(
      name='startParameter', full_name='WacomInkFormat.Path.startParameter', index=0,
      number=1, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(0),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='endParameter', full_name='WacomInkFormat.Path.endParameter', index=1,
      number=2, type=2, cpp_type=6, label=1,
      has_default_value=True, default_value=float(1),
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='decimalPrecision', full_name='WacomInkFormat.Path.decimalPrecision', index=2,
      number=3, type=13, cpp_type=3, label=1,
      has_default_value=True, default_value=2,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='data', full_name='WacomInkFormat.Path.data', index=3,
      number=4, type=17, cpp_type=1, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\020\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='strokeWidth', full_name='WacomInkFormat.Path.strokeWidth', index=4,
      number=5, type=17, cpp_type=1, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\020\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='strokeColor', full_name='WacomInkFormat.Path.strokeColor', index=5,
      number=6, type=17, cpp_type=1, label=3,
      has_default_value=False, default_value=[],
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=b'\020\001', file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='strokePaint', full_name='WacomInkFormat.Path.strokePaint', index=6,
      number=7, type=13, cpp_type=3, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='strokeParticlesRandomSeed', full_name='WacomInkFormat.Path.strokeParticlesRandomSeed', index=7,
      number=8, type=13, cpp_type=3, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='compositeOperation', full_name='WacomInkFormat.Path.compositeOperation', index=8,
      number=9, type=14, cpp_type=8, label=1,
      has_default_value=True, default_value=2,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
    _descriptor.FieldDescriptor(
      name='id', full_name='WacomInkFormat.Path.id', index=9,
      number=100, type=13, cpp_type=3, label=1,
      has_default_value=False, default_value=0,
      message_type=None, enum_type=None, containing_type=None,
      is_extension=False, extension_scope=None,
      serialized_options=None, file=DESCRIPTOR,  create_key=_descriptor._internal_create_key),
  ],
  extensions=[
  ],
  nested_types=[],
  enum_types=[
  ],
  serialized_options=None,
  is_extendable=False,
  syntax='proto2',
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=416,
  serialized_end=716,
)

_PARTICLESPAINT.fields_by_name['rotation'].enum_type = _PARTICLESPAINT_ROTATION
_PARTICLESPAINT.fields_by_name['compositeOperation'].enum_type = _COMPOSITEOPERATION
_PARTICLESPAINT_ROTATION.containing_type = _PARTICLESPAINT
_PATH.fields_by_name['compositeOperation'].enum_type = _COMPOSITEOPERATION
DESCRIPTOR.message_types_by_name['ParticlesPaint'] = _PARTICLESPAINT
DESCRIPTOR.message_types_by_name['Path'] = _PATH
DESCRIPTOR.enum_types_by_name['CompositeOperation'] = _COMPOSITEOPERATION
_sym_db.RegisterFileDescriptor(DESCRIPTOR)

ParticlesPaint = _reflection.GeneratedProtocolMessageType('ParticlesPaint', (_message.Message,), {
  'DESCRIPTOR' : _PARTICLESPAINT,
  '__module__' : 'will_message_format_pb2'
  # @@protoc_insertion_point(class_scope:WacomInkFormat.ParticlesPaint)
  })
_sym_db.RegisterMessage(ParticlesPaint)

Path = _reflection.GeneratedProtocolMessageType('Path', (_message.Message,), {
  'DESCRIPTOR' : _PATH,
  '__module__' : 'will_message_format_pb2'
  # @@protoc_insertion_point(class_scope:WacomInkFormat.Path)
  })
_sym_db.RegisterMessage(Path)


DESCRIPTOR._options = None
_PATH.fields_by_name['data']._options = None
_PATH.fields_by_name['strokeWidth']._options = None
_PATH.fields_by_name['strokeColor']._options = None
# @@protoc_insertion_point(module_scope)

Classes

class ParticlesPaint (**kwargs)

Abstract base class for protocol messages.

Protocol message classes are almost always generated by the protocol compiler. These generated types subclass Message and implement the methods shown below.

Ancestors

  • google.protobuf.message.Message

Class variables

var COMPOSITEOPERATION_FIELD_NUMBER
var DESCRIPTOR
var FILLHEIGHT_FIELD_NUMBER
var FILLWIDTH_FIELD_NUMBER
var FILL_FIELD_NUMBER
var ID_FIELD_NUMBER
var NONE
var RANDOM
var RANDOMIZEFILL_FIELD_NUMBER
var ROTATION_FIELD_NUMBER
var Rotation
var SCATTERING_FIELD_NUMBER
var SHAPE_FIELD_NUMBER
var SPACING_FIELD_NUMBER
var TRAJECTORY

Static methods

def FromString(s)
Expand source code
def FromString(s):
  message = cls()
  message.MergeFromString(s)
  return message
def RegisterExtension(extension_handle)
Expand source code
def RegisterExtension(extension_handle):
  extension_handle.containing_type = cls.DESCRIPTOR
  # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
  # pylint: disable=protected-access
  cls.DESCRIPTOR.file.pool._AddExtensionDescriptor(extension_handle)
  _AttachFieldHelpers(cls, extension_handle)

Instance variables

var compositeOperation

Getter for compositeOperation.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var fill

Getter for fill.

Expand source code
def getter(self):
  field_value = self._fields.get(field)
  if field_value is None:
    # Construct a new object to represent this field.
    field_value = field._default_constructor(self)

    # Atomically check if another thread has preempted us and, if not, swap
    # in the new object we just created.  If someone has preempted us, we
    # take that object and discard ours.
    # WARNING:  We are relying on setdefault() being atomic.  This is true
    #   in CPython but we haven't investigated others.  This warning appears
    #   in several other locations in this file.
    field_value = self._fields.setdefault(field, field_value)
  return field_value
var fillHeight

Getter for fillHeight.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var fillWidth

Getter for fillWidth.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var id

Getter for id.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var randomizeFill

Getter for randomizeFill.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var rotation

Getter for rotation.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var scattering

Getter for scattering.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var shape

Getter for shape.

Expand source code
def getter(self):
  field_value = self._fields.get(field)
  if field_value is None:
    # Construct a new object to represent this field.
    field_value = field._default_constructor(self)

    # Atomically check if another thread has preempted us and, if not, swap
    # in the new object we just created.  If someone has preempted us, we
    # take that object and discard ours.
    # WARNING:  We are relying on setdefault() being atomic.  This is true
    #   in CPython but we haven't investigated others.  This warning appears
    #   in several other locations in this file.
    field_value = self._fields.setdefault(field, field_value)
  return field_value
var spacing

Getter for spacing.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)

Methods

def ByteSize(self)
Expand source code
def ByteSize(self):
  if not self._cached_byte_size_dirty:
    return self._cached_byte_size

  size = 0
  descriptor = self.DESCRIPTOR
  if descriptor.GetOptions().map_entry:
    # Fields of map entry should always be serialized.
    size = descriptor.fields_by_name['key']._sizer(self.key)
    size += descriptor.fields_by_name['value']._sizer(self.value)
  else:
    for field_descriptor, field_value in self.ListFields():
      size += field_descriptor._sizer(field_value)
    for tag_bytes, value_bytes in self._unknown_fields:
      size += len(tag_bytes) + len(value_bytes)

  self._cached_byte_size = size
  self._cached_byte_size_dirty = False
  self._listener_for_children.dirty = False
  return size
def Clear(self)
Expand source code
def _Clear(self):
  # Clear fields.
  self._fields = {}
  self._unknown_fields = ()
  # pylint: disable=protected-access
  if self._unknown_field_set is not None:
    self._unknown_field_set._clear()
    self._unknown_field_set = None

  self._oneofs = {}
  self._Modified()
def ClearField(self, field_name)
Expand source code
def ClearField(self, field_name):
  try:
    field = message_descriptor.fields_by_name[field_name]
  except KeyError:
    try:
      field = message_descriptor.oneofs_by_name[field_name]
      if field in self._oneofs:
        field = self._oneofs[field]
      else:
        return
    except KeyError:
      raise ValueError('Protocol message %s has no "%s" field.' %
                       (message_descriptor.name, field_name))

  if field in self._fields:
    # To match the C++ implementation, we need to invalidate iterators
    # for map fields when ClearField() happens.
    if hasattr(self._fields[field], 'InvalidateIterators'):
      self._fields[field].InvalidateIterators()

    # Note:  If the field is a sub-message, its listener will still point
    #   at us.  That's fine, because the worst than can happen is that it
    #   will call _Modified() and invalidate our byte size.  Big deal.
    del self._fields[field]

    if self._oneofs.get(field.containing_oneof, None) is field:
      del self._oneofs[field.containing_oneof]

  # Always call _Modified() -- even if nothing was changed, this is
  # a mutating method, and thus calling it should cause the field to become
  # present in the parent message.
  self._Modified()
def DiscardUnknownFields(self)
Expand source code
def _DiscardUnknownFields(self):
  self._unknown_fields = []
  self._unknown_field_set = None      # pylint: disable=protected-access
  for field, value in self.ListFields():
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if _IsMapField(field):
        if _IsMessageMapField(field):
          for key in value:
            value[key].DiscardUnknownFields()
      elif field.label == _FieldDescriptor.LABEL_REPEATED:
        for sub_message in value:
          sub_message.DiscardUnknownFields()
      else:
        value.DiscardUnknownFields()
def FindInitializationErrors(self)

Finds required fields which are not initialized.

Returns

A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. "foo.bar[5].baz".

Expand source code
def FindInitializationErrors(self):
  """Finds required fields which are not initialized.

  Returns:
    A list of strings.  Each string is a path to an uninitialized field from
    the top-level message, e.g. "foo.bar[5].baz".
  """

  errors = []  # simplify things

  for field in required_fields:
    if not self.HasField(field.name):
      errors.append(field.name)

  for field, value in self.ListFields():
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if field.is_extension:
        name = '(%s)' % field.full_name
      else:
        name = field.name

      if _IsMapField(field):
        if _IsMessageMapField(field):
          for key in value:
            element = value[key]
            prefix = '%s[%s].' % (name, key)
            sub_errors = element.FindInitializationErrors()
            errors += [prefix + error for error in sub_errors]
        else:
          # ScalarMaps can't have any initialization errors.
          pass
      elif field.label == _FieldDescriptor.LABEL_REPEATED:
        for i in range(len(value)):
          element = value[i]
          prefix = '%s[%d].' % (name, i)
          sub_errors = element.FindInitializationErrors()
          errors += [prefix + error for error in sub_errors]
      else:
        prefix = name + '.'
        sub_errors = value.FindInitializationErrors()
        errors += [prefix + error for error in sub_errors]

  return errors
def HasField(self, field_name)
Expand source code
def HasField(self, field_name):
  try:
    field = hassable_fields[field_name]
  except KeyError:
    raise ValueError(error_msg % (message_descriptor.full_name, field_name))

  if isinstance(field, descriptor_mod.OneofDescriptor):
    try:
      return HasField(self, self._oneofs[field].name)
    except KeyError:
      return False
  else:
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      value = self._fields.get(field)
      return value is not None and value._is_present_in_parent
    else:
      return field in self._fields
def IsInitialized(self, errors=None)

Checks if all required fields of a message are set.

Args

errors
A list which, if provided, will be populated with the field paths of all missing required fields.

Returns

True iff the specified message has all required fields set.

Expand source code
def IsInitialized(self, errors=None):
  """Checks if all required fields of a message are set.

  Args:
    errors:  A list which, if provided, will be populated with the field
             paths of all missing required fields.

  Returns:
    True iff the specified message has all required fields set.
  """

  # Performance is critical so we avoid HasField() and ListFields().

  for field in required_fields:
    if (field not in self._fields or
        (field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE and
         not self._fields[field]._is_present_in_parent)):
      if errors is not None:
        errors.extend(self.FindInitializationErrors())
      return False

  for field, value in list(self._fields.items()):  # dict can change size!
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if field.label == _FieldDescriptor.LABEL_REPEATED:
        if (field.message_type.has_options and
            field.message_type.GetOptions().map_entry):
          continue
        for element in value:
          if not element.IsInitialized():
            if errors is not None:
              errors.extend(self.FindInitializationErrors())
            return False
      elif value._is_present_in_parent and not value.IsInitialized():
        if errors is not None:
          errors.extend(self.FindInitializationErrors())
        return False

  return True
def ListFields(self)
Expand source code
def ListFields(self):
  all_fields = [item for item in self._fields.items() if _IsPresent(item)]
  all_fields.sort(key = lambda item: item[0].number)
  return all_fields
def MergeFrom(self, msg)
Expand source code
def MergeFrom(self, msg):
  if not isinstance(msg, cls):
    raise TypeError(
        'Parameter to MergeFrom() must be instance of same class: '
        'expected %s got %s.' % (_FullyQualifiedClassName(cls),
                                 _FullyQualifiedClassName(msg.__class__)))

  assert msg is not self
  self._Modified()

  fields = self._fields

  for field, value in msg._fields.items():
    if field.label == LABEL_REPEATED:
      field_value = fields.get(field)
      if field_value is None:
        # Construct a new object to represent this field.
        field_value = field._default_constructor(self)
        fields[field] = field_value
      field_value.MergeFrom(value)
    elif field.cpp_type == CPPTYPE_MESSAGE:
      if value._is_present_in_parent:
        field_value = fields.get(field)
        if field_value is None:
          # Construct a new object to represent this field.
          field_value = field._default_constructor(self)
          fields[field] = field_value
        field_value.MergeFrom(value)
    else:
      self._fields[field] = value
      if field.containing_oneof:
        self._UpdateOneofState(field)

  if msg._unknown_fields:
    if not self._unknown_fields:
      self._unknown_fields = []
    self._unknown_fields.extend(msg._unknown_fields)
    # pylint: disable=protected-access
    if self._unknown_field_set is None:
      self._unknown_field_set = containers.UnknownFieldSet()
    self._unknown_field_set._extend(msg._unknown_field_set)
def MergeFromString(self, serialized)
Expand source code
def MergeFromString(self, serialized):
  serialized = memoryview(serialized)
  length = len(serialized)
  try:
    if self._InternalParse(serialized, 0, length) != length:
      # The only reason _InternalParse would return early is if it
      # encountered an end-group tag.
      raise message_mod.DecodeError('Unexpected end-group tag.')
  except (IndexError, TypeError):
    # Now ord(buf[p:p+1]) == ord('') gets TypeError.
    raise message_mod.DecodeError('Truncated message.')
  except struct.error as e:
    raise message_mod.DecodeError(e)
  return length   # Return this for legacy reasons.
def SerializePartialToString(self, **kwargs)
Expand source code
def SerializePartialToString(self, **kwargs):
  out = BytesIO()
  self._InternalSerialize(out.write, **kwargs)
  return out.getvalue()
def SerializeToString(self, **kwargs)
Expand source code
def SerializeToString(self, **kwargs):
  # Check if the message has all of its required fields set.
  if not self.IsInitialized():
    raise message_mod.EncodeError(
        'Message %s is missing required fields: %s' % (
        self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors())))
  return self.SerializePartialToString(**kwargs)
def SetInParent(self)

Sets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change.

Expand source code
def Modified(self):
  """Sets the _cached_byte_size_dirty bit to true,
  and propagates this to our listener iff this was a state change.
  """

  # Note:  Some callers check _cached_byte_size_dirty before calling
  #   _Modified() as an extra optimization.  So, if this method is ever
  #   changed such that it does stuff even when _cached_byte_size_dirty is
  #   already true, the callers need to be updated.
  if not self._cached_byte_size_dirty:
    self._cached_byte_size_dirty = True
    self._listener_for_children.dirty = True
    self._is_present_in_parent = True
    self._listener.Modified()
def UnknownFields(self)
Expand source code
def _UnknownFields(self):
  if self._unknown_field_set is None:  # pylint: disable=protected-access
    # pylint: disable=protected-access
    self._unknown_field_set = containers.UnknownFieldSet()
  return self._unknown_field_set    # pylint: disable=protected-access
def WhichOneof(self, oneof_name)

Returns the name of the currently set field inside a oneof, or None.

Expand source code
def WhichOneof(self, oneof_name):
  """Returns the name of the currently set field inside a oneof, or None."""
  try:
    field = message_descriptor.oneofs_by_name[oneof_name]
  except KeyError:
    raise ValueError(
        'Protocol message has no oneof "%s" field.' % oneof_name)

  nested_field = self._oneofs.get(field, None)
  if nested_field is not None and self.HasField(nested_field.name):
    return nested_field.name
  else:
    return None
class Path (**kwargs)

Abstract base class for protocol messages.

Protocol message classes are almost always generated by the protocol compiler. These generated types subclass Message and implement the methods shown below.

Ancestors

  • google.protobuf.message.Message

Class variables

var COMPOSITEOPERATION_FIELD_NUMBER
var DATA_FIELD_NUMBER
var DECIMALPRECISION_FIELD_NUMBER
var DESCRIPTOR
var ENDPARAMETER_FIELD_NUMBER
var ID_FIELD_NUMBER
var STARTPARAMETER_FIELD_NUMBER
var STROKECOLOR_FIELD_NUMBER
var STROKEPAINT_FIELD_NUMBER
var STROKEPARTICLESRANDOMSEED_FIELD_NUMBER
var STROKEWIDTH_FIELD_NUMBER

Static methods

def FromString(s)
Expand source code
def FromString(s):
  message = cls()
  message.MergeFromString(s)
  return message
def RegisterExtension(extension_handle)
Expand source code
def RegisterExtension(extension_handle):
  extension_handle.containing_type = cls.DESCRIPTOR
  # TODO(amauryfa): Use cls.MESSAGE_FACTORY.pool when available.
  # pylint: disable=protected-access
  cls.DESCRIPTOR.file.pool._AddExtensionDescriptor(extension_handle)
  _AttachFieldHelpers(cls, extension_handle)

Instance variables

var compositeOperation

Getter for compositeOperation.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var data

Getter for data.

Expand source code
def getter(self):
  field_value = self._fields.get(field)
  if field_value is None:
    # Construct a new object to represent this field.
    field_value = field._default_constructor(self)

    # Atomically check if another thread has preempted us and, if not, swap
    # in the new object we just created.  If someone has preempted us, we
    # take that object and discard ours.
    # WARNING:  We are relying on setdefault() being atomic.  This is true
    #   in CPython but we haven't investigated others.  This warning appears
    #   in several other locations in this file.
    field_value = self._fields.setdefault(field, field_value)
  return field_value
var decimalPrecision

Getter for decimalPrecision.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var endParameter

Getter for endParameter.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var id

Getter for id.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var startParameter

Getter for startParameter.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var strokeColor

Getter for strokeColor.

Expand source code
def getter(self):
  field_value = self._fields.get(field)
  if field_value is None:
    # Construct a new object to represent this field.
    field_value = field._default_constructor(self)

    # Atomically check if another thread has preempted us and, if not, swap
    # in the new object we just created.  If someone has preempted us, we
    # take that object and discard ours.
    # WARNING:  We are relying on setdefault() being atomic.  This is true
    #   in CPython but we haven't investigated others.  This warning appears
    #   in several other locations in this file.
    field_value = self._fields.setdefault(field, field_value)
  return field_value
var strokePaint

Getter for strokePaint.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var strokeParticlesRandomSeed

Getter for strokeParticlesRandomSeed.

Expand source code
def getter(self):
  # TODO(protobuf-team): This may be broken since there may not be
  # default_value.  Combine with has_default_value somehow.
  return self._fields.get(field, default_value)
var strokeWidth

Getter for strokeWidth.

Expand source code
def getter(self):
  field_value = self._fields.get(field)
  if field_value is None:
    # Construct a new object to represent this field.
    field_value = field._default_constructor(self)

    # Atomically check if another thread has preempted us and, if not, swap
    # in the new object we just created.  If someone has preempted us, we
    # take that object and discard ours.
    # WARNING:  We are relying on setdefault() being atomic.  This is true
    #   in CPython but we haven't investigated others.  This warning appears
    #   in several other locations in this file.
    field_value = self._fields.setdefault(field, field_value)
  return field_value

Methods

def ByteSize(self)
Expand source code
def ByteSize(self):
  if not self._cached_byte_size_dirty:
    return self._cached_byte_size

  size = 0
  descriptor = self.DESCRIPTOR
  if descriptor.GetOptions().map_entry:
    # Fields of map entry should always be serialized.
    size = descriptor.fields_by_name['key']._sizer(self.key)
    size += descriptor.fields_by_name['value']._sizer(self.value)
  else:
    for field_descriptor, field_value in self.ListFields():
      size += field_descriptor._sizer(field_value)
    for tag_bytes, value_bytes in self._unknown_fields:
      size += len(tag_bytes) + len(value_bytes)

  self._cached_byte_size = size
  self._cached_byte_size_dirty = False
  self._listener_for_children.dirty = False
  return size
def Clear(self)
Expand source code
def _Clear(self):
  # Clear fields.
  self._fields = {}
  self._unknown_fields = ()
  # pylint: disable=protected-access
  if self._unknown_field_set is not None:
    self._unknown_field_set._clear()
    self._unknown_field_set = None

  self._oneofs = {}
  self._Modified()
def ClearField(self, field_name)
Expand source code
def ClearField(self, field_name):
  try:
    field = message_descriptor.fields_by_name[field_name]
  except KeyError:
    try:
      field = message_descriptor.oneofs_by_name[field_name]
      if field in self._oneofs:
        field = self._oneofs[field]
      else:
        return
    except KeyError:
      raise ValueError('Protocol message %s has no "%s" field.' %
                       (message_descriptor.name, field_name))

  if field in self._fields:
    # To match the C++ implementation, we need to invalidate iterators
    # for map fields when ClearField() happens.
    if hasattr(self._fields[field], 'InvalidateIterators'):
      self._fields[field].InvalidateIterators()

    # Note:  If the field is a sub-message, its listener will still point
    #   at us.  That's fine, because the worst than can happen is that it
    #   will call _Modified() and invalidate our byte size.  Big deal.
    del self._fields[field]

    if self._oneofs.get(field.containing_oneof, None) is field:
      del self._oneofs[field.containing_oneof]

  # Always call _Modified() -- even if nothing was changed, this is
  # a mutating method, and thus calling it should cause the field to become
  # present in the parent message.
  self._Modified()
def DiscardUnknownFields(self)
Expand source code
def _DiscardUnknownFields(self):
  self._unknown_fields = []
  self._unknown_field_set = None      # pylint: disable=protected-access
  for field, value in self.ListFields():
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if _IsMapField(field):
        if _IsMessageMapField(field):
          for key in value:
            value[key].DiscardUnknownFields()
      elif field.label == _FieldDescriptor.LABEL_REPEATED:
        for sub_message in value:
          sub_message.DiscardUnknownFields()
      else:
        value.DiscardUnknownFields()
def FindInitializationErrors(self)

Finds required fields which are not initialized.

Returns

A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. "foo.bar[5].baz".

Expand source code
def FindInitializationErrors(self):
  """Finds required fields which are not initialized.

  Returns:
    A list of strings.  Each string is a path to an uninitialized field from
    the top-level message, e.g. "foo.bar[5].baz".
  """

  errors = []  # simplify things

  for field in required_fields:
    if not self.HasField(field.name):
      errors.append(field.name)

  for field, value in self.ListFields():
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if field.is_extension:
        name = '(%s)' % field.full_name
      else:
        name = field.name

      if _IsMapField(field):
        if _IsMessageMapField(field):
          for key in value:
            element = value[key]
            prefix = '%s[%s].' % (name, key)
            sub_errors = element.FindInitializationErrors()
            errors += [prefix + error for error in sub_errors]
        else:
          # ScalarMaps can't have any initialization errors.
          pass
      elif field.label == _FieldDescriptor.LABEL_REPEATED:
        for i in range(len(value)):
          element = value[i]
          prefix = '%s[%d].' % (name, i)
          sub_errors = element.FindInitializationErrors()
          errors += [prefix + error for error in sub_errors]
      else:
        prefix = name + '.'
        sub_errors = value.FindInitializationErrors()
        errors += [prefix + error for error in sub_errors]

  return errors
def HasField(self, field_name)
Expand source code
def HasField(self, field_name):
  try:
    field = hassable_fields[field_name]
  except KeyError:
    raise ValueError(error_msg % (message_descriptor.full_name, field_name))

  if isinstance(field, descriptor_mod.OneofDescriptor):
    try:
      return HasField(self, self._oneofs[field].name)
    except KeyError:
      return False
  else:
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      value = self._fields.get(field)
      return value is not None and value._is_present_in_parent
    else:
      return field in self._fields
def IsInitialized(self, errors=None)

Checks if all required fields of a message are set.

Args

errors
A list which, if provided, will be populated with the field paths of all missing required fields.

Returns

True iff the specified message has all required fields set.

Expand source code
def IsInitialized(self, errors=None):
  """Checks if all required fields of a message are set.

  Args:
    errors:  A list which, if provided, will be populated with the field
             paths of all missing required fields.

  Returns:
    True iff the specified message has all required fields set.
  """

  # Performance is critical so we avoid HasField() and ListFields().

  for field in required_fields:
    if (field not in self._fields or
        (field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE and
         not self._fields[field]._is_present_in_parent)):
      if errors is not None:
        errors.extend(self.FindInitializationErrors())
      return False

  for field, value in list(self._fields.items()):  # dict can change size!
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      if field.label == _FieldDescriptor.LABEL_REPEATED:
        if (field.message_type.has_options and
            field.message_type.GetOptions().map_entry):
          continue
        for element in value:
          if not element.IsInitialized():
            if errors is not None:
              errors.extend(self.FindInitializationErrors())
            return False
      elif value._is_present_in_parent and not value.IsInitialized():
        if errors is not None:
          errors.extend(self.FindInitializationErrors())
        return False

  return True
def ListFields(self)
Expand source code
def ListFields(self):
  all_fields = [item for item in self._fields.items() if _IsPresent(item)]
  all_fields.sort(key = lambda item: item[0].number)
  return all_fields
def MergeFrom(self, msg)
Expand source code
def MergeFrom(self, msg):
  if not isinstance(msg, cls):
    raise TypeError(
        'Parameter to MergeFrom() must be instance of same class: '
        'expected %s got %s.' % (_FullyQualifiedClassName(cls),
                                 _FullyQualifiedClassName(msg.__class__)))

  assert msg is not self
  self._Modified()

  fields = self._fields

  for field, value in msg._fields.items():
    if field.label == LABEL_REPEATED:
      field_value = fields.get(field)
      if field_value is None:
        # Construct a new object to represent this field.
        field_value = field._default_constructor(self)
        fields[field] = field_value
      field_value.MergeFrom(value)
    elif field.cpp_type == CPPTYPE_MESSAGE:
      if value._is_present_in_parent:
        field_value = fields.get(field)
        if field_value is None:
          # Construct a new object to represent this field.
          field_value = field._default_constructor(self)
          fields[field] = field_value
        field_value.MergeFrom(value)
    else:
      self._fields[field] = value
      if field.containing_oneof:
        self._UpdateOneofState(field)

  if msg._unknown_fields:
    if not self._unknown_fields:
      self._unknown_fields = []
    self._unknown_fields.extend(msg._unknown_fields)
    # pylint: disable=protected-access
    if self._unknown_field_set is None:
      self._unknown_field_set = containers.UnknownFieldSet()
    self._unknown_field_set._extend(msg._unknown_field_set)
def MergeFromString(self, serialized)
Expand source code
def MergeFromString(self, serialized):
  serialized = memoryview(serialized)
  length = len(serialized)
  try:
    if self._InternalParse(serialized, 0, length) != length:
      # The only reason _InternalParse would return early is if it
      # encountered an end-group tag.
      raise message_mod.DecodeError('Unexpected end-group tag.')
  except (IndexError, TypeError):
    # Now ord(buf[p:p+1]) == ord('') gets TypeError.
    raise message_mod.DecodeError('Truncated message.')
  except struct.error as e:
    raise message_mod.DecodeError(e)
  return length   # Return this for legacy reasons.
def SerializePartialToString(self, **kwargs)
Expand source code
def SerializePartialToString(self, **kwargs):
  out = BytesIO()
  self._InternalSerialize(out.write, **kwargs)
  return out.getvalue()
def SerializeToString(self, **kwargs)
Expand source code
def SerializeToString(self, **kwargs):
  # Check if the message has all of its required fields set.
  if not self.IsInitialized():
    raise message_mod.EncodeError(
        'Message %s is missing required fields: %s' % (
        self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors())))
  return self.SerializePartialToString(**kwargs)
def SetInParent(self)

Sets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change.

Expand source code
def Modified(self):
  """Sets the _cached_byte_size_dirty bit to true,
  and propagates this to our listener iff this was a state change.
  """

  # Note:  Some callers check _cached_byte_size_dirty before calling
  #   _Modified() as an extra optimization.  So, if this method is ever
  #   changed such that it does stuff even when _cached_byte_size_dirty is
  #   already true, the callers need to be updated.
  if not self._cached_byte_size_dirty:
    self._cached_byte_size_dirty = True
    self._listener_for_children.dirty = True
    self._is_present_in_parent = True
    self._listener.Modified()
def UnknownFields(self)
Expand source code
def _UnknownFields(self):
  if self._unknown_field_set is None:  # pylint: disable=protected-access
    # pylint: disable=protected-access
    self._unknown_field_set = containers.UnknownFieldSet()
  return self._unknown_field_set    # pylint: disable=protected-access
def WhichOneof(self, oneof_name)

Returns the name of the currently set field inside a oneof, or None.

Expand source code
def WhichOneof(self, oneof_name):
  """Returns the name of the currently set field inside a oneof, or None."""
  try:
    field = message_descriptor.oneofs_by_name[oneof_name]
  except KeyError:
    raise ValueError(
        'Protocol message has no oneof "%s" field.' % oneof_name)

  nested_field = self._oneofs.get(field, None)
  if nested_field is not None and self.HasField(nested_field.name):
    return nested_field.name
  else:
    return None