Return an X10 housecode value from a byte value.
543305
def byte_to_housecode(bytecode):
    """"""
    hc = list(HC_LOOKUP.keys())[list(HC_LOOKUP.values()).index(bytecode)]
    return hc.upper()
1179181
def _py2_crc16(value):
    
    crc = 0
    for byte in value:
        crc = ((crc << 8) & 0xffff) ^ \
              _CRC16_LOOKUP[((crc >> 8) ^ ord(byte)) & 0xff]
    return crc
77593
function fromCodePoint(cp) {
        return (cp < 0x10000) ? String.fromCharCode(cp) :
            String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) +
            String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
    }
966537
function (cp) {
	        return (cp < 0x10000) ? String.fromCharCode(cp) :
	            String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) +
	                String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
	    }
933444
def to_bytes(value):
    """"""
    if isinstance(value, unicode):
        return value.encode('utf8')
    elif not isinstance(value, str):
        return str(value)
    return value
950185
def encode(self, value):
        '''
        
        '''
        encoded = strToBytes(value) + b'\x00'
        return Bits(bytes=encoded)
1031620
def from_bytes(TxIn, byte_string):
        '''
        
        '''
        outpoint = Outpoint.from_bytes(byte_string[:36])

        script_sig_len = VarInt.from_bytes(byte_string[36:45])
        script_start = 36 + len(script_sig_len)
        script_end = script_start + script_sig_len.number
        script_sig = byte_string[script_start:script_end]

        sequence = byte_string[script_end:script_end + 4]
        if script_sig == b'':
            stack_script = b''
            redeem_script = b''
        else:
            stack_script, redeem_script = TxIn._parse_script_sig(script_sig)
        return TxIn(
            outpoint=outpoint,
            stack_script=stack_script,
            redeem_script=redeem_script,
            sequence=sequence)
599555
def from_raw(self, raw: RawScalar) -> Optional[bytes]:
        """"""
        try:
            return base64.b64decode(raw, validate=True)
        except TypeError:
            return None
170239
def create_x10(plm, housecode, unitcode, feature):
    """"""
    from insteonplm.devices.ipdb import IPDB
    ipdb = IPDB()
    product = ipdb.x10(feature)
    deviceclass = product.deviceclass
    device = None
    if deviceclass:
        device = deviceclass(plm, housecode, unitcode)
    return device
1012353
def decodebytes(input):
    """"""
    py_version = sys.version_info[0]
    if py_version >= 3:
        return _decodebytes_py3(input)
    return _decodebytes_py2(input)
729891
def as_bin(self):
        """"""
        f = io.BytesIO()
        self.stream(f)
        return f.getvalue()
330454
def _bytes_to_json(value):
    """"""
    if isinstance(value, bytes):
        value = base64.standard_b64encode(value).decode("ascii")
    return value
714518
def encode(self, value):
        '''
        
        '''
        kassert.is_of_types(value, Bits)
        remainder = len(value) % 8
        if remainder:
            value += Bits(bin='0' * (8 - remainder))
        return value
598956
def encode_value_using_ma(message_attribute: int, value: Optional[Union[int, float]]) -> int:
    """"""
    if message_attribute == MA_TX3AC_100A:
        # TX-3AC in 100A mode; use value as-is, with 0xFE indicating null
        if value is None:
            return 0xfe
        return int(value)
    elif message_attribute == MA_TX3AC_10A:
        # TX-3AC in 10A mode; shift decimal point, with 0xFE indicating null
        if value is None:
            return 0xfe
        return int(value * 10)
    else:
        # Signed byte, with 0x80 indicating null
        if value is None:
            return 0x80
        elif value < 0:
            return 0x100 + int(value)
        return int(value)
540710
def get_decode_value(self):
        """"""
        if self._store_type == PUBLIC_KEY_STORE_TYPE_HEX:
            value = bytes.fromhex(self._value)
        elif self._store_type == PUBLIC_KEY_STORE_TYPE_BASE64:
            value = b64decode(self._value)
        elif self._store_type == PUBLIC_KEY_STORE_TYPE_BASE85:
            value = b85decode(self._value)
        elif self._store_type == PUBLIC_KEY_STORE_TYPE_JWK:
            # TODO: need to decide on which jwk library to import?
            raise NotImplementedError
        else:
            value = self._value
        return value
446881
def tob32(val):
    """"""
    ret = bytearray(4)
    ret[0] = (val>>24)&M8
    ret[1] = (val>>16)&M8
    ret[2] = (val>>8)&M8
    ret[3] = val&M8
    return ret
696162
def from_bytes(rawbytes):
        '''
        
        '''
        ipopts = IPOptionList()

        i = 0
        while i < len(rawbytes):
            opttype = rawbytes[i]
            optcopied = opttype >> 7         # high order 1 bit
            optclass = (opttype >> 5) & 0x03 # next 2 bits
            optnum = opttype & 0x1f          # low-order 5 bits are optnum
            optnum = IPOptionNumber(optnum)
            obj = IPOptionClasses[optnum]()
            eaten = obj.from_bytes(rawbytes[i:])
            i += eaten
            ipopts.append(obj)
        return ipopts