Skip to content

Commit

Permalink
Update docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Feb 7, 2024
1 parent 5eb929c commit f4b0183
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 15 additions & 1 deletion opengsq/responses/source/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,18 @@ class Environment(IntEnum):

@staticmethod
def parse(byte: int):
return Environment(ord(chr(byte).lower()))
"""
Parses the given byte to an Environment value. If the byte does not correspond to a valid
Environment value, it defaults to Environment.Mac.
Args:
byte (int): The byte to parse.
Returns:
Environment: The corresponding Environment value, or Environment.Mac if the byte is not valid.
"""
try:
return Environment(ord(chr(byte).lower()))
except ValueError:
# 'm' or 'o' for Mac (the code changed after L4D1)
return Environment.Mac
10 changes: 10 additions & 0 deletions opengsq/responses/source/server_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@ class ServerType(IntEnum):

@staticmethod
def parse(byte: int):
"""
Parses the given byte to a ServerType value. If the byte does not correspond to a valid
ServerType value, a ValueError is raised.
Args:
byte (int): The byte to parse.
Returns:
ServerType: The corresponding ServerType value.
"""
return ServerType(ord(chr(byte).lower()))

0 comments on commit f4b0183

Please sign in to comment.