ubii.proto package¶
Message Types¶
This meta package is used to import the protobuf message types.
Note
Only import from ubii.proto, not directly from the module set in ubii.proto.__proto_module__
- class ubii.proto.Client(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- devices¶
RepeatedFieldof typeDevice
- tags¶
RepeatedFieldof typeSTRING
- processing_modules¶
RepeatedFieldof typeProcessingModule
- state¶
-
- Type
- class ubii.proto.ClientList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeClient
- class ubii.proto.ButtonEventType(value)[source]¶
Bases:
proto.enums.EnumAn enumeration.
- UP = 0¶
- DOWN = 1¶
- class ubii.proto.HandGestureType(value)[source]¶
Bases:
proto.enums.EnumAn enumeration.
- REST = 0¶
- FINGERS_SPREAD = 1¶
- WAVE_IN = 2¶
- WAVE_OUT = 3¶
- FIST = 4¶
- DOUBLE_TAP = 5¶
- class ubii.proto.Color(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Image2D(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- data_format¶
Fieldof typeDataFormat- Type
- class ubii.proto.Image2DList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeImage2D
- class ubii.proto.KeyEvent(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- type¶
Fieldof typeButtonEventType- Type
- class ubii.proto.StringList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeSTRING
- class ubii.proto.DoubleList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeDOUBLE
- class ubii.proto.FloatList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeFLOAT
- class ubii.proto.BoolList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeBOOL
- class ubii.proto.Int32List(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeINT32
- class ubii.proto.Matrix3x2(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Matrix4x4(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.MouseEvent(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- type¶
Fieldof typeButtonEventType- Type
- class ubii.proto.MyoEvent(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- emg¶
-
- Type
- orientation¶
Fieldof typeQuaternion- Type
- gyroscope¶
-
- Type
- accelerometer¶
-
- Type
- gesture¶
Fieldof typeHandGestureType- Type
- class ubii.proto.Object2D(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- pose¶
-
- Type
- size¶
-
- Type
- class ubii.proto.Object2DList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeObject2D
- class ubii.proto.Object3D(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- pose¶
-
- Type
- size¶
-
- Type
- class ubii.proto.Object3DList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeObject3D
- class ubii.proto.Pose2D(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- position¶
-
- Type
- direction¶
Fieldof typeVector2– oneoforientation- Type
- angle¶
Fieldof typeFLOAT– oneoforientation- Type
- class ubii.proto.Pose3D(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- position¶
-
- Type
- quaternion¶
Fieldof typeQuaternion– oneoforientation- Type
- euler¶
Fieldof typeVector3– oneoforientation- Type
- class ubii.proto.Quaternion(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.QuaternionList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeQuaternion
- class ubii.proto.TouchEvent(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- type¶
Fieldof typeTouchEventType- Type
- position¶
-
- Type
- class ubii.proto.TouchEventList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTouchEvent
- class ubii.proto.Vector2(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Vector2List(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeVector2
- class ubii.proto.Vector3(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Vector3List(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeVector3
- class ubii.proto.Vector4(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Vector4List(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeVector4
- class ubii.proto.Vector8(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Vector8List(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeVector8
- class ubii.proto.Component(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- io_type¶
-
- Type
- tags¶
RepeatedFieldof typeSTRING
- class IOType(value)[source]¶
Bases:
proto.enums.EnumAn enumeration.
- PUBLISHER = 0¶
- SUBSCRIBER = 1¶
- class ubii.proto.ComponentList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeComponent
- class ubii.proto.Device(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- device_type¶
Fieldof typeDeviceType- Type
- components¶
RepeatedFieldof typeComponent
- tags¶
RepeatedFieldof typeSTRING
- class DeviceType(value)[source]¶
Bases:
proto.enums.EnumAn enumeration.
- PARTICIPANT = 0¶
- WATCHER = 1¶
- class ubii.proto.DeviceList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeDevice
- class ubii.proto.TopicDemux(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.TopicDemuxList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTopicDemux
- class ubii.proto.TopicMux(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.TopicMuxList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTopicMux
- class ubii.proto.Error(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.ErrorList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeError
- class ubii.proto.Success(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.SuccessList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeSuccess
- class ubii.proto.LockstepProcessingRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- processing_module_ids¶
RepeatedFieldof typeSTRING
- records¶
RepeatedFieldof typeTopicDataRecord
- class ubii.proto.LockstepProcessingReply(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- processing_module_ids¶
RepeatedFieldof typeSTRING
- records¶
RepeatedFieldof typeTopicDataRecord
- class ubii.proto.ProcessingMode(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageOne Ofs
This message defines the following oneof group[s]
- trigger_on_input¶
Fieldof typeTriggerOnInput– oneofmode- Type
- class Frequency(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageProcessing Callback is executed at a fixed time interval, with target frequency
- class Lockstep(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageProcessing Callback is executed when the master node sends a lockstep processing request
- class ubii.proto.ModuleIO(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.ProcessingModule(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- authors¶
RepeatedFieldof typeSTRING
- tags¶
RepeatedFieldof typeSTRING
- status¶
-
- Type
- processing_mode¶
Fieldof typeProcessingMode- Type
- inputs¶
RepeatedFieldof typeModuleIO
- outputs¶
RepeatedFieldof typeModuleIO
- language¶
-
- Type
- class ubii.proto.ProcessingModuleList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeProcessingModule
- class ubii.proto.Constants(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- DEFAULT_TOPICS¶
Fieldof typeDefaultTopics- Type
- MSG_TYPES¶
-
- Type
- class DefaultTopics(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- SERVICES¶
-
- Type
- INFO_TOPICS¶
Fieldof typeInfoTopics- Type
- class Services(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class InfoTopics(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class MsgTypes(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Server(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.Service(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- tags¶
RepeatedFieldof typeSTRING
- class ubii.proto.ServiceList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeService
- class ubii.proto.ServiceReply(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageOne Ofs
This message defines the following oneof group[s]
- session_list¶
Fieldof typeSessionList– oneoftype- Type
- processing_module¶
Fieldof typeProcessingModule– oneoftype- Type
- processing_module_list¶
Fieldof typeProcessingModuleList– oneoftype- Type
- string_list¶
Fieldof typeStringList– oneoftype- Type
- topic_mux_list¶
Fieldof typeTopicMuxList– oneoftype- Type
- topic_demux¶
Fieldof typeTopicDemux– oneoftype- Type
- topic_demux_list¶
Fieldof typeTopicDemuxList– oneoftype- Type
- client_list¶
Fieldof typeClientList– oneoftype- Type
- device_list¶
Fieldof typeDeviceList– oneoftype- Type
- service_list¶
Fieldof typeServiceList– oneoftype- Type
- lockstep_processing_reply¶
Fieldof typeLockstepProcessingReply– oneoftype- Type
- component_list¶
Fieldof typeComponentList– oneoftype- Type
- class ubii.proto.ServiceRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageOne Ofs
This message defines the following oneof group[s]
- topic_subscription¶
Fieldof typeTopicSubscription– oneoftype- Type
- session_list¶
Fieldof typeSessionList– oneoftype- Type
- processing_module¶
Fieldof typeProcessingModule– oneoftype- Type
- processing_module_list¶
Fieldof typeProcessingModuleList– oneoftype- Type
- topic_mux_list¶
Fieldof typeTopicMuxList– oneoftype- Type
- topic_demux¶
Fieldof typeTopicDemux– oneoftype- Type
- topic_demux_list¶
Fieldof typeTopicDemuxList– oneoftype- Type
- client_list¶
Fieldof typeClientList– oneoftype- Type
- device_list¶
Fieldof typeDeviceList– oneoftype- Type
- lockstep_processing_request¶
Fieldof typeLockstepProcessingRequest– oneoftype- Type
- component_list¶
Fieldof typeComponentList– oneoftype- Type
- class ubii.proto.TopicSubscription(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- subscribe_topics¶
RepeatedFieldof typeSTRING
- unsubscribe_topics¶
RepeatedFieldof typeSTRING
- subscribe_topic_regexp¶
RepeatedFieldof typeSTRING
- unsubscribe_topic_regexp¶
RepeatedFieldof typeSTRING
- class ubii.proto.SessionStatus(value)[source]¶
Bases:
proto.enums.EnumAn enumeration.
- CREATED = 0¶
- RUNNING = 1¶
- PAUSED = 2¶
- STOPPED = 3¶
- class ubii.proto.TopicInputMapping(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- topic¶
Fieldof typeSTRING– oneoftopic_source- Type
- topic_mux¶
Fieldof typeTopicMux– oneoftopic_source- Type
- class ubii.proto.TopicInputMappingList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTopicInputMapping
- class ubii.proto.TopicOutputMapping(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- topic¶
Fieldof typeSTRING– oneoftopic_destination- Type
- topic_demux¶
Fieldof typeTopicDemux– oneoftopic_destination- Type
- class ubii.proto.TopicOutputMappingList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTopicOutputMapping
- class ubii.proto.IOMapping(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- input_mappings¶
RepeatedFieldof typeTopicInputMapping
- output_mappings¶
RepeatedFieldof typeTopicOutputMapping
- class ubii.proto.IOMappingList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeIOMapping
- class ubii.proto.Session(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- processing_modules¶
RepeatedFieldof typeProcessingModule
- io_mappings¶
RepeatedFieldof typeIOMapping
- tags¶
RepeatedFieldof typeSTRING
- authors¶
RepeatedFieldof typeSTRING
- status¶
Fieldof typeSessionStatus- Type
- class ubii.proto.SessionList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeSession
- class ubii.proto.Timestamp(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message
- class ubii.proto.TopicData(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.MessageOne Ofs
This message defines the following oneof group[s]
- topic_data_record¶
Fieldof typeTopicDataRecord– oneoftype- Type
- topic_data_record_list¶
Fieldof typeTopicDataRecordList– oneoftype- Type
- class ubii.proto.TopicDataRecord(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Messagecontinuous index: 38
- timestamp¶
-
- Type
- vector2_list¶
Fieldof typeVector2List– oneoftype- Type
- vector3_list¶
Fieldof typeVector3List– oneoftype- Type
- vector4_list¶
Fieldof typeVector4List– oneoftype- Type
- quaternion¶
Fieldof typeQuaternion– oneoftype- Type
- quaternion_list¶
Fieldof typeQuaternion– oneoftype- Type
- touch_event¶
Fieldof typeTouchEvent– oneoftype- Type
- touch_event_list¶
Fieldof typeTouchEventList– oneoftype- Type
- mouse_event¶
Fieldof typeMouseEvent– oneoftype- Type
- object2D_list¶
Fieldof typeObject2DList– oneoftype- Type
- object3D_list¶
Fieldof typeObject3DList– oneoftype- Type
- double_list¶
Fieldof typeDoubleList– oneoftype- Type
- string_list¶
Fieldof typeStringList– oneoftype- Type
- image2D_list¶
Fieldof typeImage2DList– oneoftype- Type
- class ubii.proto.TopicDataRecordList(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]¶
Bases:
proto.message.Message- elements¶
RepeatedFieldof typeTopicDataRecord
- ubii.proto.__protobuf__ = ProtoModule(package='ubii.proto.v1', marshal='ubii.proto.v1', manifest=frozenset({'StringList', 'TopicInputMapping', 'TopicOutputMapping', 'Error', 'Vector2List', 'ProcessingMode', 'Vector3', 'Vector4', 'Quaternion', 'Matrix3x2', 'TopicDataRecordList', 'HandGestureType', 'QuaternionList', 'TopicMuxList', 'Vector8', 'Success', 'KeyEvent', 'Object3DList', 'ComponentList', 'TopicOutputMappingList', 'TopicInputMappingList', 'Timestamp', 'DoubleList', 'ButtonEventType', 'Pose2D', 'TopicMux', 'MouseEvent', 'DeviceList', 'LockstepProcessingReply', 'Constants', 'Vector8List', 'SuccessList', 'Server', 'Image2D', 'ProcessingModule', 'Matrix4x4', 'FloatList', 'TopicDemuxList', 'MyoEvent', 'ServiceList', 'Vector3List', 'Object2DList', 'IOMapping', 'ModuleIO', 'Vector2', 'BoolList', 'SessionStatus', 'IOMappingList', 'Component', 'ErrorList', 'Int32List', 'Object2D', 'TopicDataRecord', 'LockstepProcessingRequest', 'Color', 'Vector4List', 'SessionList', 'Device', 'Session', 'TopicData', 'Client', 'TopicSubscription', 'ServiceReply', 'TouchEvent', 'Image2DList', 'TouchEventList', 'ClientList', 'TopicDemux', 'ProcessingModuleList', 'Pose3D', 'Service', 'Object3D', 'ServiceRequest'}))¶
Used by Proto Plus for Python to aggregate defined protobuf message in the same descriptor pool. You need to import this attribute in every module that extends an existing protobuf wrapper class using
ubii.proto.ProtoMeta. In essence this is a named tuple with attributespackageandmarshalcontaining the name for theMarshalused by this package andmanifestcontaining a set of allMessageavailable from this module.Example
You may want to create a extension to the wrapper around
ubii.proto.Errorto be able to raise the error as an exception:from functools import lru_cache from proto.marshal import Marshal from proto.marshal.rules.message import MessageRule import ubii.proto as ub __protobuf__ = ub.__protobuf__ class BaseError(ub.Error, Exception, metaclass=ub.ProtoMeta): @classmethod @lru_cache def rule(cls): return MessageRule(ub.Error.pb(), cls) @property def args(self): return self.title, self.message, self.stack class SessionRuntimeStopServiceError(BaseError): pass class OtherError(BaseError): pass class ErrorRule(MessageRule): def to_python(self, value, *, absent: bool | None = None): title = value.title or '' rule = None if title.startswith('SessionRuntimeStopService'): rule = SessionRuntimeStopServiceError.rule() elif title.startswith('Other'): rule = OtherError.rule() else: rule = BaseError.rule() return rule.to_python(value, absent=absent) def to_proto(self, value): return super().to_proto(value) # register the new marshal rule to automatically convert errors Marshal(name=__protobuf__.marshal).register(ub.Error.pb(), ErrorRule(ub.Error.pb(), BaseError))
- ubii.proto.__proto_module__ = 'ubii.proto.v1'¶
The actual import path of the module that contains the autogenerated protobuf code. Users are supposed to import from
ubii.protoinstead.
You can look for the package from ubii.proto.__proto_module__
inside the auto-generated documentation:
- ubii.proto.v1 package
- ubii.proto.v1.clients package
- ubii.proto.v1.dataStructure package
- ubii.proto.v1.devices package
- ubii.proto.v1.general package
- ubii.proto.v1.processing package
- ubii.proto.v1.servers package
- ubii.proto.v1.services package
- ubii.proto.v1.services.request package
- ubii.proto.v1.sessions package
- ubii.proto.v1.topicData package
Utility¶
ubii.proto.util.ProtoMeta and
ubii.proto.util.ProtoEncoder from ubii.proto.util are directly
importable from ubii.proto
Submodules¶
ubii.proto.util module¶
Utility features to format protobuf messages and implement protobuf wrapper classes with custom behaviour.
- ubii.proto.util.get_import_name(message_type: str)[source]¶
The .proto files declare a package name ‘ubii’, but this is not reflected in the python package. Instead the package is named ubii.proto, to not clash with different packages in the ubii namespace. The python files are generated from updated proto files, to produce the correct directory structure. The directory structure determines python package names see https://developers.google.com/protocol-buffers/docs/reference/python-generated#package
- Parameters
message_type (str) – string describing the data type
- ubii.proto.util.import_type(message_type: str, reimport=False)[source]¶
See the documentation of the ubii-msg-compiler at https://github.com/saggitar/ubii-msg-compiler for more information about updating the .proto files to generate a different package structure.
- class ubii.proto.util.ProtoMeta(name, bases, attrs)[source]¶
Bases:
abc.ABCMeta,proto.message.MessageMetaThis metaclass is used to inherit from Proto Plus for Python wrapper classes
Example
Make sure you import and set
ubii.proto.__protobuf__in every module which defines newMessagetypes:import ubii.proto as ub __protobuf__ = ub.__protobuf__ class Fancy(ub.Component, metaclass=ub.ProtoMeta): @property def something_amazing(self) return "Wow"
- class ubii.proto.util.ProtoEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
json.encoder.JSONEncoderCustom encoder to convert Protobuf Messages and Proto-Plus Messages to valid json.
- format_options: Dict[str, bool] = {'including_default_value_fields': True, 'preserving_proto_field_name': False, 'use_integers_for_enums': True}¶
dictionary of default arguments passed to the
proto.message.Message.to_dict()orgoogle.protobuf.json_format.MessageToDict()calls which are used to convert the message object.
- default(o)[source]¶
returns a serializable object for
o, or calls the base implementation (to raise aTypeError).- Parameters
o (object) – (hopefully) serializable object, e.g. Protobuf message
- Returns
dict – Dictionary representation of message using
proto.message.Message.to_dict()orgoogle.protobuf.json_format.MessageToDict()- Raises
TypeError – If object is not serializable as Protobuf Message of by
json.JSONEncoder.default()
- ubii.proto.util.patch_wrapper_class_repr(replacement='...', max_len=50) None[source]¶
E.g. for documentation purposes it’s undesirable that the __repr__ method of
proto.message.Messagesimply returns formatted json for the message object. For messages with many fields or long representation of field values this to much information.This function simply monkeypatches the __repr__ method of
proto.message.Messageto replace output that is longer thanmax_lenwithreplacement- Parameters
replacement – string used as replacement
max_len – shorter representations will not be converted