def test_basic(self):
        span = SimpleXMLElement(
            '<span><a href="python.org.ar">pyar</a>'
            '<prueba><i>1</i><float>1.5</float></prueba></span>')
        span1 = SimpleXMLElement('<span><a href="google.com">google</a>'
                                 '<a>yahoo</a><a>hotmail</a></span>')
        self.eq([str(a) for a in span1.a()], ['google', 'yahoo', 'hotmail'])

        span1.add_child('a', 'altavista')
        span1.b = "ex msn"
        d = {'href': 'http://www.bing.com/', 'alt': 'Bing'}
        span1.b[:] = d
        self.eq(sorted([(k, v) for k, v in span1.b[:]]), sorted(d.items()))

        xml = ('<?xml version="1.0" encoding="UTF-8"?><span>'
               '<a href="google.com">google</a><a>yahoo</a>'
               '<a>hotmail</a><a>altavista</a>'
               '<b alt="Bing" href="http://www.bing.com/">ex msn</b></span>')
        self.eq(span1.as_xml(), xml if PY2 else xml.encode('utf-8'))
        self.assertTrue('b' in span1)

        span.import_node(span1)
        xml = (
            '<?xml version="1.0" encoding="UTF-8"?><span>'
            '<a href="python.org.ar">pyar</a><prueba><i>1</i>'
            '<float>1.5</float></prueba><span><a href="google.com">google</a>'
            '<a>yahoo</a><a>hotmail</a><a>altavista</a>'
            '<b alt="Bing" href="http://www.bing.com/">ex msn</b>'
            '</span></span>')
        self.eq(span.as_xml(), xml if PY2 else xml.encode('utf-8'))

        types = {'when': datetime.datetime}
        when = datetime.datetime.now()
        dt = SimpleXMLElement('<when>%s</when>' % when.isoformat())
        self.eq(dt.unmarshall(types)['when'], when)
Esempio n. 2
0
def generate_wsa_header_for_soap12(ns_binding, action):
    action_header = ns_binding + action

    soap_header = SimpleXMLElement('<Header></Header>')
    soap_header.add_child('To', Config.FRT_WS_URL, WSA_NS)
    soap_header.add_child('Action', action_header, WSA_NS)
    return soap_header
    def test_marshall_cdata(self):
        span = SimpleXMLElement('<span/>')
        cdata = CDATASection()
        cdata.data = 'python'
        span.add_child('a', cdata)

        xml = '<?xml version="1.0" encoding="UTF-8"?><span><a><![CDATA[python]]></a></span>'
        self.eq(span.as_xml(), xml if PY2 else xml.encode('utf-8'))
    def test_marshall_cdata(self):
        span = SimpleXMLElement('<span/>')
        cdata = CDATASection()
        cdata.data = 'python'
        span.add_child('a', cdata)

        xml = '<?xml version="1.0" encoding="UTF-8"?><span><a><![CDATA[python]]></a></span>'
        self.eq(span.as_xml(), xml if PY2 else xml.encode('utf-8'))
Esempio n. 5
0
def makeNRPSrequest(seqs):
    root = SimpleXMLElement("<predict></predict>",prefix="ws",namespace="http://ws.NRPSpredictor2.roettig.org/")
    root.add_child("request",ns=True)
    print root.as_xml(pretty=True)
    arg0_node = root.children()[0]
    

    idx = 1
    for seq in seqs:
        seqs_node = arg0_node.add_child("sequence",ns=True)
        seqs_node.add_child("id","%d"%idx,ns=True)
        seqs_node.add_child("kingdom","0",ns=True)
        seqs_node.add_child("seqString",seq,ns=True)
        seqs_node.add_child("sequenceType","0",ns=True)
        idx+=1
    print root.as_xml(pretty=True)    
    return root
Esempio n. 6
0
def makeNRPSrequest(seqs):
    root = SimpleXMLElement("<predict></predict>",
                            prefix="ws",
                            namespace="http://ws.NRPSpredictor2.roettig.org/")
    root.add_child("request", ns=True)
    print root.as_xml(pretty=True)
    arg0_node = root.children()[0]

    idx = 1
    for seq in seqs:
        seqs_node = arg0_node.add_child("sequence", ns=True)
        seqs_node.add_child("id", "%d" % idx, ns=True)
        seqs_node.add_child("kingdom", "0", ns=True)
        seqs_node.add_child("seqString", seq, ns=True)
        seqs_node.add_child("sequenceType", "0", ns=True)
        idx += 1
    print root.as_xml(pretty=True)
    return root
Esempio n. 7
0
def initializeReg(apitoken):
	client = SoapClient(
		wsdl = "https://www.regonline.com/api/default.asmx?WSDL"
		, trace = False)

	header = SimpleXMLElement("<Headers/>")

	MakeHeader = header.add_child("TokenHeader")
	MakeHeader.add_attribute('xmlns','http://www.regonline.com/api')
	MakeHeader.marshall('APIToken', apitoken)
	client['TokenHeader']=MakeHeader
	return client
    def test_basic(self):
        span = SimpleXMLElement('<span><a href="python.org.ar">pyar</a><prueba><i>1</i><float>1.5</float></prueba></span>')
        span1 = SimpleXMLElement('<span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a></span>')
        self.eq([str(a) for a in span1.a()], ['google', 'yahoo', 'hotmail'])

        span1.add_child('a', 'altavista')
        span1.b = "ex msn"
        d = {'href': 'http://www.bing.com/', 'alt': 'Bing'}
        span1.b[:] = d
        self.eq(sorted([(k, v) for k, v in span1.b[:]]), sorted(d.items()))

        xml = '<?xml version="1.0" encoding="UTF-8"?><span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a><a>altavista</a><b alt="Bing" href="http://www.bing.com/">ex msn</b></span>'
        self.eq(span1.as_xml(), xml)
        self.assertTrue('b' in span1)

        span.import_node(span1)
        xml = '<?xml version="1.0" encoding="UTF-8"?><span><a href="python.org.ar">pyar</a><prueba><i>1</i><float>1.5</float></prueba><span><a href="google.com">google</a><a>yahoo</a><a>hotmail</a><a>altavista</a><b alt="Bing" href="http://www.bing.com/">ex msn</b></span></span>'
        self.eq(span.as_xml(), xml)

        types = {'when': datetime.datetime}
        when = datetime.datetime.now()
        dt = SimpleXMLElement('<when>%s</when>' % when.isoformat())
        self.eq(dt.unmarshall(types)['when'], when)
Esempio n. 9
0
def submit_problem(url, params):
    p = SimpleXMLElement("<submitProblem></submitProblem>")
    for k, v in params.items():
        child = p.add_child(k, v)
        child.add_attribute("xsi:type", "xsd:string")

    client = SoapClient(
        location = url,
        action = '',
        soap_ns = 'soapenv',
        namespace = 'http://www.decision-deck.org/2009/XMCDA-2.0.0',
        trace = False)

    sp = client.call('submitProblem', p)
    reply = sp.submitProblemResponse
    return str(reply.ticket)