Skip to content

Commit

Permalink
Add preliminary 8.12 support to fix failing CI on master
Browse files Browse the repository at this point in the history
  • Loading branch information
whonore committed Feb 16, 2020
1 parent eeaed7f commit b1cd22b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
33 changes: 32 additions & 1 deletion python/xmlInterface.py
Expand Up @@ -1277,7 +1277,38 @@ class XMLInterface811(XMLInterface810):
"""The version 8.11.* XML interface."""


XMLInterfaceLatest = XMLInterface811
class XMLInterface812(XMLInterface811):
"""The version 8.12.* XML interface."""

OptionState = namedtuple("OptionState", ["sync", "depr", "value"])

def __init__(self, versions):
# type: (Tuple[int, ...]) -> None
"""Update conversion maps with new types."""
super(XMLInterface811, self).__init__(versions)

self._standardize_funcs.update(
{"GetOptions": self._standardize_get_options,}
)

def _standardize_get_options(self, res):
# type: (Union[Ok, Err]) -> Union[Ok, Err]
"""Standardize the info returned by 'GetOptions'.
Return:
opts: list (string * string * ?) - Triples of all option names,
descriptions, and current values
"""
if isinstance(res, Ok):
raw_opts = res.val # type: List[Tuple[Text, XMLInterface812.OptionState]]
opts = [
(" ".join(name), " ".join(name), state.value.val)
for name, state in raw_opts
] # type: List[Tuple[Text, Text, Any]]
res.val = opts
return res


XMLInterfaceLatest = XMLInterface812


def XMLInterface(version):
Expand Down
17 changes: 12 additions & 5 deletions tests/test_xmlInterface.py
Expand Up @@ -243,11 +243,18 @@ def option_state(self):
true = self.true()
abc = self.abc()
opt = self.option_value_bool()
return PyXML(
self.xi.OptionState(true.py, true.py, abc.py, opt.py),
mkXML("option_state", children=[true, true, abc, opt]),
False,
)
if self.xi.versions < (8, 12, 0):
return PyXML(
self.xi.OptionState(true.py, true.py, abc.py, opt.py),
mkXML("option_state", children=[true, true, abc, opt]),
False,
)
else:
return PyXML(
self.xi.OptionState(true.py, true.py, opt.py),
mkXML("option_state", children=[true, true, opt]),
False,
)

def status(self):
one = self.one()
Expand Down

0 comments on commit b1cd22b

Please sign in to comment.