cp2077_extractor.utils

General utility functions.

Classes:

InfiniteList(items)

List-like object that refills with a random order once empty.

StringReader([initial_bytes])

Reader for REDengine sized strings.

Functions:

to_snake_case(value)

Convert the given string into snake_case.

transcode_file(wem_filename, mp3_filename[, ...])

Transcode a WWise .wem file to mp3 at 256kbps.

class InfiniteList(items)[source]

Bases: Generic[~_T]

List-like object that refills with a random order once empty.

Parameters

items (list[~_T]) – Values to loop through.

Methods:

pop()

Get the next item from the back of the list.

repopulate()

Repopulate the list with a new random order, avoiding recent items occuring soon.

pop()[source]

Get the next item from the back of the list.

Return type

~_T

repopulate()[source]

Repopulate the list with a new random order, avoiding recent items occuring soon.

class StringReader(initial_bytes=b'')[source]

Bases: BytesIO

Reader for REDengine sized strings.

Methods:

parse_string()

Parse a length-prefixed string (as bytes) to a Python string.

parse_string_and_size()

Parse a length-prefixed string (as bytes) to a Python string.

read_vlq_int32()

Parse modified 32 bit VLQ to int.

parse_string()[source]

Parse a length-prefixed string (as bytes) to a Python string.

Return type

str

parse_string_and_size()[source]

Parse a length-prefixed string (as bytes) to a Python string.

Return type

tuple[int, str]

Returns

Tuple of length prefix and the string.

read_vlq_int32()[source]

Parse modified 32 bit VLQ to int.

The first bit is the sign bit, the 2nd bit tells whether there are more octets to read, and the next 6 bytes are the least significant bits of the number data. Remaining octets are 1+7 continuation and data.

Return type

int

to_snake_case(value)[source]

Convert the given string into snake_case.

Parameters

value (str)

Return type

str

transcode_file(wem_filename, mp3_filename, length_range=None)[source]

Transcode a WWise .wem file to mp3 at 256kbps.

Requires ffmpeg to be installed.

Parameters