Exemple #1
0
    @property
    def elements(self):
        return []

def parse(file):
    return Svg.parse(file)

def label_iter(image):
    for child in image:
        if (
            isinstance(child, Tag) and
            child.name == 'g' and
            'inkscape:label' in child
        ):
            yield child['inkscape:label']

labels = wrap(list)(label_iter)

def label_layer_iter(image):
    for child in image:
        if (
            isinstance(child, Tag) and
            child.name == 'g' and
            'inkscape:label' in child
        ):
            yield (child['inkscape:label'], child)

label_layer = wrap(dict)(label_layer_iter)

Exemple #2
0
        inner_visited.add(key)

        for inner in lt_table[key]:
            if inner in visited:
                continue
            for item in inner_topo_sorted(inner, inner_visited):
                yield item

        yield key

    for key in items:
        if key not in visited:
            for line in inner_topo_sorted(key):
                yield line

topo_sorted = wrap(list)(topo_sorted_iter)

class Rules(dict):

    def __getitem__(self, key):
        if key not in self:
            self[key] = set() 
        return super(Rules, self).__getitem__(key)

def parse_rules(labels, rules_files):

    edges = tuple(
        chain(*[
            blocks(uncomment(rules_file))
            for rules_file in rules_files
        ])