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


Python xmlutil.safe_minidom_parse_string函数代码示例

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


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

示例1: default

 def default(self, string):
     events = []
     dom = xmlutil.safe_minidom_parse_string(string)
     events_node = self.find_first_child_named(dom, "events")
     for event_node in self.find_children_named(events_node, "event"):
         events.append(self._extract_event(event_node))
     return {"body": {"events": events}}
开发者ID:gilmeir,项目名称:nova,代码行数:7,代码来源:server_external_events.py

示例2: action_peek_xml

def action_peek_xml(body):
    """Determine action to invoke."""

    dom = xmlutil.safe_minidom_parse_string(body)
    action_node = dom.childNodes[0]

    return action_node.tagName
开发者ID:CrazyTeaFs,项目名称:nova,代码行数:7,代码来源:wsgi.py

示例3: deserialize

 def deserialize(self, text):
     dom = xmlutil.safe_minidom_parse_string(text)
     metadata_node = self.find_first_child_named(dom, "metadata")
     key = metadata_node.getAttribute("key")
     metadata = {}
     metadata[key] = self.extract_text(metadata_node)
     return {'body': {'metadata': metadata}}
开发者ID:674009287,项目名称:nova,代码行数:7,代码来源:server_metadata.py

示例4: default

 def default(self, string):
     dom = xmlutil.safe_minidom_parse_string(string)
     action_node = dom.childNodes[0]
     action_name = action_node.tagName
     action_data = None
     if action_node.hasAttribute("admin_password"):
         action_data = {'admin_password':
                        action_node.getAttribute("admin_password")}
     return {'body': {action_name: action_data}}
开发者ID:674009287,项目名称:nova,代码行数:9,代码来源:admin_password.py

示例5: default

    def default(self, string):
        node = xmlutil.safe_minidom_parse_string(string)
        service = {}
        service_node = self.find_first_child_named(node, 'service')
        if service_node is None:
            return service
        service['host'] = service_node.getAttribute('host')
        service['binary'] = service_node.getAttribute('binary')

        return dict(body=service)
开发者ID:CiscoAS,项目名称:nova,代码行数:10,代码来源:services.py

示例6: default

    def default(self, string):
        node = xmlutil.safe_minidom_parse_string(string)
        service = {}
        service_node = self.find_first_child_named(node, "service")
        if service_node is None:
            return service
        service["host"] = service_node.getAttribute("host")
        service["binary"] = service_node.getAttribute("binary")
        service["disabled_reason"] = service_node.getAttribute("disabled_reason")

        return dict(body=service)
开发者ID:habuka036,项目名称:nova,代码行数:11,代码来源:services.py

示例7: default

 def default(self, string):
     """Deserialize an xml-formatted security group create request."""
     dom = xmlutil.safe_minidom_parse_string(string)
     security_group = {}
     sg_node = self.find_first_child_named(dom, "security_group")
     if sg_node is not None:
         if sg_node.hasAttribute("name"):
             security_group["name"] = sg_node.getAttribute("name")
         desc_node = self.find_first_child_named(sg_node, "description")
         if desc_node:
             security_group["description"] = self.extract_text(desc_node)
     return {"body": {"security_group": security_group}}
开发者ID:kevinbenton,项目名称:nova,代码行数:12,代码来源:security_groups.py

示例8: test_safe_parse_xml

    def test_safe_parse_xml(self):

        normal_body = ('<?xml version="1.0" ?>'
                       '<foo><bar><v1>hey</v1><v2>there</v2></bar></foo>')

        dom = xmlutil.safe_minidom_parse_string(normal_body)
        # Some versions of minidom inject extra newlines so we ignore them
        result = str(dom.toxml()).replace('\n', '')
        self.assertEqual(normal_body, result)

        self.assertRaises(exception.MalformedRequestBody,
                          xmlutil.safe_minidom_parse_string,
                          tests_utils.killer_xml_body())
开发者ID:AsherBond,项目名称:nova,代码行数:13,代码来源:test_xmlutil.py

示例9: default

    def default(self, string):
        node = xmlutil.safe_minidom_parse_string(string)

        updates = {}
        updates_node = self.find_first_child_named(node, "updates")
        if updates_node is not None:
            maintenance = self.find_first_child_named(updates_node, "maintenance_mode")
            if maintenance is not None:
                updates[maintenance.tagName] = self.extract_text(maintenance)

            status = self.find_first_child_named(updates_node, "status")
            if status is not None:
                updates[status.tagName] = self.extract_text(status)

        return dict(body=updates)
开发者ID:B-Rich,项目名称:nova-1,代码行数:15,代码来源:hosts.py

示例10: test_safe_parse_xml

    def test_safe_parse_xml(self):

        normal_body = ("""
                 <?xml version="1.0" ?><foo>
                    <bar>
                        <v1>hey</v1>
                        <v2>there</v2>
                    </bar>
                </foo>""").strip()

        dom = xmlutil.safe_minidom_parse_string(normal_body)
        self.assertEqual(normal_body, str(dom.toxml()))

        self.assertRaises(exception.MalformedRequestBody,
                          xmlutil.safe_minidom_parse_string,
                          tests_utils.killer_xml_body())
开发者ID:Guoweiwei1130,项目名称:openstack,代码行数:16,代码来源:test_xmlutil.py

示例11: default

 def default(self, string):
     """Deserialize an xml-formatted volume create request."""
     dom = xmlutil.safe_minidom_parse_string(string)
     vol = self._extract_volume(dom)
     return {"body": {"volume": vol}}
开发者ID:joydraft,项目名称:nova,代码行数:5,代码来源:volumes.py

示例12: _extract_metadata_container

 def _extract_metadata_container(self, datastring):
     dom = xmlutil.safe_minidom_parse_string(datastring)
     metadata_node = self.find_first_child_named(dom, "metadata")
     metadata = self.extract_metadata(metadata_node)
     return {'body': {'metadata': metadata}}
开发者ID:anjoah,项目名称:nova,代码行数:5,代码来源:common.py

示例13: update

 def update(self, datastring):
     dom = xmlutil.safe_minidom_parse_string(datastring)
     metadata_item = self.extract_metadata(dom)
     return {'body': {'meta': metadata_item}}
开发者ID:anjoah,项目名称:nova,代码行数:4,代码来源:common.py

示例14: deserialize

 def deserialize(self, text):
     dom = xmlutil.safe_minidom_parse_string(text)
     metadata_node = self.find_first_child_named(dom, "metadata")
     metadata = self.extract_metadata(metadata_node)
     return {'body': {'metadata': metadata}}
开发者ID:anjoah,项目名称:nova,代码行数:5,代码来源:common.py

示例15: default

 def default(self, string):
     """Deserialize an xml-formatted security group create request."""
     dom = xmlutil.safe_minidom_parse_string(string)
     security_group_rule = self._extract_security_group_rule(dom)
     return {'body': {'security_group_rule': security_group_rule}}
开发者ID:YankunLi,项目名称:nova,代码行数:5,代码来源:security_groups.py


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