ó
ˇ8Jc           @   s)   d  Z  d d l Z d d d     YZ d S(   s4   
Provides XML I{special character} encoder classes.
i˙˙˙˙Nt   Encoderc           B   sY   e  Z d  Z d d d d d f Z d d d d d f Z d Z d   Z d   Z d   Z RS(   s=  
    An XML special character encoder/decoder.
    @cvar encodings: A mapping of special characters encoding.
    @type encodings: [(str,str)]
    @cvar decodings: A mapping of special characters decoding.
    @type decodings: [(str,str)]
    @cvar special: A list of special characters
    @type special: [char]
    s   &(?!(amp|lt|gt|quot|apos);)s   &amp;t   <s   &lt;t   >s   &gt;t   "s   &quot;t   's   &apos;t   &c         C   s:   t  | t  r6 x$ |  j D] } | | k r t Sq Wn  t S(   sÁ   
        Get whether string I{s} contains special characters.
        @param s: A string to check.
        @type s: str
        @return: True if needs encoding.
        @rtype: boolean
        (   t
   isinstancet
   basestringt   specialt   Truet   False(   t   selft   st   c(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/enc.pyt   needsEncoding)   s
    c         C   sV   t  | t  rR |  j |  rR x1 |  j D]# } t j | d | d |  } q( Wn  | S(   sľ   
        Encode special characters found in string I{s}.
        @param s: A string to encode.
        @type s: str
        @return: The encoded string.
        @rtype: str
        i    i   (   R   R   R   t	   encodingst   ret   sub(   R   R   t   x(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/enc.pyt   encode7   s    $c         C   sP   t  | t  rL d | k rL x. |  j D]  } | j | d | d  } q% Wn  | S(   sż   
        Decode special characters encodings found in string I{s}.
        @param s: A string to decode.
        @type s: str
        @return: The decoded string.
        @rtype: str
        R   i    i   (   R   R   t	   decodingst   replace(   R   R   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/enc.pyt   decodeD   s    !(   s   &(?!(amp|lt|gt|quot|apos);)s   &amp;(   R   s   &lt;(   R   s   &gt;(   R   s   &quot;(   R   s   &apos;(   s   &lt;R   (   s   &gt;R   (   s   &quot;R   (   s   &apos;R   (   s   &amp;R   (   R   R   R   R   R   (	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/enc.pyR       s   			(    (   R   R   R    (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/enc.pyt   <module>   s   