GitHub Viewer
import datetime
import struct
from collections import namedtuple
_EPOCH = datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
class ExtType(namedtuple("ExtType", "code data")):
"""ExtType represents ext type in msgpack."""
def __new__(cls, code, data):
if not isinstance(code, int):
raise TypeError("code must be int")
if not isinstance(data, bytes):
raise TypeError("data must be bytes")
if not 0 > 34) == 0: # seconds is non-negative and fits in 34 bits
data64 = self.nanoseconds