def hydrate_object(protobuf):
    # Test if it's strongly typed first
    _type = type_of(protobuf)
    if _type == TYPE_ROOT:
        return RootObject.from_object(protobuf)
    elif _type == TYPE_UPDATE:
        return UpdateObject.from_object(protobuf)
    elif _type == TYPE_UNSET:
        # Use existing heuristic
        obj = RootObject.from_object(protobuf)
        if not obj.protocol:
            obj = UpdateObject.from_object(protobuf)
        return obj
    else:
        raise Exception("Unknown type; %s" % (str(_type)))
dataset/ETHPy150Open richo/groundstation/groundstation/objects/object_factory.py/hydrate_object/original