def patch(node, permutation): """ Replaces all occourences with incoming values """ modified = False if node.type == "identifier" or node.type == "dot": if node.type == "dot": name = assembleDot(node) else: name = node.value replacement = __translateToValue(permutation.get(name)) if replacement: Console.debug("Found permutation query (%s => %s) in line %s", name, replacement, node.line) replacementNode = Parser.parseExpression(replacement) node.parent.replace(node, replacementNode) modified = True # Process children for child in reversed(node): if child != None: if patch(child, permutation): modified = True return modified
def __getTree(self, context=None): """ Returns the parsed tree """ field = "tree[%s]" % self.id tree = self.project.getCache().read(field, self.mtime) if not tree: Console.info( "Processing stylesheet %s %s...", Console.colorize(self.id, "bold"), Console.colorize("[%s]" % context, "cyan"), ) Console.indent() tree = Parser.parse(self.getText(), self.id) Console.outdent() self.project.getCache().store(field, tree, self.mtime, True) return tree
def getTree(text, fileId=None): """ Returns a tree of nodes from the given text """ return Parser.parse(text, fileId)
def getTree(text, fileId=None): """Returns a tree of nodes from the given text.""" return Parser.parse(text, fileId)