File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,18 @@ class Environment(IntEnum):
17
17
18
18
@staticmethod
19
19
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):
17
17
18
18
@staticmethod
19
19
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
+ """
20
30
return ServerType (ord (chr (byte ).lower ()))
You can’t perform that action at this time.
0 commit comments