How to use the cup.util.misc.check_type function in cup

To help you get started, we’ve selected a few cup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github baidu / CUP / cup / net / asyn / msg.py View on Github external
def set_body(self, body):
        """
        set msg body
        """
        misc.check_type(body, str)
        self._data['body'] = body
        self._bodylen = len(body)
github baidu / CUP / cup / net / asyn / common.py View on Github external
def ip_port2connaddr(peer):
    """
    connaddr is a 64bit int
        32 -  16    - 16   - 32
        ip - port   - stub - future

    :param peer:
        (ipaddr, port)
    :return:
        return a connaddr
    """
    misc.check_type(peer, tuple)
    ipaddr, port = peer
    misc.check_type(ipaddr, str)
    packed = socket.inet_aton(ipaddr)
    return (struct.unpack("!L", packed)[0] << 64) | (port << 48)
github baidu / CUP / cup / net / asyn / msg.py View on Github external
def set_msg_type(self, msg_type):
        """
        set msg type
        """
        misc.check_type(msg_type, int)
        self._data['type'] = self._asign_uint2byte_bybits(msg_type, 32)
        self._type = msg_type
github baidu / CUP / cup / net / asyn / msg.py View on Github external
def _check_addr(cls, ip_port, stub_future):
        ip, port = ip_port
        stub, future = stub_future
        misc.check_type(ip, str)
github baidu / CUP / cup / util / __init__.py View on Github external
def check_type(param, expect):
    """
    deprecated. Recommand using misc.check_type in cup.util
    """
    misc.check_type(param, expect)
github baidu / CUP / cup / net / asyn / msg.py View on Github external
def _addr2pack(self, ip_port, stub_future):
        misc.check_type(ip_port, tuple)
        misc.check_type(stub_future, tuple)
        pack = common.ip_port2connaddr(ip_port)
        pack = common.add_stub2connaddr(pack, stub_future[0])
        pack = common.add_future2connaddr(pack, stub_future[1])
        return pack
github baidu / CUP / cup / net / asyn / msg.py View on Github external
def _addr2pack(self, ip_port, stub_future):
        misc.check_type(ip_port, tuple)
        misc.check_type(stub_future, tuple)
        pack = common.ip_port2connaddr(ip_port)
        pack = common.add_stub2connaddr(pack, stub_future[0])
        pack = common.add_future2connaddr(pack, stub_future[1])
        return pack