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


Python Element.setText方法代码示例

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


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

示例1: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     if self.password_digest:
         p.set('Type', wsdigest)
         p.setText(self.password_digest)
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         if self.nonce_has_encoding:
             n.set('EncodingType', nonce_encoding_type)
         n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(str(DateTime(self.created)))
         root.append(n)
     return root
开发者ID:ovnicraft,项目名称:suds,代码行数:29,代码来源:wsse.py

示例2: to_xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def to_xml(self, factory):
     # Dear Docdata: apparently, reusing Vat was not possible..?
     #node = factory.create('ns0:totalVatAmount') does not support setting text.
     element = Element('ns0:totalVatAmount')
     element.setText(str(int(self.value * 100)))
     element.set('rate', self.rate)
     element.set('currency', self.currency)
     return element
开发者ID:jklardie,项目名称:django-oscar-docdata,代码行数:10,代码来源:gateway.py

示例3: to_xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def to_xml(self, factory):
     # make sure the namespace is set to the correct one
     metadata = factory.resolver.find('ns0:totalVatAmount')
     element = Element("totalVatAmount", ns=metadata.namespace())
     element.setText(str(int(self.value * 100)))
     element.set('rate', self.rate)
     element.set('currency', self.currency)
     return element
开发者ID:edoburu,项目名称:django-oscar-docdata,代码行数:10,代码来源:gateway.py

示例4: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     created = Element('Created', ns=wsuns)
     created.setText(str(DateTime(self.created)))
     expires = Element('Expires', ns=wsuns)
     expires.setText(str(DateTime(self.expires)))
     root.append(created)
     root.append(expires)
     return root
开发者ID:BhallaLab,项目名称:moose-gui,代码行数:11,代码来源:wsse.py

示例5: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     root = Element("Timestamp", ns=wsuns)
     # xsd:datetime format does not have fractional seconds
     created = Element("Created", ns=wsuns)
     created.setText(str(UTC(self.created - timedelta(microseconds=self.created.microsecond))))
     expires = Element("Expires", ns=wsuns)
     expires.setText(str(UTC(self.expires - timedelta(microseconds=self.expires.microsecond))))
     root.append(created)
     root.append(expires)
     return root
开发者ID:evandeaubl,项目名称:suds,代码行数:12,代码来源:__init__.py

示例6: encryptMessage

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
def encryptMessage(cert, symmetric_key, elements_to_encrypt, enc_key_uri, reference_type=KEY_REFERENCE_ISSUER_SERIAL, key_transport=KEY_TRANSPORT_RSA_OAEP):
    sym_key = symmetric_key.sym_key
    iv = symmetric_key.iv
    block_encryption = symmetric_key.block_encryption_algorithm

    reference_list = Element("ReferenceList", ns=wsencns)

    for (element_to_encrypt, type) in elements_to_encrypt:
        reference = Element("DataReference", ns=wsencns)
        id = "EncDataId-" + str(generate_unique_id())
        reference.set("URI", '#' + id)
        reference_list.append(reference)

        element_content = element_to_encrypt.canonical()
        if type == 'Content':
            element_content = element_content[element_content.index(">") + 1:element_content.rindex("<")]
        enc_data = Element("EncryptedData", ns=wsencns)
        enc_data.set("Id", id)
        enc_data.set("Type", "http://www.w3.org/2001/04/xmlenc#" + type)
        
        block_encryption_props = blockEncryptionProperties[block_encryption]
        enc_method = Element("EncryptionMethod", ns=wsencns)
        enc_method.set("Algorithm", block_encryption_props['uri'])
        
        key_info = Element("KeyInfo", ns=dsns)
        sec_token_ref = Element("SecurityTokenReference", ns=wssens)
        wsse_reference = Element("Reference", ns=wssens)
        wsse_reference.set("URI", enc_key_uri)
        sec_token_ref.append(wsse_reference)
        key_info.append(sec_token_ref)
        
        cipher_data = Element("CipherData", ns=wsencns)
        cipher_value = Element("CipherValue", ns=wsencns)
        cipher = EVP.Cipher(alg=blockEncryptionProperties[block_encryption]['openssl_cipher'], key=sym_key, iv=iv, op=1, padding=0)
        pad_bytes = block_encryption_props['block_size'] - len(element_content) % block_encryption_props['block_size']
        element_content = element_content + ' ' * (pad_bytes - 1) + chr(pad_bytes)
        enc_content = cipher.update(element_content.encode("utf-8"))
        enc_content = enc_content + cipher.final()
        enc_content = iv + enc_content
        cipher_value.setText(b64encode(enc_content))
        cipher_data.append(cipher_value)

        enc_data.append(enc_method)
        enc_data.append(key_info)
        enc_data.append(cipher_data)
        
        if type == 'Element':
            element_to_encrypt.parent.replaceChild(element_to_encrypt, enc_data)
        elif type == 'Content':
            element_to_encrypt.setText('')
            for child in element_to_encrypt.children:
                element_to_encrypt.remove(child)
            element_to_encrypt.append(enc_data)
    
    return reference_list
开发者ID:analytehealth,项目名称:suds,代码行数:57,代码来源:xmlsec.py

示例7: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     self.created = datetime.utcnow()
     root = Element("Timestamp", ns=WSUNS)
     created = Element('Created', ns=WSUNS)
     created.setText(iso_utc(self.created))
     root.append(created)
     if self.validity is not None:
         self.expires = self.created + timedelta(seconds=self.validity)
         expires = Element('Expires', ns=WSUNS)
         expires.setText(iso_utc(self.expires))
         root.append(expires)
     return root
开发者ID:metaspace,项目名称:robotframework-sudslibrary,代码行数:14,代码来源:wsse.py

示例8: connect

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def connect(self):
     from .client import SmsClient
     from suds.sax.element import Element
     self.client = SmsClient(self._vim.server_fqdn)
     session = eval(list(self._vim.client.client.options.transport.cookiejar)[0].value)
     cookie = Element("vcSessionCookie")
     cookie.setText(session)
     self.client.wsdl.options.__pts__.set("soapheaders", cookie)
     ref = Property('ServiceInstance')
     ref._type = 'ServiceInstance'
     self.service_instance = SmsServiceInstance(self, name='ServiceInstance', ref=ref)
     self.connected = True
开发者ID:Infinidat,项目名称:pyvisdk,代码行数:14,代码来源:core.py

示例9: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     self.created = Token.utc()
     root = Element("Timestamp", ns=WSUNS)
     created = Element('Created', ns=WSUNS)
     created.setText(self._trim_to_ms(str(UTC(self.created))))
     root.append(created)
     if self.validity is not None:
         self.expires = self.created + timedelta(seconds=self.validity)
         expires = Element('Expires', ns=WSUNS)
         expires.setText(self._trim_to_ms(str(UTC(self.expires))))
         root.append(expires)
     return root
开发者ID:w00fel,项目名称:cloudera,代码行数:14,代码来源:wsse.py

示例10: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
    def xml(self):
        """
        Get xml representation of the object.
        @return: The root node.
        @rtype: L{Element}
        """
        root = Element('UsernameToken', ns=wssens)

        u = Element('Username', ns=wssens)
        u.setText(self.username)
        root.append(u)

        p = Element('Password', ns=wssens)
        p.setText(self.generate_digest())
        p.set(wspassd[0], wspassd[1])
        root.append(p)

        n = Element('Nonce', ns=wssens)
        n.setText(base64.encodestring(self.nonce)[:-1])
        n.set(wsenctype[0], wsenctype[1])
        root.append(n)

        n = Element('Created', ns=wsuns)
        n.setText(self.created)
        root.append(n)

        self.reset()
        return root
开发者ID:leppis,项目名称:suds-passworddigest,代码行数:30,代码来源:token.py

示例11: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
 def xml(self):
     """
     Get xml representation of the object.
     @return: The root node.
     @rtype: L{Element}
     """
     root = Element('UsernameToken', ns=wssens)
     root.set('wsu:Id', 'UsernameToken-%i' % hash(self))
     u = Element('Username', ns=wssens)
     u.setText(self.username)
     root.append(u)
     p = Element('Password', ns=wssens)
     p.setText(self.password)
     # The Type attribute defaults to PasswordText, but some endpoints
     # seem to want it specified anyway.
     p.set('Type', PASSWORD_TYPES['plain'])
     root.append(p)
     if self.nonce is not None:
         n = Element('Nonce', ns=wssens)
         n.setText(self.nonce)
         root.append(n)
     if self.created is not None:
         n = Element('Created', ns=wsuns)
         n.setText(self.created.isoformat())
         root.append(n)
     return root
开发者ID:tic-ull,项目名称:defensatfc-proto,代码行数:28,代码来源:wsse.py

示例12: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
    def xml(self):
        usernametoken = Element("UsernameToken", ns=wssens)

        username = Element("Username", ns=wssens)
        username.setText(self.username)
        usernametoken.append(username)

        password = Element("Password", ns=wssens)
        s = hashlib.sha1()
        s.update(self.nonce)
        s.update(self._print_datetime(self.created).encode("utf-8"))
        s.update(self.password.encode("utf-8"))
        password.setText(b64encode(s.digest()).decode("utf-8"))
        password.set(
            "Type",
            "http://docs.oasis-open.org/wss/2004/01/" "oasis-200401-wss-username-token-profile-1.0" "#PasswordDigest",
        )
        usernametoken.append(password)

        nonce = Element("Nonce", ns=wssens)
        nonce.setText(b64encode(self.nonce).decode("utf-8"))
        nonce.set(
            "EncodingType",
            "http://docs.oasis-open.org/wss/2004" "/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary",
        )
        usernametoken.append(nonce)

        created = Element("Created", ns=wsuns)
        created.setText(self._print_datetime(self.created))
        usernametoken.append(created)

        return usernametoken
开发者ID:kmillet,项目名称:crabpytest,代码行数:34,代码来源:wsse.py

示例13: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
    def xml(self):
        usernametoken = Element('UsernameToken', ns=wssens)

        username = Element('Username', ns=wssens)
        username.setText(self.username)
        usernametoken.append(username)

        password = Element('Password', ns=wssens)
        s = hashlib.sha1()
        s.update(self.nonce)
        s.update(self._print_datetime(self.created).encode('utf-8'))
        s.update(self.password.encode('utf-8'))
        password.setText(b64encode(s.digest()).decode('utf-8'))
        password.set('Type', 'http://docs.oasis-open.org/wss/2004/01/'
                             'oasis-200401-wss-username-token-profile-1.0'
                             '#PasswordDigest')
        usernametoken.append(password)

        nonce = Element('Nonce', ns=wssens)
        nonce.setText(b64encode(self.nonce).decode('utf-8'))
        nonce.set(
            'EncodingType',
            'http://docs.oasis-open.org/wss/2004'
            '/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'
        )
        usernametoken.append(nonce)

        created = Element('Created', ns=wsuns)
        created.setText(self._print_datetime(self.created))
        usernametoken.append(created)

        return usernametoken
开发者ID:OnroerendErfgoed,项目名称:crabpy,代码行数:34,代码来源:wsse.py

示例14: xml

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
    def xml(self):
        """
        Get xml representation of the object.
        @return: The root node.
        @rtype: L{Element}
        """
        root = Element('UsernameToken', ns=WSSE_NS)
        for p, u in self.nsprefixes.items():
            root.addPrefix(p, u)
        root.append(Attribute('wsu:Id', 'UsernameToken-9'))
        root.append(Attribute('xmlns:wsu', WSU_URI))

        u = Element('Username', ns=WSSE_NS)
        u.setText(self.username)
        root.append(u)
        p = Element('Password', ns=WSSE_NS)
        p.setText(self.password)
        p.append(Attribute('Type', WSU_UN_URI))
        root.append(p)
        if self.nonce is not None:
            n = Element('Nonce', ns=WSSE_NS)
            n.setText(self.nonce)
            root.append(n)
        if self.created is not None:
            n = Element('Created', ns=WSU_NS)
            n.setText(str(UTC(self.created)))
            root.append(n)
        return root
开发者ID:rijkstofberg,项目名称:paymentintegrations,代码行数:30,代码来源:payu.py

示例15: build_soap_header

# 需要导入模块: from suds.sax.element import Element [as 别名]
# 或者: from suds.sax.element.Element import setText [as 别名]
    def build_soap_header(self, el, data):
        """Set up a SOAP object for our headers"""
        ## make our first element
        for name in data:
            if type(data[name]) is dict:
                ## append to the current element
                nel = Element(name)
                el.children.append(nel)
                self.build_soap_header(nel, data[name])
            else:
                opt = Element(name)
                opt.setText(data[name])
                el.children.append(opt)
                # print "{name} - {data}".format(name=name,data=data[name])

        return el
开发者ID:enygma,项目名称:slsoap,代码行数:18,代码来源:slsoap.py


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