ó
±éRc           @  s•   d  d l  m Z d  d l m Z d  d l Z d  d l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z	 d	 „  Z
 e ƒ  Z d
 „  Z d „  Z d S(   iÿÿÿÿ(   t   print_function(   t   cbookNt   Substitutionc           B  s8   e  Z d  Z d „  Z d „  Z d „  Z e d „  ƒ Z RS(   s/  
    A decorator to take a function's docstring and perform string
    substitution on it.

    This decorator should be robust even if func.__doc__ is None
    (for example, if -OO was passed to the interpreter)

    Usage: construct a docstring.Substitution with a sequence or
    dictionary suitable for performing substitution; then
    decorate a suitable function with the constructed object. e.g.

    sub_author_name = Substitution(author='Jason')

    @sub_author_name
    def some_function(x):
        "%(author)s wrote this function"

    # note that some_function.__doc__ is now "Jason wrote this function"

    One can also use positional arguments.

    sub_first_last_names = Substitution('Edgar Allen', 'Poe')

    @sub_first_last_names
    def some_function(x):
        "%s %s wrote the Raven"
    c         O  s,   | o	 | s t  d ƒ ‚ | p" | |  _ d  S(   Ns+   Only positional or keyword args are allowed(   t   AssertionErrort   params(   t   selft   argst   kwargs(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   __init__"   s    c         C  s    | j  o | j  |  j | _  | S(   N(   t   __doc__R   (   R   t   func(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   __call__&   s    c         O  s   |  j  j | | Ž  d S(   s=   Assume self.params is a dict and update it with supplied argsN(   R   t   update(   R   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR   *   s    c         C  s   |  ƒ  } | | _  | S(   s(  
        In the case where the params is a mutable sequence (list or dictionary)
        and it may change before this class is called, one may explicitly use
        a reference to the params rather than using *args or **kwargs which will
        copy the values and not reference them.
        (   R   (   t   clsR   t   result(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   from_params.   s    		(   t   __name__t
   __module__R	   R   R   R   t   classmethodR   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR      s
   			t   Appenderc           B  s#   e  Z d  Z d d „ Z d „  Z RS(   sf  
    A function decorator that will append an addendum to the docstring
    of the target function.

    This decorator should be robust even if func.__doc__ is None
    (for example, if -OO was passed to the interpreter).

    Usage: construct a docstring.Appender with a string to be joined to
    the original docstring. An optional 'join' parameter may be supplied
    which will be used to join the docstring and addendum. e.g.

    add_copyright = Appender("Copyright (c) 2009", join='
')

    @add_copyright
    def my_dog(has='fleas'):
        "This docstring will have a copyright below"
        pass
    t    c         C  s   | |  _  | |  _ d  S(   N(   t   addendumt   join(   R   R   R   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR   M   s    	c         C  s1   | j  |  j g } | j  o' d j | ƒ | _  | S(   NR   (   R	   R   R   (   R   R
   t   docitems(    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR   Q   s    (   R   R   R	   R   R   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR   :   s   c         C  s"   |  j  o t j |  j  ƒ |  _  |  S(   s   Dedent a docstring (if present)(   R	   R   t   dedent(   R
   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyR   V   s    c           s   ‡  f d †  } | S(   s:   Copy a docstring from another source function (if present)c           s   ˆ  j  r ˆ  j  |  _  n  |  S(   N(   R	   (   t   target(   t   source(    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   do_copy]   s    	(    (   R   R   (    (   R   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   copy[   s    c         C  sA   t  |  t j ƒ r1 t j d d k  r1 |  j }  n  t t |  ƒ ƒ S(   sX   A special case of the interpd that first performs a dedent on
    the incoming docstringi    i   (   t
   isinstancet   typest
   MethodTypet   syst   version_infot   im_funct   interpdR   (   R
   (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   dedent_interpdg   s    %c           s   ‡  f d †  S(   sO   A decorator that will copy the docstring from the source and
    then dedent itc           s   t  t ˆ  ƒ |  ƒ ƒ S(   N(   R   R   (   R   (   R   (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   <lambda>u   s    (    (   R   (    (   R   sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   copy_dedentn   s    (   t
   __future__R    t
   matplotlibR   R    R   t   objectR   R   R   R   R#   R$   R&   (    (    (    sN   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/docstring.pyt   <module>   s   4		
		