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


Python SimpleXMLElement.marshall方法代码示例

本文整理汇总了Python中pysimplesoap.simplexml.SimpleXMLElement.marshall方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLElement.marshall方法的具体用法?Python SimpleXMLElement.marshall怎么用?Python SimpleXMLElement.marshall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pysimplesoap.simplexml.SimpleXMLElement的用法示例。


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

示例1: serializar

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import marshall [as 别名]
def serializar(regs):
    "Dado una lista de comprobantes (diccionarios), convierte a xml"
    xml = SimpleXMLElement(XML_BASE)

    comprobantes = []
    for reg in regs:
        dic = {}
        for k, v in MAP_ENC.items():
            dic[v] = reg[k]
                
        dic.update({
                'detalles': [{
                    'detalle': mapear({}, det, MAP_DET, swap=True),
                    } for det in reg['detalles']],                
                'tributos': [{
                    'tributo': mapear({}, trib, MAP_TRIB, swap=True),
                    } for trib in reg['tributos']],
                'ivas': [{
                    'iva': mapear({}, iva, MAP_IVA, swap=True),
                    } for iva in reg['ivas']],
                'formaspago': [{
                'formapago': {
                    'codigo': '',
                    'descripcion': reg['forma_pago'],
                    }}]
                })
        comprobantes.append(dic)

    for comprobante in comprobantes:
        xml.marshall("comprobante", comprobante)
    return xml.as_xml()
开发者ID:AndresVillan,项目名称:pyafipws,代码行数:33,代码来源:formato_xml.py

示例2: get_bugs

# 需要导入模块: from pysimplesoap.simplexml import SimpleXMLElement [as 别名]
# 或者: from pysimplesoap.simplexml.SimpleXMLElement import marshall [as 别名]
def get_bugs(*key_value):
    """Get list of bugs matching certain criteria.

    The conditions are defined by key value pairs.

    Possible keys are:
        * "package": bugs for the given package
        * "submitter": bugs from the submitter
        * "maint": bugs belonging to a maintainer
        * "src": bugs belonging to a source package
        * "severity": bugs with a certain severity
        * "status": can be either "done", "forwarded", or "open"
        * "tag": see http://www.debian.org/Bugs/Developer#tags for
           available tags
        * "owner": bugs which are assigned to `owner`
        * "bugs": takes single int or list of bugnumbers, filters the list
           according to given criteria
        * "correspondent": bugs where `correspondent` has sent a mail to

    Arguments
    ---------
    key_value : str

    Returns
    -------
    bugs : list of ints
        the bugnumbers

    Examples
    --------
    >>> get_bugs('package', 'gtk-qt-engine', 'severity', 'normal')
    [12345, 23456]

    """
    # previous versions also accepted
    # get_bugs(['package', 'gtk-qt-engine', 'severity', 'normal'])
    # if key_value is a list in a one elemented tuple, remove the
    # wrapping list
    if len(key_value) == 1 and isinstance(key_value[0], list):
        key_value = tuple(key_value[0])

    # pysimplesoap doesn't generate soap Arrays without using wsdl
    # I build body by hand, converting list to array and using standard
    # pysimplesoap marshalling for other types
    method_el = SimpleXMLElement('<get_bugs></get_bugs>')
    for arg_n, kv in enumerate(key_value):
        arg_name = 'arg' + str(arg_n)
        if isinstance(kv, (list, tuple)):
            _build_int_array_el(arg_name, method_el, kv)
        else:
            method_el.marshall(arg_name, kv)

    soap_client = _build_soap_client()
    reply = soap_client.call('get_bugs', method_el)
    items_el = reply('soapenc:Array')
    return [int(item_el) for item_el in items_el.children() or []]
开发者ID:venthur,项目名称:python-debianbts,代码行数:58,代码来源:debianbts.py


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