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]
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]
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' })
def get_portmap(self): """ Returns a map output -> input """ return token_attr_map(self.selected, "port_out", "port_in")
def get_aliasmap(self): """ Returns a map alias -> element """ return token_attr_map(self.selected, "alias", "element")
def get_partitionmap(self): """ Returns a map element -> partition name """ return token_attr_map(self.selected, "element", "partition")
def get_partition_bounds(self): """ Returns a map partition name -> bounds """ return token_attr_map(self.selected, "partition", "bounds")
def get_parentmap(self): """ Returns a map element -> parent. """ return token_attr_map(self.selected, "element", "parent")
def get_labelmap(self): """ Returns a map element -> label """ return token_attr_map(self.selected, "element", "label")
def get_descriptionmap(self): """ Returns a map element -> description """ return token_attr_map(self.selected, "element", "description")
def get_portmap(self): """ Returns a map element -> port """ return token_attr_map(self.selected, "element", "port")