• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xml.XmlDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_boolean

    def test_boolean(self):
        b = etree.Element('test')
        XmlDocument().to_parent(None, Boolean, True, b, ns_test)
        b = b[0]
        self.assertEquals('true', b.text)

        b = etree.Element('test')
        XmlDocument().to_parent(None, Boolean, 0, b, ns_test)
        b = b[0]
        self.assertEquals('false', b.text)

        b = etree.Element('test')
        XmlDocument().to_parent(None, Boolean, 1, b, ns_test)
        b = b[0]
        self.assertEquals('true', b.text)

        b = XmlDocument().from_element(None, Boolean, b)
        self.assertEquals(b, True)

        b = etree.Element('test')
        XmlDocument().to_parent(None, Boolean, False, b, ns_test)
        b = b[0]
        self.assertEquals('false', b.text)

        b = XmlDocument().from_element(None, Boolean, b)
        self.assertEquals(b, False)

        b = etree.Element('test')
        XmlDocument().to_parent(None, Boolean, None, b, ns_test)
        b = b[0]
        self.assertEquals('true', b.get('{%s}nil' % ns.xsi))

        b = XmlDocument().from_element(None, Boolean, b)
        self.assertEquals(b, None)
开发者ID:jpunwin,项目名称:spyne,代码行数:34,代码来源:test_primitive.py


示例2: get_xml_as_object

def get_xml_as_object(elt, cls):
    '''Returns a native :class:`spyne.model.complex.ComplexModel` child from an
    ElementTree representation of the same class.

    :param value: The class the xml document represents.
    :param value: The xml document to be deserialized.
    '''

    xml_object = XmlDocument()

    return xml_object.from_element(cls, elt)
开发者ID:Bluehorn,项目名称:spyne,代码行数:11,代码来源:xml.py


示例3: __init__

    def __init__(self, app=None, validator=None, wrapped=True,
                                xml_declaration=True, cleanup_namespaces=True):
        XmlDocument.__init__(self, app, validator, xml_declaration,
                                                             cleanup_namespaces)

        self.__wrapped = wrapped

        # SOAP requires DateTime strings to be in iso format. This function
        # bypasses datetime formatting via DateTime(format="...") string.
        self.serialization_handlers[DateTime] = _datetime_to_parent_element
        self.deserialization_handlers[DateTime] = _datetime_from_element
开发者ID:rahims,项目名称:spyne,代码行数:11,代码来源:soap11.py


示例4: __init__

    def __init__(self, app=None, validator=None, xml_declaration=True,
                cleanup_namespaces=True, encoding='UTF-8', pretty_print=False):
        XmlDocument.__init__(self, app, validator, xml_declaration,
                                    cleanup_namespaces, encoding, pretty_print)

        # SOAP requires DateTime strings to be in iso format. The following
        # lines make sure custom datetime formatting via DateTime(format="...")
        # string is bypassed.
        self._to_string_handlers[Time] = lambda cls, value: value.isoformat()
        self._to_string_handlers[DateTime] = lambda cls, value: value.isoformat()

        self._from_string_handlers[Date] = date_from_string_iso
        self._from_string_handlers[DateTime] = datetime_from_string_iso
开发者ID:hartror,项目名称:spyne,代码行数:13,代码来源:soap11.py


示例5: test_datetime_timezone

    def test_datetime_timezone(self):
        import pytz

        n = datetime.datetime.now(pytz.timezone('EST'))
        element = etree.Element('test')
        cls = DateTime(as_timezone=pytz.utc, timezone=False)
        XmlDocument().to_parent(None, cls, n, element, ns_test)
        element = element[0]

        c = n.astimezone(pytz.utc).replace(tzinfo=None)
        self.assertEquals(element.text, c.isoformat())
        dt = XmlDocument().from_element(None, cls, element)
        assert dt.tzinfo is not None
        dt = dt.replace(tzinfo=None)
        self.assertEquals(c, dt)
开发者ID:jpunwin,项目名称:spyne,代码行数:15,代码来源:test_primitive.py


示例6: get_object_as_xml

def get_object_as_xml(value, cls=None, root_tag_name=None, no_namespace=False):
    '''Returns an ElementTree representation of a :class:`spyne.model.complex.ComplexModel`
    child.

    :param value: The instance of the class to be serialized.
    :param value: The root tag string to use. Defaults to the output of
        ``value.__class__.get_type_name_ns()``.
    '''

    if cls is None:
        cls = value.__class__
    xml_object = XmlDocument()
    parent = etree.Element("parent")

    xml_object.to_parent_element(cls, value, cls.get_namespace(),
                                                          parent, root_tag_name)

    if no_namespace:
        _dig(parent)
        etree.cleanup_namespaces(parent)

    return parent[0]
开发者ID:Bluehorn,项目名称:spyne,代码行数:22,代码来源:xml.py


示例7: __init__

    def __init__(self, app=None, validator=None, wrapped=True,
                                xml_declaration=True, cleanup_namespaces=True):
        XmlDocument.__init__(self, app, validator, xml_declaration,
                                                             cleanup_namespaces)

        self.__wrapped = wrapped
开发者ID:amgibson,项目名称:spyne,代码行数:6,代码来源:soap11.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python server.ServerBase类代码示例发布时间:2022-05-27
下一篇:
Python protocol.ProtocolBase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap