當前位置: 首頁>>代碼示例>>Python>>正文


Python ET.parse方法代碼示例

本文整理匯總了Python中robot.utils.ET.parse方法的典型用法代碼示例。如果您正苦於以下問題:Python ET.parse方法的具體用法?Python ET.parse怎麽用?Python ET.parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在robot.utils.ET的用法示例。


在下文中一共展示了ET.parse方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _verify_node

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:10,代碼來源:test_xmlwriter.py

示例2: _parse_spec

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:10,代碼來源:specbuilder.py

示例3: test_rows_are_not_split_if_there_are_headers

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:11,代碼來源:test_filewriters.py

示例4: test_rows_are_not_split_if_there_are_headers

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:11,代碼來源:test_filewriters.py

示例5: test_content_with_unicode

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:12,代碼來源:test_xmlwriter.py

示例6: test_write_many_elements

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:18,代碼來源:test_xmlwriter.py

示例7: parse_xml

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
    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,代碼行數:21,代碼來源:XML.py

示例8: get_interpreter

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
def get_interpreter(output):
    tree = ET.parse(output)
    root = tree.getroot()
    return Interpreter(*MATCHER.match(root.attrib['generator']).groups())
開發者ID:userzimmermann,項目名稱:robotframework-python3,代碼行數:6,代碼來源:read_interpreter.py

示例9: _xml_lines

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 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,代碼行數:8,代碼來源:test_resultserializer.py

示例10: _get_root

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 def _get_root(self):
     self.writer.close()
     with ETSource(PATH) as source:
         return ET.parse(source).getroot()
開發者ID:Apaking,項目名稱:robotframework,代碼行數:6,代碼來源:test_xmlwriter.py

示例11: parse_xml

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 def parse_xml(self, source):
     with ETSource(source) as source:
         return ET.parse(source).getroot()
開發者ID:Senseg,項目名稱:robotframework,代碼行數:5,代碼來源:XmlLibrary.py

示例12: _parse_spec

# 需要導入模塊: from robot.utils import ET [as 別名]
# 或者: from robot.utils.ET import parse [as 別名]
 def _parse_spec(self, path):
     with ETSource(path) as source:
         return ET.parse(source).getroot()
開發者ID:EnochManohar,項目名稱:RIDE,代碼行數:5,代碼來源:specbuilder.py


注:本文中的robot.utils.ET.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。