/usr/lib/python3/dist-packages/twisted/web/__pycache__
NameSizeModeActions
client.cpython-310.pyc578890644editdlrm
demo.cpython-310.pyc7750644editdlrm
distrib.cpython-310.pyc122830644editdlrm
domhelpers.cpython-310.pyc88800644editdlrm
error.cpython-310.pyc131210644editdlrm
guard.cpython-310.pyc5280644editdlrm
html.cpython-310.pyc16740644editdlrm
http.cpython-310.pyc966750644editdlrm
http_headers.cpython-310.pyc87120644editdlrm
iweb.cpython-310.pyc313510644editdlrm
microdom.cpython-310.pyc302510644editdlrm
proxy.cpython-310.pyc100340644editdlrm
resource.cpython-310.pyc151370644editdlrm
rewrite.cpython-310.pyc22660644editdlrm
script.cpython-310.pyc64210644editdlrm
server.cpython-310.pyc259950644editdlrm
soap.cpython-310.pyc45010644editdlrm
static.cpython-310.pyc329660644editdlrm
sux.cpython-310.pyc169110644editdlrm
tap.cpython-310.pyc100280644editdlrm
template.cpython-310.pyc12190644editdlrm
twcgi.cpython-310.pyc102500644editdlrm
util.cpython-310.pyc6090644editdlrm
vhost.cpython-310.pyc57850644editdlrm
wsgi.cpython-310.pyc161300644editdlrm
xmlrpc.cpython-310.pyc200150644editdlrm
_element.cpython-310.pyc63360644editdlrm
_flatten.cpython-310.pyc145810644editdlrm
_http2.cpython-310.pyc378270644editdlrm
_newclient.cpython-310.pyc527690644editdlrm
_responses.cpython-310.pyc27210644editdlrm
_stan.cpython-310.pyc88560644editdlrm
_template_util.cpython-310.pyc304340644editdlrm
__init__.cpython-310.pyc4230644editdlrm
Edit: /usr/lib/python3/dist-packages/twisted/web/__pycache__/domhelpers.cpython-310.pyc (8880B)
o bf"@sdZddlmZddlmZddlmZmZmZeeGddde Z ddZ d9d d Z d d Z ddZddZddZd:ddZddZddZddZd;ddZGd d!d!ejZd A library for performing interesting tasks with DOM objects. )StringIO)microdom)escapegetElementsByTagNameunescapec@s eZdZdS)NodeLookupErrorN)__name__ __module__ __qualname__r r 8/usr/lib/python3/dist-packages/twisted/web/domhelpers.pyrsrcCsF|jD]}t|dr|jr|dt|j|j|t|||qdS)z Look through the given node's children for strings, and attempt to do string substitution with the given parameter. nodeValuerN) childNodeshasattrr replaceDatalen substitute)requestnodesubschildr r r rs ridclassmodelpatterncCst|dr|r|D]}t|||kr|Sq |rDt|jdr*|jj}nt|j}t|D]}t |j||}|rC|Sq3dSdS)zx (internal) Get a node with the specified C{nodeId} as any of the C{class}, C{id} or C{pattern} attributes. hasAttributeslengthN) rrstr getAttribute hasChildNodesrrrrange_get)rnodeId nodeAttrsnodeAttrrchildNumresultr r r r""s     r"cCst||}|r |St|)z Get a node with the specified C{nodeId} as any of the C{class}, C{id} or C{pattern} attributes. If there is no such node, raise L{NodeLookupError}. )r"rrr#r'r r r get7s r)cCs t||S)z Get a node with the specified C{nodeId} as any of the C{class}, C{id} or C{pattern} attributes. If there is no such node, return L{None}. )r")rr#r r r getIfExistsCs r*cCst||}|r t||S)zGet a node with the specified C{nodeId} as any of the C{class}, C{id} or C{pattern} attributes. If there is no such node, raise L{NodeLookupError}. Remove all child nodes before returning. )r) clearNoder(r r r getAndClearLs r,cCsg|jdd<dS)z2 Remove all children from the given node. Nr)rr r r r+Wsr+cCsrg}t|tgst|j|||S|D]#}t|dsqt|||kr,|||r,q|t||||q|S)z\ Find subnodes in the given node where the given attribute has the given value. r) isinstancetype locateNodesrrrrappendextend)nodeListkeyvalue noNesting returnList childNoder r r r1^s  r1cCsBt|dsdS||||r|jD] }t|||qdSdS)N setAttribute)rr:r rsuperSetAttribute)rr5r6rr r r r;qs   r;cCsft|dsdS||}|r|||d|n||||r/|jD] }t|||q&dSdSNr:/)rrr:r rsuperPrependAttributerr5r6oldrr r r r>z    r>cCsft|dsdS||}|r|||d|n||||r/|jD] }t|||q&dSdSr<)rrr:r rsuperAppendAttributer?r r r rBrArBcCs|g}|j}|g}t|dkr9|d}t|dr,|jdur,|r%t|j}n|j}|||j|dd<t|dks||S)ahVisit each child node and collect its text data, if any, into a string. For example:: >>> doc=microdom.parseString('1234') >>> gatherTextNodes(doc.documentElement) '1234' With dounescape=1, also convert entities back into normal characters. @return: the gathered nodes as a single string @rtype: strrr N)r2rpoprr rrjoin)iNode dounescapejoinWithgatheredgathered_appendslicecvalr r r gatherTextNodess     rNc@s&eZdZdZ      dddZdS)RawTexta7This is an evil and horrible speed hack. Basically, if you have a big chunk of XML that you want to insert into the DOM, but you don't want to incur the cost of parsing it, you can construct one of these and insert it into the DOM. This will most certainly only work with microdom as the API for converting nodes to xml is different in every DOM implementation. This could be improved by making this class a Lazy parser, so if you inserted this into the DOM and then later actually tried to mutate this node, it would be parsed then. rCrNcCs|||j|dSN)writedata)selfwriterindent addindentnewlstrip nsprefixes namespacer r r writexmls zRawText.writexml)rCrCrCrNN)rr r __doc__r[r r r r rOsrONcCsF|durg}|s |S|jD]}||r||t|||q|SrPr rr2 findNodesparentmatcheraccumrr r r r^s  r^cCsP|durg}|s |S|jD]}||r||||r%t||||q|SrP)r rr2findNodesShallowOnMatch)r`rarecurseMatcherrbrr r r rcs  rccCsH|durg}|s |S|jD]}||r||qt|||q|SrPr]r_r r r findNodesShallows  recst|fddS)z Return an iterable of the elements which are direct children of C{parent} and which have the C{attribute} attribute. cst|ddduo |SNtagName)getattr hasAttribute)n attributer r sz2findElementsWithAttributeShallow..)re)r`rlr rkr findElementsWithAttributeShallow rncCt||fddS)z Return an iterable of the elements which are children of C{parent} for which the predicate C{matcher} returns true. cSst|ddduo ||Srfrh)rjrar r r rmszfindElements..r^)r`rar r r findElementsrorscCs*|r t|||fddSt||fddS)NcSs||o |||kSrP)rir)rjrlr6r r r rms z+findElementsWithAttribute..cSs ||SrP)ri)rjrlr r r rm  )rs)r`rlr6r r r findElementsWithAttributes  rucCrp)NcSs |j|kSrPnodeName)rjnamer r r rmrtz findNodesNamed..rr)r`rxr r r findNodesNamedsrycCs6|jD]}t|dr|d|jqt||qdS)NrRrC)rrrQrR writeNodeData)roldiosubnoder r r rzs   rzcCst}t|||SrP)rrzgetvalue)rr{r r r getNodeTexts r~cCs g}|r|||j}|s|SrP)r2 parentNode)rlr r r getParents#s  rcsfdd|jDS)znnamedChildren(parent, nodeName) -> children (not descendants) of parent that have tagName == nodeName cs g|] }t|ddkr|qS)rgrCrq).0rjrvr r /s z!namedChildren..r-)r`rwr rvr namedChildren+sr)r)r.)rrCrP)#r\ior twisted.webrtwisted.web.microdomrrr Exceptionrrr"r)r*r,r+r1r;r>rBrNTextrOr^rcrernrsruryrzr~rrr r r r s<