Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _consume_actions(buffer):
compressed_byte_count = consume_int(buffer)
compressed_data = buffer[:compressed_byte_count]
del buffer[:compressed_byte_count]
decompressed_data = lzma.decompress(compressed_data)
out = []
offset = 0
for raw_action in decompressed_data.split(b','):
if not raw_action:
continue
raw_offset, x, y, raw_action_mask = raw_action.split(b'|')
action_mask = ActionBitMask.unpack(int(raw_action_mask))
offset += int(raw_offset)
out.append(Action(
datetime.timedelta(milliseconds=offset),
Position(float(x), float(y)),
action_mask['m1'],
'one of library or client must be passed if you wish the'
' beatmap to be retrieved',
)
use_client = client is not None
if use_client:
if library is not None:
raise ValueError(
'only one of library or client can be passed'
)
library = client.library
buffer = bytearray(data)
mode = GameMode(consume_byte(buffer))
version = consume_int(buffer)
beatmap_md5 = consume_string(buffer)
player_name = consume_string(buffer)
replay_md5 = consume_string(buffer)
count_300 = consume_short(buffer)
count_100 = consume_short(buffer)
count_50 = consume_short(buffer)
count_geki = consume_short(buffer)
count_katu = consume_short(buffer)
count_miss = consume_short(buffer)
score = consume_int(buffer)
max_combo = consume_short(buffer)
full_combo = bool(consume_byte(buffer))
mod_mask = consume_int(buffer)
life_bar_graph = _consume_life_bar_graph(buffer)
timestamp = consume_datetime(buffer)
actions = _consume_actions(buffer)
library = client.library
buffer = bytearray(data)
mode = GameMode(consume_byte(buffer))
version = consume_int(buffer)
beatmap_md5 = consume_string(buffer)
player_name = consume_string(buffer)
replay_md5 = consume_string(buffer)
count_300 = consume_short(buffer)
count_100 = consume_short(buffer)
count_50 = consume_short(buffer)
count_geki = consume_short(buffer)
count_katu = consume_short(buffer)
count_miss = consume_short(buffer)
score = consume_int(buffer)
max_combo = consume_short(buffer)
full_combo = bool(consume_byte(buffer))
mod_mask = consume_int(buffer)
life_bar_graph = _consume_life_bar_graph(buffer)
timestamp = consume_datetime(buffer)
actions = _consume_actions(buffer)
mod_kwargs = Mod.unpack(mod_mask)
# delete the alias field names
del mod_kwargs['relax2']
del mod_kwargs['last_mod']
if retrieve_beatmap:
try:
beatmap = library.lookup_by_md5(beatmap_md5)
except KeyError:
mode = GameMode(consume_byte(buffer))
version = consume_int(buffer)
beatmap_md5 = consume_string(buffer)
player_name = consume_string(buffer)
replay_md5 = consume_string(buffer)
count_300 = consume_short(buffer)
count_100 = consume_short(buffer)
count_50 = consume_short(buffer)
count_geki = consume_short(buffer)
count_katu = consume_short(buffer)
count_miss = consume_short(buffer)
score = consume_int(buffer)
max_combo = consume_short(buffer)
full_combo = bool(consume_byte(buffer))
mod_mask = consume_int(buffer)
life_bar_graph = _consume_life_bar_graph(buffer)
timestamp = consume_datetime(buffer)
actions = _consume_actions(buffer)
mod_kwargs = Mod.unpack(mod_mask)
# delete the alias field names
del mod_kwargs['relax2']
del mod_kwargs['last_mod']
if retrieve_beatmap:
try:
beatmap = library.lookup_by_md5(beatmap_md5)
except KeyError:
if not use_client:
raise
beatmap = client.beatmap(