Skip to content

Commit

Permalink
foxwq workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Land committed Aug 28, 2020
1 parent f4b38e7 commit fd67ea8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion katrain/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"anim_pv_time": 0.5,
"debug_level": 0,
"lang": "en",
"version": "1.4.0"
"version": "1.4.1"
},
"timer": {
"byo_length": 30,
Expand Down
2 changes: 1 addition & 1 deletion katrain/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "1.4.0"
VERSION = "1.4.1"
HOMEPAGE = "https://github.com/sanderland/katrain"
CONFIG_MIN_VERSION = "1.4.0" # keep config files from this version

Expand Down
8 changes: 6 additions & 2 deletions katrain/core/sgf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ def parse_sgf(cls, input_str) -> SGFNode:
"""Parse a string as SGF."""
match = re.search(cls.SGF_PAT, input_str)
clipped_str = match.group() if match else input_str
return cls(clipped_str).root
root = cls(clipped_str).root
if "foxwq" in root.get_list_property("AP"):
fixed_komi = 0.5 if root.get_property("HA") == 1 else 7.5
root.set_property("KM", fixed_komi)
return root

@classmethod
def parse_file(cls, filename, encoding=None) -> SGFNode:
Expand All @@ -343,7 +347,7 @@ def parse_file(cls, filename, encoding=None) -> SGFNode:
with open(filename, "rb") as f:
bin_contents = f.read()
if not encoding:
if is_gib or is_ngf:
if is_gib or is_ngf or b"AP[foxwq]" in bin_contents:
encoding = "utf8"
else: # sgf
match = re.search(rb"CA\[(.*?)\]", bin_contents)
Expand Down

0 comments on commit fd67ea8

Please sign in to comment.