1class CBORTag(object): 2 """ 3 Represents a CBOR semantic tag. 4 5 :param int tag: tag number 6 :param value: encapsulated value (any object) 7 """ 8 9 __slots__ = 'tag', 'value' 10 11 def __init__(self, tag, value): 12 self.tag = tag 13 self.value = value 14 15 def __eq__(self, other): 16 if isinstance(other, CBORTag): 17 return self.tag == other.tag and self.value == other.value 18 return NotImplemented 19 20 def __repr__(self): 21 return 'CBORTag({self.tag}, {self.value!r})'.format(self=self) 22 23 24class CBORSimpleValue(object): 25 """ 26 Represents a CBOR "simple value". 27 28 :param int value: the value (0-255) 29 """ 30 31 __slots__ = 'value' 32 33 def __init__(self, value): 34 if value < 0 or value > 255: 35 raise TypeError('simple value too big') 36 self.value = value 37 38 def __eq__(self, other): 39 if isinstance(other, CBORSimpleValue): 40 return self.value == other.value 41 elif isinstance(other, int): 42 return self.value == other 43 return NotImplemented 44 45 def __repr__(self): 46 return 'CBORSimpleValue({self.value})'.format(self=self) 47 48 49class UndefinedType(object): 50 __slots__ = () 51 52 53#: Represents the "undefined" value. 54undefined = UndefinedType() 55break_marker = object() 56