当前位置: 首页>>代码示例>>Python>>正文


Python utils.ET类代码示例

本文整理汇总了Python中robot.utils.ET的典型用法代码示例。如果您正苦于以下问题:Python ET类的具体用法?Python ET怎么用?Python ET使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ET类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _parse_spec

 def _parse_spec(self, path):
     if not os.path.isfile(path):
         raise DataError("Spec file '%s' does not exist." % path)
     with ETSource(path) as source:
         root = ET.parse(source).getroot()
     if root.tag != 'keywordspec':
         raise DataError("Invalid spec file '%s'." % path)
     return root
开发者ID:userzimmermann,项目名称:robotframework-python3,代码行数:8,代码来源:specbuilder.py

示例2: _verify_node

 def _verify_node(self, node, name, text=None, attrs={}):
     if node is None:
         with ETSource(PATH) as source:
             node = ET.parse(source).getroot()
     assert_equals(node.tag, name)
     if text is not None:
         assert_equals(node.text, text)
     assert_equals(node.attrib, attrs)
开发者ID:quangdt,项目名称:plan_come_on_baby,代码行数:8,代码来源:test_xmlwriter.py

示例3: build

 def build(self, result):
     handler = XmlElementHandler(result)
     # Faster attribute lookup inside for loop
     start, end = handler.start, handler.end
     with self._source as source:
         for event, elem in ET.iterparse(source, events=('start', 'end')):
             start(elem) if event == 'start' else end(elem)
     SuiteTeardownFailureHandler(result.generator).visit_suite(result.suite)
     return result
开发者ID:IlfirinPL,项目名称:RIDE,代码行数:9,代码来源:executionresult.py

示例4: test_rows_are_not_split_if_there_are_headers

 def test_rows_are_not_split_if_there_are_headers(self):
     output = self._add_long_step_and_save("html")
     with ETSource("\n".join(output.splitlines()[1:])) as source:
         tree = ET.parse(source)
     lines = tree.findall("body/table/tr")
     assert_equals(len(lines), 3)
     for l in lines:
         cols = l.findall("td") or l.findall("th")
         assert_equals(len(cols), 9)
开发者ID:nurruden,项目名称:robotframework,代码行数:9,代码来源:test_filewriters.py

示例5: test_rows_are_not_split_if_there_are_headers

 def test_rows_are_not_split_if_there_are_headers(self):
     output = self._add_long_step_and_save('html')
     with ETSource('\n'.join(output.splitlines()[1:])) as source:
         tree = ET.parse(source)
     lines = tree.findall('body/table/tr')
     assert_equal(len(lines), 3)
     for l in lines:
         cols = l.findall('td') or l.findall('th')
         assert_equal(len(cols), 9)
开发者ID:koonchaim,项目名称:robotframework,代码行数:9,代码来源:test_filewriters.py

示例6: _parse

 def _parse(self, source, start, end):
     context = ET.iterparse(source, events=('start', 'end'))
     if not self._include_keywords:
         context = self._omit_keywords(context)
     for event, elem in context:
         if event == 'start':
             start(elem)
         else:
             end(elem)
             elem.clear()
开发者ID:agalitz,项目名称:robotframework,代码行数:10,代码来源:resultbuilder.py

示例7: test_content_with_unicode

 def test_content_with_unicode(self):
     self.writer.start("root")
     self.writer.element(u"e", u"Circle is 360\u00B0")
     self.writer.element(u"f", u"Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4")
     self.writer.end("root")
     self.writer.close()
     with ETSource(PATH) as source:
         root = ET.parse(source).getroot()
     self._verify_node(root.find("e"), "e", u"Circle is 360\u00B0")
     self._verify_node(root.find("f"), "f", u"Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4")
开发者ID:quangdt,项目名称:plan_come_on_baby,代码行数:10,代码来源:test_xmlwriter.py

示例8: _parse

 def _parse(self, source, start, end):
     context = ET.iterparse(source, events=("start", "end"))
     if not self._include_keywords:
         context = self._omit_keywords(context)
     elif self._flattened_keywords:
         context = self._flatten_keywords(context, self._flattened_keywords)
     for event, elem in context:
         if event == "start":
             start(elem)
         else:
             end(elem)
             elem.clear()
开发者ID:Exarchiasghost,项目名称:robotframework,代码行数:12,代码来源:resultbuilder.py

示例9: element_to_string

    def element_to_string(self, source, xpath="."):
        """Returns the string representation of the specified element.

        The element to convert to a string is specified using `source` and
        `xpath`. They have exactly the same semantics as with `Get Element`
        keyword.

        The returned string is in Unicode format and it does not contain any
        XML declaration.

        See also `Log Element`.
        """
        string = ET.tostring(self.get_element(source, xpath), encoding="UTF-8")
        return self._xml_declaration.sub("", string.decode("UTF-8")).strip()
开发者ID:quangdt,项目名称:plan_come_on_baby,代码行数:14,代码来源:XML.py

示例10: test_write_many_elements

 def test_write_many_elements(self):
     self.writer.start("root", {"version": "test"})
     self.writer.start("child1", {"my-attr": "my value"})
     self.writer.element("leaf1.1", "leaf content", {"type": "kw"})
     self.writer.element("leaf1.2")
     self.writer.end("child1")
     self.writer.element("child2", attrs={"class": "foo"})
     self.writer.end("root")
     self.writer.close()
     with ETSource(PATH) as source:
         root = ET.parse(source).getroot()
     self._verify_node(root, "root", attrs={"version": "test"})
     self._verify_node(root.find("child1"), "child1", attrs={"my-attr": "my value"})
     self._verify_node(root.find("child1/leaf1.1"), "leaf1.1", "leaf content", {"type": "kw"})
     self._verify_node(root.find("child1/leaf1.2"), "leaf1.2")
     self._verify_node(root.find("child2"), "child2", attrs={"class": "foo"})
开发者ID:quangdt,项目名称:plan_come_on_baby,代码行数:16,代码来源:test_xmlwriter.py

示例11: parse_xml

    def parse_xml(self, source):
        """Parses the given XML file or string into an element structure.

        The `source` can either be a path to an XML file or a string containing
        XML. In both cases the XML is parsed into ElementTree
        [http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.Element|element structure]
        and the root element is returned.

        Examples:
        | ${xml} =  | Parse XML | ${CURDIR}/test.xml    |
        | ${root} = | Parse XML | <root><child/></root> |

        For more details and examples, see `Parsing XML` section in the
        `introduction`.

        See also `Get Element` and `Get Elements`.
        """
        with ETSource(source) as source:
            return ET.parse(source).getroot()
开发者ID:quangdt,项目名称:plan_come_on_baby,代码行数:19,代码来源:XML.py

示例12: get_interpreter

def get_interpreter(output):
    tree = ET.parse(output)
    root = tree.getroot()
    return Interpreter(*MATCHER.match(root.attrib['generator']).groups())
开发者ID:userzimmermann,项目名称:robotframework-python3,代码行数:4,代码来源:read_interpreter.py

示例13: _xml_lines

 def _xml_lines(self, text):
     with ETSource(text) as source:
         tree = ET.parse(source)
     output = StringIO()
     tree.write(output)
     return output.getvalue().splitlines()
开发者ID:Apaking,项目名称:robotframework,代码行数:6,代码来源:test_resultserializer.py

示例14: _get_root

 def _get_root(self):
     self.writer.close()
     with ETSource(PATH) as source:
         return ET.parse(source).getroot()
开发者ID:Apaking,项目名称:robotframework,代码行数:4,代码来源:test_xmlwriter.py

示例15: parse_xml

 def parse_xml(self, source):
     with ETSource(source) as source:
         return ET.parse(source).getroot()
开发者ID:Senseg,项目名称:robotframework,代码行数:3,代码来源:XmlLibrary.py


注:本文中的robot.utils.ET类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。