ó
W^Kc           @   si   d  Z  d d l Z d d l m Z d d l Td d l Td d l m Z e e ƒ Z d d d „  ƒ  YZ	 d S(	   s$   
Provides XML I{attribute} classes.
iÿÿÿÿN(   t	   getLogger(   t   *(   t   Textt	   Attributec           B   s˜   e  Z d  Z d d „ Z d d „ Z d „  Z d „  Z e d ƒ d „ Z	 d „  Z
 d „  Z d	 „  Z d d d
 „ Z d „  Z d „  Z d „  Z d „  Z RS(   sd  
    An XML attribute object.
    @ivar parent: The node containing this attribute
    @type parent: L{element.Element}
    @ivar prefix: The I{optional} namespace prefix.
    @type prefix: basestring
    @ivar name: The I{unqualified} name of the attribute
    @type name: basestring
    @ivar value: The attribute's value
    @type value: basestring
    c         C   s2   d |  _ t | ƒ \ |  _ |  _ |  j | ƒ d S(   sÂ   
        @param name: The attribute's name with I{optional} namespace prefix.
        @type name: basestring
        @param value: The attribute's value
        @type value: basestring 
        N(   t   Nonet   parentt   splitPrefixt   prefixt   namet   setValue(   t   selfR   t   value(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   __init__)   s    	c         C   s%   t  |  j ƒ  |  j ƒ } | | _ | S(   sÞ   
        Clone this object.
        @param parent: The parent for the clone.
        @type parent: L{element.Element}
        @return: A copy of this object assigned to the new parent.
        @rtype: L{Attribute}
        (   R   t   qnameR   R   (   R
   R   t   a(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   clone4   s    	c         C   s3   |  j  d k r |  j Sd j |  j  |  j f ƒ Sd S(   s‰   
        Get the B{fully} qualified name of this attribute
        @return: The fully qualified name.
        @rtype: basestring
        t   :N(   R   R   R   t   join(   R
   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyR   @   s    c         C   s.   t  | t ƒ r | |  _ n t | ƒ |  _ |  S(   s¯   
        Set the attributes value
        @param value: The new value (may be None)
        @type value: basestring
        @return: self
        @rtype: L{Attribute}
        (   t
   isinstanceR   R   (   R
   R   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyR	   K   s    t    c         C   s   |  j  ƒ  r |  j S| Sd S(   s  
        Get the attributes value with optional default.
        @param default: An optional value to be return when the
            attribute's has not been set.
        @type default: basestring
        @return: The attribute's value, or I{default}
        @rtype: L{Text}
        N(   t   hasTextR   (   R
   t   default(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   getValueY   s    	c         C   s   |  j  d k	 o t |  j  ƒ S(   s±   
        Get whether the attribute has I{text} and that it is not an empty
        (zero length) string.
        @return: True when has I{text}.
        @rtype: boolean
        N(   R   R   t   len(   R
   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyR   g   s    c         C   s*   |  j  d k r t j S|  j |  j  ƒ Sd S(   sã   
        Get the attributes namespace.  This may either be the namespace
        defined by an optional prefix, or its parent's namespace.
        @return: The attribute's namespace
        @rtype: (I{prefix}, I{name})
        N(   R   R   t	   NamespaceR   t   resolvePrefix(   R
   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt	   namespacep   s    c         C   s1   t  j } |  j d k	 r- |  j j | ƒ } n  | S(   sô   
        Resolve the specified prefix to a known namespace.
        @param prefix: A declared prefix
        @type prefix: basestring
        @return: The namespace that has been mapped to I{prefix}
        @rtype: (I{prefix}, I{name})
        N(   R   R   R   R   R   (   R
   R   t   ns(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyR   |   s    	c         C   s]   | d k r t } n |  j | k } | d k r9 t } n |  j ƒ  d | d k } | o\ | S(   s   
        Match by (optional) name and/or (optional) namespace.
        @param name: The optional attribute tag name.
        @type name: str
        @param ns: An optional namespace.
        @type ns: (I{prefix}, I{name})
        @return: True if matched.
        @rtype: boolean
        i   N(   R   t   TrueR   R   (   R
   R   R   t   bynamet   byns(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   match‰   s    
		c         C   s=   | d k	 o< t | t ƒ o< |  j | j k o< |  j | j k S(   s    equals operator N(   R   R   R   R   R   (   R
   t   rhs(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   __eq__�   s    c         C   s   d |  j  |  j |  j f S(   s    get a string representation s%   attr (prefix=%s, name=%s, value=(%s))(   R   R   R   (   R
   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   __repr__¤   s    c         C   s   t  |  ƒ j d ƒ S(   s"    get an xml string representation s   utf-8(   t   unicodet   encode(   R
   (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   __str__ª   s    c         C   sA   |  j  ƒ  } |  j ƒ  r* |  j j ƒ  } n	 |  j } d | | f S(   s"    get an xml string representation u   %s="%s"(   R   R   R   t   escape(   R
   t   nt   v(    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   __unicode__®   s
    	N(   t   __name__t
   __module__t   __doc__R   R   R   R   R	   R   R   R   R   R   R   R!   R"   R%   R)   (    (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyR      s   									(    (
   R,   t   suds.saxt   sudst   loggingR    t   suds.sax.textR   R*   t   logR   (    (    (    sL   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/sax/attribute.pyt   <module>   s   

