Your IP : 18.224.32.243


Current Path : /opt/alt/python33/lib64/python3.3/xml/sax/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/xml/sax/__pycache__/saxutils.cpython-33.pyc

�
��f/c@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	dd�Z
idd	�Zid
d�Zidd
�Z
dd�ZGdd�dej�ZGdd�de	j�Zddd�ZdS(unA library of useful helper classes to the SAX classes, for the
convenience of application and driver writers.
iNi(uhandler(u	xmlreadercCs3x,|j�D]\}}|j||�}q
W|S(u2Replace substrings of a string using a dictionary.(uitemsureplace(usudukeyuvalue((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu__dict_replacesu__dict_replacecCsR|jdd�}|jdd�}|jdd�}|rNt||�}n|S(u�Escape &, <, and > in a string of data.

    You can escape other strings of data by passing a dictionary as
    the optional entities parameter.  The keys and values must all be
    strings; each key will be replaced with its corresponding value.
    u&u&amp;u>u&gt;u<u&lt;(ureplaceu__dict_replace(udatauentities((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuescapes	uescapecCsL|jdd�}|jdd�}|r<t||�}n|jdd�S(u
Unescape &amp;, &lt;, and &gt; in a string of data.

    You can unescape other strings of data by passing a dictionary as
    the optional entities parameter.  The keys and values must all be
    strings; each key will be replaced with its corresponding value.
    u&lt;u<u&gt;u>u&amp;u&(ureplaceu__dict_replace(udatauentities((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuunescape"s
uunescapecCs�|j�}|jidd6dd6dd6�t||�}d|kr{d|krnd	|jdd
�}q�d|}n
d	|}|S(u�Escape and quote an attribute value.

    Escape &, <, and > in a string of data, then quote it for use as
    an attribute value.  The " character will be escaped as well, if
    necessary.

    You can escape other strings of data by passing a dictionary as
    the optional entities parameter.  The keys and values must all be
    strings; each key will be replaced with its corresponding value.
    u&#10;u
u&#13;u
u&#9;u	u"u'u"%s"u&quot;u'%s'(ucopyuupdateuescapeureplace(udatauentities((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu	quoteattr0s"

u	quoteattrcs�dkrddl}|jSt�tj�r5�St�tjtjf�rT�St�tj	�r�G�fdd�d�}|�}dd�|_
nXtj�}dd�|_�j
|_
y�j|_�j|_Wntk
r�YnXtj|d|dd	d
ddd
�S(Nics/|EeZdZ�jZ�fdd�ZdS(u _gettextwriter.<locals>._wrappercs
t�|�S(N(ugetattr(uselfuname(uout(u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu__getattr__[su,_gettextwriter.<locals>._wrapper.__getattr__N(u__name__u
__module__u__qualname__u	__class__u__getattr__(u
__locals__(uout(u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu_wrapperYs	u_wrappercSsdS(N(uNone(((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu<lambda>^su _gettextwriter.<locals>.<lambda>cSsdS(NT(uTrue(((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu<lambda>csuencodinguerrorsuxmlcharrefreplaceunewlineu
u
write_throughT(uNoneusysustdoutu
isinstanceuiou
TextIOBaseucodecsuStreamWriteruStreamReaderWriteru	RawIOBaseucloseuBufferedIOBaseuwritableuwriteuseekableutelluAttributeErroru
TextIOWrapperuTrue(uoutuencodingusysu_wrapperubuffer((uoutu5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu_gettextwriterHs.	
u_gettextwritercBs�|EeZdZddddd�Zdd�Zddd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS( uXMLGeneratoru
iso-8859-1cCs{tjj|�t||�}|j|_|j|_ig|_|jd|_	g|_
||_||_d|_dS(Nii����F(uhandleruContentHandleru__init__u_gettextwriteruwriteu_writeuflushu_flushu_ns_contextsu_current_contextu_undeclared_ns_mapsu	_encodingu_short_empty_elementsuFalseu_pending_start_element(uselfuoutuencodingushort_empty_elements((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu__init__ss			uXMLGenerator.__init__cCsX|drPd|dkr&d|dS|j|d}|rP|d|dSn|dS(u7Builds a qualified name from a (ns_url, localname) pairiu$http://www.w3.org/XML/1998/namespaceuxml:iu:(u_current_context(uselfunameuprefix((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu_qnames
uXMLGenerator._qnamecCs&|jr"|jd�d|_ndS(Nu>F(u_pending_start_elementu_writeuFalse(uselfu
endElement((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu_finish_pending_start_element�s	
u*XMLGenerator._finish_pending_start_elementcCs|jd|j�dS(Nu$<?xml version="1.0" encoding="%s"?>
(u_writeu	_encoding(uself((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
startDocument�s	uXMLGenerator.startDocumentcCs|j�dS(N(u_flush(uself((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendDocument�suXMLGenerator.endDocumentcCs@|jj|jj��||j|<|jj||f�dS(N(u_ns_contextsuappendu_current_contextucopyu_undeclared_ns_maps(uselfuprefixuuri((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartPrefixMapping�s
uXMLGenerator.startPrefixMappingcCs|jd|_|jd=dS(Nii����i����(u_ns_contextsu_current_context(uselfuprefix((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendPrefixMapping�suXMLGenerator.endPrefixMappingcCs{|j�|jd|�x7|j�D])\}}|jd|t|�f�q(W|jrjd|_n
|jd�dS(Nu<u %s=%su>T(u_finish_pending_start_elementu_writeuitemsu	quoteattru_short_empty_elementsuTrueu_pending_start_element(uselfunameuattrsuvalue((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartElement�s
!	uXMLGenerator.startElementcCs7|jr"|jd�d|_n|jd|�dS(Nu/>u</%s>F(u_pending_start_elementu_writeuFalse(uselfuname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
endElement�s	
uXMLGenerator.endElementcCs�|j�|jd|j|��xH|jD]=\}}|rZ|jd||f�q.|jd|�q.Wg|_x@|j�D]2\}}|jd|j|�t|�f�q�W|jr�d|_n
|jd�dS(Nu<u xmlns:%s="%s"u xmlns="%s"u %s=%su>T(	u_finish_pending_start_elementu_writeu_qnameu_undeclared_ns_mapsuitemsu	quoteattru_short_empty_elementsuTrueu_pending_start_element(uselfunameuqnameuattrsuprefixuuriuvalue((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartElementNS�s
	*	uXMLGenerator.startElementNScCs@|jr"|jd�d|_n|jd|j|��dS(Nu/>u</%s>F(u_pending_start_elementu_writeuFalseu_qname(uselfunameuqname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendElementNS�s	
uXMLGenerator.endElementNScCsN|rJ|j�t|t�s4t||j�}n|jt|��ndS(N(u_finish_pending_start_elementu
isinstanceustru	_encodingu_writeuescape(uselfucontent((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
characters�s

uXMLGenerator.characterscCsH|rD|j�t|t�s4t||j�}n|j|�ndS(N(u_finish_pending_start_elementu
isinstanceustru	_encodingu_write(uselfucontent((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuignorableWhitespace�s

u XMLGenerator.ignorableWhitespacecCs%|j�|jd||f�dS(Nu	<?%s %s?>(u_finish_pending_start_elementu_write(uselfutargetudata((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuprocessingInstruction�s
u"XMLGenerator.processingInstructionNF(u__name__u
__module__u__qualname__uNoneuFalseu__init__u_qnameu_finish_pending_start_elementu
startDocumentuendDocumentustartPrefixMappinguendPrefixMappingustartElementu
endElementustartElementNSuendElementNSu
charactersuignorableWhitespaceuprocessingInstruction(u
__locals__((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuXMLGeneratorqs
uXMLGeneratorcBsm|EeZdZdZd:dd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:S(;u
XMLFilterBaseuYThis class is designed to sit between an XMLReader and the
    client application's event handlers.  By default, it does nothing
    but pass requests up to the reader and events on to the handlers
    unmodified, but subclasses can override specific methods to modify
    the event stream or the configuration requests as they pass
    through.cCstjj|�||_dS(N(u	xmlreaderu	XMLReaderu__init__u_parent(uselfuparent((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu__init__�suXMLFilterBase.__init__cCs|jj|�dS(N(u_err_handleruerror(uselfu	exception((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuerror�suXMLFilterBase.errorcCs|jj|�dS(N(u_err_handleru
fatalError(uselfu	exception((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
fatalError�suXMLFilterBase.fatalErrorcCs|jj|�dS(N(u_err_handleruwarning(uselfu	exception((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuwarning�suXMLFilterBase.warningcCs|jj|�dS(N(u
_cont_handlerusetDocumentLocator(uselfulocator((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyusetDocumentLocator�su XMLFilterBase.setDocumentLocatorcCs|jj�dS(N(u
_cont_handleru
startDocument(uself((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
startDocumentsuXMLFilterBase.startDocumentcCs|jj�dS(N(u
_cont_handleruendDocument(uself((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendDocumentsuXMLFilterBase.endDocumentcCs|jj||�dS(N(u
_cont_handlerustartPrefixMapping(uselfuprefixuuri((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartPrefixMappingsu XMLFilterBase.startPrefixMappingcCs|jj|�dS(N(u
_cont_handleruendPrefixMapping(uselfuprefix((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendPrefixMapping	suXMLFilterBase.endPrefixMappingcCs|jj||�dS(N(u
_cont_handlerustartElement(uselfunameuattrs((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartElementsuXMLFilterBase.startElementcCs|jj|�dS(N(u
_cont_handleru
endElement(uselfuname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
endElementsuXMLFilterBase.endElementcCs|jj|||�dS(N(u
_cont_handlerustartElementNS(uselfunameuqnameuattrs((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyustartElementNSsuXMLFilterBase.startElementNScCs|jj||�dS(N(u
_cont_handleruendElementNS(uselfunameuqname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuendElementNSsuXMLFilterBase.endElementNScCs|jj|�dS(N(u
_cont_handleru
characters(uselfucontent((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
characterssuXMLFilterBase.characterscCs|jj|�dS(N(u
_cont_handleruignorableWhitespace(uselfuchars((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuignorableWhitespacesu!XMLFilterBase.ignorableWhitespacecCs|jj||�dS(N(u
_cont_handleruprocessingInstruction(uselfutargetudata((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuprocessingInstructionsu#XMLFilterBase.processingInstructioncCs|jj|�dS(N(u
_cont_handleru
skippedEntity(uselfuname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
skippedEntity!suXMLFilterBase.skippedEntitycCs|jj|||�dS(N(u_dtd_handlerunotationDecl(uselfunameupublicIdusystemId((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyunotationDecl&suXMLFilterBase.notationDeclcCs|jj||||�dS(N(u_dtd_handleruunparsedEntityDecl(uselfunameupublicIdusystemIdundata((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuunparsedEntityDecl)su XMLFilterBase.unparsedEntityDeclcCs|jj||�S(N(u_ent_handleru
resolveEntity(uselfupublicIdusystemId((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
resolveEntity.suXMLFilterBase.resolveEntitycCsT|jj|�|jj|�|jj|�|jj|�|jj|�dS(N(u_parentusetContentHandlerusetErrorHandlerusetEntityResolveru
setDTDHandleruparse(uselfusource((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuparse3s
uXMLFilterBase.parsecCs|jj|�dS(N(u_parentu	setLocale(uselfulocale((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu	setLocale:suXMLFilterBase.setLocalecCs|jj|�S(N(u_parentu
getFeature(uselfuname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
getFeature=suXMLFilterBase.getFeaturecCs|jj||�dS(N(u_parentu
setFeature(uselfunameustate((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
setFeature@suXMLFilterBase.setFeaturecCs|jj|�S(N(u_parentugetProperty(uselfuname((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyugetPropertyCsuXMLFilterBase.getPropertycCs|jj||�dS(N(u_parentusetProperty(uselfunameuvalue((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyusetPropertyFsuXMLFilterBase.setPropertycCs|jS(N(u_parent(uself((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu	getParentKsuXMLFilterBase.getParentcCs
||_dS(N(u_parent(uselfuparent((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu	setParentNsuXMLFilterBase.setParentN(!u__name__u
__module__u__qualname__u__doc__uNoneu__init__uerroru
fatalErroruwarningusetDocumentLocatoru
startDocumentuendDocumentustartPrefixMappinguendPrefixMappingustartElementu
endElementustartElementNSuendElementNSu
charactersuignorableWhitespaceuprocessingInstructionu
skippedEntityunotationDecluunparsedEntityDeclu
resolveEntityuparseu	setLocaleu
getFeatureu
setFeatureugetPropertyusetPropertyu	getParentu	setParent(u
__locals__((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu
XMLFilterBase�s:u
XMLFilterBaseucCs>t|t�r!tj|�}nSt|d�rt|}tj�}|j|�t|d�rt|j|j�qtn|j�dkr:|j
�}tjj
tjj|��}tjj||�}tjj|�r�|j|�t|d�}n4|jtjj||��tjj|j
��}|j|�n|S(u�This function takes an InputSource and an optional base URL and
    returns a fully resolved InputSource object ready for reading.ureadunameurbN(u
isinstanceustru	xmlreaderuInputSourceuhasattru
setByteStreamusetSystemIdunameu
getByteStreamuNoneugetSystemIduosupathudirnameunormpathujoinuisfileuopenuurllibuparseuurljoinurequestuurlopen(usourceubaseufusysidubaseheadu
sysidfilename((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyuprepare_input_sourceSs&

uprepare_input_source(u__doc__uosuurllib.parseuurllibuurllib.requestuioucodecsuuhandleru	xmlreaderu__dict_replaceuescapeuunescapeu	quoteattru_gettextwriteruContentHandleruXMLGeneratoru	XMLReaderu
XMLFilterBaseuprepare_input_source(((u5/opt/alt/python33/lib64/python3.3/xml/sax/saxutils.pyu<module>s$)so

?>