File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ()))
You can’t perform that action at this time.
0 commit comments