Ejemplo n.º 1
0
    def _run(self):
        variable_name = expression_parser.parse(
            self.expression_str).variable_name
        results = expression_parser.execute_within_context(
            self.context, self.expression_str)
        for result, row in itertools.izip_longest(
                results, get_table_body_rows(self.element)):
            setattr(self.context, variable_name, result)

            if result is None:
                row.attrib["class"] = (row.attrib.get("class", "") +
                                       " missing").strip()
                continue

            if row is None:
                total_columns = max(self.children, key=attrgetter(
                    "index")).index + 1  # good enough but not perfect
                row = etree.Element("tr", **{"class": "surplus"})
                for _ in xrange(total_columns):
                    etree.SubElement(row, "td")
                if self.element.xpath("//tbody"):
                    self.element.xpath("//tbody")[0].append(row)
                else:
                    self.element.append(row)

            for command in self.children:
                element = row.xpath("td")[command.index]
                command.element = element
                command.run()
Ejemplo n.º 2
0
 def _run(self):
     expression = expression_parser.parse(self.expression_str)
     if expression.function_name:  # concordion:set="blah = function(#TEXT)"
         expression_parser.execute_within_context(self.context,
                                                  self.expression_str)
     else:
         setattr(self.context, expression.variable_name,
                 get_element_content(self.element))
Ejemplo n.º 3
0
    def _run(self):
        variable_name = expression_parser.parse(self.expression_str).variable_name
        results = expression_parser.execute_within_context(self.context, self.expression_str)
        for result, row in itertools.izip_longest(results, get_table_body_rows(self.element)):
            setattr(self.context, variable_name, result)

            if result is None:
                row.attrib["class"] = (row.attrib.get("class", "") + " missing").strip()
                continue

            if row is None:
                total_columns = max(self.children, key=attrgetter("index")).index + 1  # good enough but not perfect
                row = etree.Element("tr", **{"class": "surplus"})
                for _ in xrange(total_columns):
                    etree.SubElement(row, "td")
                if self.element.xpath("//tbody"):
                    self.element.xpath("//tbody")[0].append(row)
                else:
                    self.element.append(row)

            for command in self.children:
                element = row.xpath("td")[command.index]
                command.element = element
                command.run()
Ejemplo n.º 4
0
 def _run(self):
     expression = expression_parser.parse(self.expression_str)
     if expression.function_name:  # concordion:set="blah = function(#TEXT)"
         expression_parser.execute_within_context(self.context, self.expression_str)
     else:
         setattr(self.context, expression.variable_name, get_element_content(self.element))