def reset(self): """Reset the registry to its initial state.""" self._rules.clear() # Register date and time wrappers. self.register(timestamp_pb2.Timestamp, dates.TimestampRule()) self.register(duration_pb2.Duration, dates.DurationRule()) # Register nullable primitive wrappers. self.register(wrappers_pb2.BoolValue, wrappers.BoolValueRule()) self.register(wrappers_pb2.BytesValue, wrappers.BytesValueRule()) self.register(wrappers_pb2.DoubleValue, wrappers.DoubleValueRule()) self.register(wrappers_pb2.FloatValue, wrappers.FloatValueRule()) self.register(wrappers_pb2.Int32Value, wrappers.Int32ValueRule()) self.register(wrappers_pb2.Int64Value, wrappers.Int64ValueRule()) self.register(wrappers_pb2.StringValue, wrappers.StringValueRule()) self.register(wrappers_pb2.UInt32Value, wrappers.UInt32ValueRule()) self.register(wrappers_pb2.UInt64Value, wrappers.UInt64ValueRule()) # Register the google.protobuf.Struct wrappers. # # These are aware of the marshal that created them, because they # create RepeatedComposite and MapComposite instances directly and # need to pass the marshal to them. self.register(struct_pb2.Value, struct.ValueRule(marshal=self)) self.register(struct_pb2.ListValue, struct.ListValueRule(marshal=self)) self.register(struct_pb2.Struct, struct.StructRule(marshal=self))
def reset(self): """Reset the registry to its initial state.""" self._rules.clear() # Register date and time wrappers. self.register(timestamp_pb2.Timestamp, dates.TimestampRule()) self.register(duration_pb2.Duration, dates.DurationRule()) # Register nullable primitive wrappers. self.register(wrappers_pb2.BoolValue, wrappers.BoolValueRule()) self.register(wrappers_pb2.BytesValue, wrappers.BytesValueRule()) self.register(wrappers_pb2.DoubleValue, wrappers.DoubleValueRule()) self.register(wrappers_pb2.FloatValue, wrappers.FloatValueRule()) self.register(wrappers_pb2.Int32Value, wrappers.Int32ValueRule()) self.register(wrappers_pb2.Int64Value, wrappers.Int64ValueRule()) self.register(wrappers_pb2.StringValue, wrappers.StringValueRule()) self.register(wrappers_pb2.UInt32Value, wrappers.UInt32ValueRule()) self.register(wrappers_pb2.UInt64Value, wrappers.UInt64ValueRule()) # Register the google.protobuf.Struct wrappers. # # These are aware of the marshal that created them, because they # create RepeatedComposite and MapComposite instances directly and # need to pass the marshal to them. self.register(struct_pb2.Value, struct.ValueRule(marshal=self)) self.register(struct_pb2.ListValue, struct.ListValueRule(marshal=self)) self.register(struct_pb2.Struct, struct.StructRule(marshal=self)) # Special case for bytes to allow base64 encode/decode self.register(ProtoType.BYTES, pb_bytes.BytesRule()) # Special case for int64 from strings because of dict round trip. # See https://github.com/protocolbuffers/protobuf/issues/2679 for rule_class in stringy_numbers.STRINGY_NUMBER_RULES: self.register(rule_class._proto_type, rule_class())