Exemple #1
0
def parse_rxspec(rxspec):
    if not isinstance(rxspec, list):
        rxspec = [rxspec]

    node_spec = {"rw_name": rxspec[0]}
    for spec in rxspec[1:]:
        if first_nested(spec) in mods.values():
            node_spec["modifier"] = parse_rxspec(spec)

        else:
            node_spec["children"] = [parse_rxspec(child) for child in spec]

    return node_spec
Exemple #2
0
    def parse_rxspec(self, rxspec: RxSpec) -> NodeSpec:
        if not isinstance(rxspec, list):
            rxspec = [rxspec]

        node_spec = {"rw_name": rxspec[0]}
        for spec in rxspec[1:]:
            if self._rxwrappers.wrapper_is_type(first_nested(spec), "mod"):
                node_spec["modifier"] = self.parse_rxspec(spec)

            else:
                node_spec["children"] = [
                    self.parse_rxspec(child) for child in spec
                ]

        return node_spec
Exemple #3
0
 def test_nested_first_nested_list(self):
     data = [[["first", "second"], [["third"], "fourth", "fifth"], "sixth"]]
     result = first_nested(data)
     self.assertEqual(result, "first")
Exemple #4
0
 def test_nested_first_flat_list(self):
     data = ["first", "second", "third"]
     result = first_nested(data)
     self.assertEqual(result, "first")
Exemple #5
0
 def test_nested_first_value(self):
     data = "first"
     result = first_nested(data)
     self.assertEqual(result, "first")