Skip to content

Commit

Permalink
chore: misc changes (#228)
Browse files Browse the repository at this point in the history
* chore: misc changes

* feat: allow packing raw bytes
  • Loading branch information
NiceAesth authored Mar 3, 2024
1 parent cef4586 commit 3427090
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions aiosu/models/lazer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class LazerScore(BaseModel):
rank: str
ruleset_id: int
statistics: LazerScoreStatistics
total_score: int = Field(alias="score")
total_score: int = Field(validation_alias="score")
type: ScoreType
user_id: int
beatmap: Optional[Beatmap] = None
Expand Down Expand Up @@ -243,5 +243,3 @@ def _fail_rank(cls, values: dict[str, object]) -> dict[str, object]:


from .multiplayer import MultiplayerMatch

LazerScore.model_rebuild()
7 changes: 4 additions & 3 deletions aiosu/utils/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from datetime import datetime
from datetime import timezone
from typing import TYPE_CHECKING
from typing import Union

if TYPE_CHECKING:
from typing import BinaryIO
Expand Down Expand Up @@ -315,20 +316,20 @@ def pack_uleb128(file: BinaryIO, value: int) -> None:
break


def pack_string(file: BinaryIO, value: str) -> None:
def pack_string(file: BinaryIO, value: Union[bytes, str]) -> None:
r"""Pack a string into a file.
:param file: The file to pack into.
:type file: BinaryIO
:param value: The value to pack.
:type value: str
:type value: Union[bytes, str]
"""
pack_byte(file, 11)
if not value:
file.write(b"\x00")
return
pack_uleb128(file, len(value))
file.write(value.encode("utf-8"))
file.write(value.encode("utf-8") if isinstance(value, str) else value)


def pack_replay_data(file: BinaryIO, data: str) -> None:
Expand Down

0 comments on commit 3427090

Please sign in to comment.