Skip to content

Commit f4b0183

Browse files
Update docstring
1 parent 5eb929c commit f4b0183

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

opengsq/responses/source/environment.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,18 @@ class Environment(IntEnum):
1717

1818
@staticmethod
1919
def parse(byte: int):
20-
return Environment(ord(chr(byte).lower()))
20+
"""
21+
Parses the given byte to an Environment value. If the byte does not correspond to a valid
22+
Environment value, it defaults to Environment.Mac.
23+
24+
Args:
25+
byte (int): The byte to parse.
26+
27+
Returns:
28+
Environment: The corresponding Environment value, or Environment.Mac if the byte is not valid.
29+
"""
30+
try:
31+
return Environment(ord(chr(byte).lower()))
32+
except ValueError:
33+
# 'm' or 'o' for Mac (the code changed after L4D1)
34+
return Environment.Mac

opengsq/responses/source/server_type.py

+10
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,14 @@ class ServerType(IntEnum):
1717

1818
@staticmethod
1919
def parse(byte: int):
20+
"""
21+
Parses the given byte to a ServerType value. If the byte does not correspond to a valid
22+
ServerType value, a ValueError is raised.
23+
24+
Args:
25+
byte (int): The byte to parse.
26+
27+
Returns:
28+
ServerType: The corresponding ServerType value.
29+
"""
2030
return ServerType(ord(chr(byte).lower()))

0 commit comments

Comments
 (0)