コード例 #1
0
ファイル: Style.py プロジェクト: isabella232/jasy
def includeGenerator(node):
    """A generator which yiels include names and the origin include nodes for every include in the given root node."""

    for child in node:
        if child:
            if child.type == "include":
                valueNode = child[0]
                if valueNode.type in ("string", "identifier"):
                    includeName = valueNode.value
                elif valueNode.type == "dot":
                    includeName = Util.assembleDot(valueNode)
                else:
                    raise Exception("Invalid include: %s" % valueNode)

                yield includeName, child

            else:
                includeGenerator(child)
コード例 #2
0
ファイル: Style.py プロジェクト: Zenwolf/jasy
        def resolveIncludesRecurser(node):
            for child in node:
                if child.type == "include":
                    valueNode = child[0]
                    if valueNode.type in ("string", "identifier"):
                        includeName = valueNode.value
                    elif valueNode.type == "dot":
                        includeName = Util.assembleDot(valueNode)
                    else:
                        raise Exception("Invalid include: %s" % valueNode)

                    childStyleItem = session.getStyleByName(includeName)

                    # Use merged tree for children as well...
                    childRoot = childStyleItem.getMergedTree(permutation, session)

                    # and copy it for being free to modify it
                    childRoot = copy.deepcopy(childRoot)

                    node.replace(child, childRoot)

                else:
                    resolveIncludesRecurser(child)