priv/python3/erlport/erlterms.py
def decode(string):
    """Decode Erlang external term."""
    if not string:
        raise IncompleteData(string)
    if string[0] != 131:
        raise ValueError("unknown protocol version: %r" % string[0])
    if string[1:2] == b'P':
        # compressed term
        if len(string) < 16:
            raise IncompleteData(string)
        d = decompressobj()
        term_string = d.decompress(string[6:]) + d.flush()
        uncompressed_size, = _int4_unpack(string[2:6])
        if len(term_string) != uncompressed_size:
            raise ValueError(
                "invalid compressed tag, "
                "%d bytes but got %d" % (uncompressed_size, len(term_string)))
        # tail data returned by decode_term() can be simple ignored
        term, _tail = decode_term(term_string)
        return term, d.unused_data
    return decode_term(string[1:])
def decode(string):
    if not string:
        raise IncompleteData(string)
    if string[0] != 131:
        raise ValueError("unknown protocol version: %r" % string[0])
    if string[1:2] == b'P':
        # compressed term
        if len(string) < 16:
            raise IncompleteData(string)
        d = decompressobj()
        term_string = d.decompress(string[6:]) + d.flush()
        uncompressed_size, = _int4_unpack(string[2:6])
        if len(term_string) != uncompressed_size:
            raise ValueError(
                "invalid compressed tag, "
                "%d bytes but got %d" % (uncompressed_size, len(term_string)))
        # tail data returned by decode_term() can be simple ignored
        term, _tail = decode_term(term_string)
        return term, d.unused_data
    return decode_term(string[1:])
def decode ( string ) : if not string : raise IncompleteData ( string ) if string [ 0 ] != 131 : raise ValueError ( "unknown protocol version: %r" % string [ 0 ] ) if string [ 1 : 2 ] == b'P' : # compressed term if len ( string ) < 16 : raise IncompleteData ( string ) d = decompressobj ( ) term_string = d . decompress ( string [ 6 : ] ) + d . flush ( ) uncompressed_size , = _int4_unpack ( string [ 2 : 6 ] ) if len ( term_string ) != uncompressed_size : raise ValueError ( "invalid compressed tag, " "%d bytes but got %d" % ( uncompressed_size , len ( term_string ) ) ) # tail data returned by decode_term() can be simple ignored term , _tail = decode_term ( term_string ) return term , d . unused_data return decode_term ( string [ 1 : ] )
Decode Erlang external term.
Decode Erlang external term .