fix ValueError when converting empty string KM to float in sgf parser
Some sgfs has "KM" property with empty value, this could cause ValueError exception.
This commit is contained in:
1 parent
a3815cb47a
commit
9b09e9b65d
1 file changed
+6
-1
@@ -192,7 +192,12 @@ class SGFNode:
|
||||
@property
|
||||
def komi(self) -> float:
|
||||
"""Retrieves the root's KM property, or 6.5 if missing"""
|
||||
return float(self.root.get_property("KM", 6.5))
|
||||
try:
|
||||
km = float(self.root.get_property("KM", 6.5))
|
||||
except ValueError:
|
||||
km = 6.5
|
||||
|
||||
return km
|
||||
|
||||
@property
|
||||
def ruleset(self) -> str:
|
||||
|
||||
Reference in new issue
Block a user