def soap_call(url, method, doc, requests_session = None): msg = ET.tostring(create_soap_env_xml(doc), xml_declaration=True, encoding='UTF-8') resp = (requests_session or requests).post(url, msg, headers={ "Content-Type": "text/xml; charset=UTF-8", 'SOAPAction': '"%s"' % method, 'Accept-Encoding': 'UTF-8', }) return ET.fromstring(resp.content).xpath("/ns:Envelope/ns:Body", namespaces={"ns": NS_ENV})[0]
def soap_call(url, method, doc, requests_session=None): msg = ET.tostring(create_soap_env_xml(doc), xml_declaration=True, encoding='UTF-8') resp = (requests_session or requests).post(url, msg, headers={ "Content-Type": "text/xml; charset=UTF-8", 'SOAPAction': '"%s"' % method, 'Accept-Encoding': 'UTF-8', }) return ET.fromstring(resp.content).xpath("/ns:Envelope/ns:Body", namespaces={"ns": NS_ENV})[0]
def save_pretty(self, filename): """Save the current page, after lxml has prettified it""" self.parse() # lazy-load LXML from lxml.builder import ET with open(filename, 'w') as fp: fp.write(ET.tostring(self._tree, pretty_print=True))
def create_logout_request_url(authn_url, app_name, username): el = SEM('LogoutRequest', SEM('{%s}Issuer' % NS_SAML, app_name), SEM('NameID', username), ID=gen_id(), Version="2.0", IssueInstant=gen_ts()) xml = ET.tostring(el, encoding='UTF-8') return authn_url + '?' + urlencode({ 'SAMLRequest': base64.encodestring(deflate(xml)) })
def create_authn_request_url(authn_url, app_name, redirect_url): el = SEM('AuthnRequest', SEM('{%s}Issuer' % NS_SAML, app_name), ID=gen_id(), Version="2.0", IssueInstant=gen_ts(), Destination=authn_url, IsPassive="false", AssertionConsumerServiceURL=redirect_url) xml = ET.tostring(el, encoding='UTF-8') return authn_url + '?' + urlencode({ 'SAMLRequest': base64.encodestring(deflate(xml)) })
def create_logout_request_url(authn_url, app_name, username): el = SEM('LogoutRequest', SEM('{%s}Issuer' % NS_SAML, app_name), SEM('NameID', username), ID=gen_id(), Version="2.0", IssueInstant=gen_ts()) xml = ET.tostring(el, encoding='UTF-8') return authn_url + '?' + urlencode( {'SAMLRequest': base64.encodestring(deflate(xml))})
def create_authn_request_url(authn_url, app_name, redirect_url): el = SEM('AuthnRequest', SEM('{%s}Issuer' % NS_SAML, app_name), ID=gen_id(), Version="2.0", IssueInstant=gen_ts(), Destination=authn_url, IsPassive="false", AssertionConsumerServiceURL=redirect_url) xml = ET.tostring(el, encoding='UTF-8') return authn_url + '?' + urlencode( {'SAMLRequest': base64.encodestring(deflate(xml))})
def call(*args, **kwargs): html = copy(HTML) content = html.xpath("//html/body/*[@id='content']")[0] res = f(*args, **kwargs) if type(res) is BaseResponse: return res for item in res: content.append(item) if title is not None: html.xpath("//title")[0].text += (' - ' + title) html.xpath("//*[@id='page-title']")[0].text = '> %s' % title HEAD = html.xpath("/html/head")[0] BODY = html.xpath("/html/body")[0] for url in css: HEAD.append(stylesheet(url)) for url in js: BODY.append(javascript(url)) for remove in removals: try: node = html.xpath(remove)[0] node.getparent().remove(node) except IndexError: print "Could not find %s to remove!" % remove # make sure all fields take UTF-8 for element in html.xpath("//input | //textarea"): element.attrib['accept-charset'] = 'UTF-8' return '<!DOCTYPE HTML>\n%s' % ET.tostring(html, pretty_print=True)
###### R = chimp.Reference(""" This data was cooked right out of my head! --Spencer """, bibtex=""" @Article{TheDuke, author = {John Wayne}, title = {True grit is not made from grits}, journal = {Holywood. Rev. B}, year = {1960}, volume = {3}, number = {}, month = {}, pages = {1-10}, } """) rawdata = loadtxt('dummy-data2.txt') D = cross_section.DATA(reference=R, xscale='1/K_B', yscale='1e-12*barns', data=rawdata) I = Interaction(lhs={'Hg': 1, 'e^-': 1}, rhs={'Hg^+': 1, 'e^-': 2}) I.data.append(D) interactions.append(I.getXML()) ##### print ET.tostring(E.Olson(interactions), pretty_print=True)