From fd67ea84912686c585ccfd86220797d4a21e6ce5 Mon Sep 17 00:00:00 2001 From: Sander Land Date: Fri, 28 Aug 2020 14:50:07 +0200 Subject: [PATCH] foxwq workarounds --- katrain/config.json | 2 +- katrain/core/constants.py | 2 +- katrain/core/sgf_parser.py | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/katrain/config.json b/katrain/config.json index 6c51d8a..c4f103f 100644 --- a/katrain/config.json +++ b/katrain/config.json @@ -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, diff --git a/katrain/core/constants.py b/katrain/core/constants.py index d37d410..f0d880e 100644 --- a/katrain/core/constants.py +++ b/katrain/core/constants.py @@ -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 diff --git a/katrain/core/sgf_parser.py b/katrain/core/sgf_parser.py index fd3ca01..000809e 100644 --- a/katrain/core/sgf_parser.py +++ b/katrain/core/sgf_parser.py @@ -332,7 +332,11 @@ class SGF: """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: @@ -343,7 +347,7 @@ class SGF: 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)