示例#1
0
文件: Style.py 项目: Zenwolf/jasy
    def __getOptimizedTree(self, permutation=None, context=None):
        """
        Returns an optimized tree with permutations applied
        """

        field = "opt-tree[%s]-%s" % (self.id, permutation)
        tree = self.project.getCache().read(field, self.mtime)
        if not tree:
            tree = copy.deepcopy(self.__getTree("%s:plain" % context))

            # Logging
            msg = "Processing stylesheet %s" % Console.colorize(self.id, "bold")
            if permutation:
                msg += Console.colorize(" (%s)" % permutation, "grey")
            if context:
                msg += Console.colorize(" [%s]" % context, "cyan")

            Console.info("%s..." % msg)
            Console.indent()

            # Apply permutation
            if permutation:
                Console.debug("Patching tree with permutation: %s", permutation)
                Console.indent()
                Permutate.patch(tree, permutation)
                Console.outdent()

            self.project.getCache().store(field, tree, self.mtime, True)
            Console.outdent()

        return tree
示例#2
0
def permutateTree(tree, permutation=None):
    """Returns an optimized tree with permutations applied."""

    if permutation:
        Permutate.patch(tree, permutation)
        return tree

    else:
        return tree
示例#3
0
def permutateTree(tree, permutation=None):
    """Returns an optimized tree with permutations applied."""

    if permutation:
        Permutate.patch(tree, permutation)
        return tree

    else:
        return tree