예제 #1
0
    def get_selected_partition(self):
        """
        Returns the name of the selected partition.
        """
        partition_select_tokens = list(token_attr_map(self.selected, "partition"))

        if len(partition_select_tokens) != 1:
            raise ParserError("Exactly one partition must be selected")

        return partition_select_tokens[0]
예제 #2
0
    def get_component(self):
        """
        Returns the component.
        """
        components = list(token_attr_map(self.selected, "component"))

        if len(components) != 1:
            raise ParserError("Process template must generate exactly one component token")

        return components[0]
예제 #3
0
    def test_token_attr_map(self):
        class T1(object):
            def __init__(self, key, value):
                self.key = key
                self.value = value

        t1 = T1('foo', 'bar')
        t2 = T1('foo', 'baz')
        tokens = [
            AddTokenOp(t1),
            SetDefaultTokenOp(t2)
        ]

        self.assertDictEqual(token_attr_map(tokens, 'key'), {
            'foo': 'foo'
        })

        self.assertDictEqual(token_attr_map(tokens, 'key', 'value'), {
            'foo': 'bar'
        })
예제 #4
0
 def get_portmap(self):
     """
     Returns a map output -> input
     """
     return token_attr_map(self.selected, "port_out", "port_in")
예제 #5
0
 def get_aliasmap(self):
     """
     Returns a map alias -> element
     """
     return token_attr_map(self.selected, "alias", "element")
예제 #6
0
 def get_partitionmap(self):
     """
     Returns a map element -> partition name
     """
     return token_attr_map(self.selected, "element", "partition")
예제 #7
0
 def get_partition_bounds(self):
     """
     Returns a map partition name -> bounds
     """
     return token_attr_map(self.selected, "partition", "bounds")
예제 #8
0
 def get_parentmap(self):
     """
     Returns a map element -> parent.
     """
     return token_attr_map(self.selected, "element", "parent")
예제 #9
0
 def get_labelmap(self):
     """
     Returns a map element -> label
     """
     return token_attr_map(self.selected, "element", "label")
예제 #10
0
 def get_descriptionmap(self):
     """
     Returns a map element -> description
     """
     return token_attr_map(self.selected, "element", "description")
예제 #11
0
 def get_portmap(self):
     """
     Returns a map element -> port
     """
     return token_attr_map(self.selected, "element", "port")