Use OrderedDict

This commit is contained in:
Emily 2019-09-01 14:14:33 +00:00
parent 8b7ebbe7e0
commit ad7c608df6

View File

@ -3,6 +3,8 @@ import string
#import lzma #import lzma
import pylzma # Required cause pythons standard library lzma has missing support import pylzma # Required cause pythons standard library lzma has missing support
from collections import OrderedDict
from .frame import ReplayFrame from .frame import ReplayFrame
from .helpers import osuModes from .helpers import osuModes
@ -45,32 +47,32 @@ def lzma_compress(data):
return struct.pack("<I", len(comp)) + comp # For some odd ass reason this doesnt use ULEB return struct.pack("<I", len(comp)) + comp # For some odd ass reason this doesnt use ULEB
class Replay: class Replay:
structure = { structure = OrderedDict([
"mode": Serializable(osuModes.STANDARD, TYPE_BYTE), ("mode", Serializable(osuModes.STANDARD, TYPE_BYTE)),
"osu_version": Serializable(20181216, TYPE_INT), ("osu_version", Serializable(20181216, TYPE_INT)),
"beatmap_hash": Serializable(b"d41d8cd98f00b204e9800998ecf8427e", TYPE_STRING), ("beatmap_hash",Serializable(b"d41d8cd98f00b204e9800998ecf8427e", TYPE_STRING)),
"player_name": Serializable(b"osu!", TYPE_STRING), ("player_name", Serializable(b"osu!", TYPE_STRING)),
"score_hash": Serializable(b"d41d8cd98f00b204e9800998ecf8427e", TYPE_STRING), ("score_hash", Serializable(b"d41d8cd98f00b204e9800998ecf8427e", TYPE_STRING)),
"score_300s": Serializable(0, TYPE_USHORT), ("score_300s", Serializable(0, TYPE_USHORT)),
"score_100s": Serializable(0, TYPE_USHORT), ("score_100s", Serializable(0, TYPE_USHORT)),
"score_50s": Serializable(0, TYPE_USHORT), ("score_50s", Serializable(0, TYPE_USHORT)),
"score_gekis": Serializable(0, TYPE_USHORT), ("score_gekis", Serializable(0, TYPE_USHORT)),
"score_katus": Serializable(0, TYPE_USHORT), ("score_katus", Serializable(0, TYPE_USHORT)),
"score_miss": Serializable(0, TYPE_USHORT), ("score_miss", Serializable(0, TYPE_USHORT)),
"score": Serializable(0, TYPE_INT), ("score", Serializable(0, TYPE_INT)),
"combo": Serializable(0, TYPE_USHORT), ("combo", Serializable(0, TYPE_USHORT)),
"perfect": Serializable(True, TYPE_BOOL), ("perfect", Serializable(True, TYPE_BOOL)),
"mods": Serializable(osuMods.NOMOD, TYPE_INT), ("mods", Serializable(osuMods.NOMOD, TYPE_INT)),
"lifebar_graph": Serializable(b"0|1,", TYPE_STRING), ("lifebar_graph", Serializable(b"0|1,", TYPE_STRING)),
"timestamp": Serializable(0, TYPE_ULLONG), ("timestamp", Serializable(0, TYPE_ULLONG)),
"replay_data": Serializable(b"", TYPE_BYTESTREAM, post = append_and_compress), ("replay_data", Serializable(b"", TYPE_BYTESTREAM, post = append_and_compress)),
"online_score_id": Serializable(0, TYPE_ULLONG) ("online_score_id", Serializable(0, TYPE_ULLONG))
} ])
def __init__(self, **kwargs): def __init__(self, **kwargs):
allowed_kwargs = { allowed_kwargs = {