Skip to content

Commit

Permalink
Fix handling multiple features in on line
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami authored and niklasf committed Apr 20, 2018
1 parent bfb1b76 commit 794004a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions chess/xboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import concurrent.futures
import shlex
import threading

from chess.engine import EngineTerminatedException
Expand Down Expand Up @@ -397,9 +398,8 @@ def _feature(self, features):
Does not conform to the CECP spec regarding `done` and instead reads all
the features atomically.
"""
if features.startswith("option"):
features = features.replace("\"", "")
params = features.split("=")[1].split()
def _option(feature):
params = feature.split()
name = params[0]
type = params[1][1:]
default = None
Expand Down Expand Up @@ -431,12 +431,13 @@ def _feature(self, features):
self.features.set_option(option.name, option)
return

features = features.split()
features = shlex.split(features)
feature_map = [feature.split("=") for feature in features]
for (key, value) in feature_map:
value = value.strip("\"")
if key == "variant":
self.features.set_feature(key, value.split(","))
elif key == "option":
_option(value)
else:
self.features.set_feature(key, value)

Expand Down

0 comments on commit 794004a

Please sign in to comment.