steamfiles/manifest.py
def loads(data, wrapper=dict):
    """
    Loads Manifest content into a Python object.
    :param data: A byte-like object with the contents of an Appinfo file.
    :param wrapper: A wrapping object for key-value pairs.
    :return: A dictionary with Manifest data.
    """
    if not isinstance(data, (bytes, bytearray)):
        raise TypeError('can only load a bytes-like object as a Manifest but got ' + type(data).__name__)

    offset = 0
    parsed = wrapper()
    int32 = struct.Struct('<I')

    while True:
        msg_id, = int32.unpack_from(data, offset)
        offset += int32.size

        if msg_id == MSG_EOF:
            break

        msg_size, = int32.unpack_from(data, offset)
        offset += int32.size

        msg_data = data[offset:offset + msg_size]
        offset += msg_size

        message = MessageClass[msg_id]()
        message.ParseFromString(msg_data)

        parsed[MSG_NAMES[msg_id]] = wrapper(protobuf_to_dict(message))

    return parsed
def loads(data, wrapper=dict):
    """
    Loads Manifest content into a Python object.
    :param data: A byte-like object with the contents of an Appinfo file.
    :param wrapper: A wrapping object for key-value pairs.
    :return: A dictionary with Manifest data.
    """
    if not isinstance(data, (bytes, bytearray)):
        raise TypeError('can only load a bytes-like object as a Manifest but got ' + type(data).__name__)

    offset = 0
    parsed = wrapper()
    int32 = struct.Struct('<I')

    while True:
        msg_id, = int32.unpack_from(data, offset)
        offset += int32.size

        if msg_id == MSG_EOF:
            break

        msg_size, = int32.unpack_from(data, offset)
        offset += int32.size

        msg_data = data[offset:offset + msg_size]
        offset += msg_size

        message = MessageClass[msg_id]()
        message.ParseFromString(msg_data)

        parsed[MSG_NAMES[msg_id]] = wrapper(protobuf_to_dict(message))

    return parsed
def loads ( data , wrapper = dict ) : if not isinstance ( data , ( bytes , bytearray ) ) : raise TypeError ( 'can only load a bytes-like object as a Manifest but got ' + type ( data ) . __name__ ) offset = 0 parsed = wrapper ( ) int32 = struct . Struct ( '<I' ) while True : msg_id , = int32 . unpack_from ( data , offset ) offset += int32 . size if msg_id == MSG_EOF : break msg_size , = int32 . unpack_from ( data , offset ) offset += int32 . size msg_data = data [ offset : offset + msg_size ] offset += msg_size message = MessageClass [ msg_id ] ( ) message . ParseFromString ( msg_data ) parsed [ MSG_NAMES [ msg_id ] ] = wrapper ( protobuf_to_dict ( message ) ) return parsed
Loads Manifest content into a Python object.
    :param data: A byte-like object with the contents of an Appinfo file.
    :param wrapper: A wrapping object for key-value pairs.
    :return: A dictionary with Manifest data.
Loads Manifest content into a Python object . : param data : A byte - like object with the contents of an Appinfo file . : param wrapper : A wrapping object for key - value pairs . : return : A dictionary with Manifest data .