ó
 m[c           @` sł   d  d l  m Z m Z m Z m Z d  d l 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   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   cbookt   Substitutionc           B` s8   e  Z d  Z d   Z d   Z d   Z e d    Z RS(   u/  
    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` s8   t  |  o t  |  s% t d   | p. | |  _ d  S(   Nu+   Only positional or keyword args are allowed(   t   lent   AssertionErrort   params(   t   selft   argst   kwargs(    (    s3   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(    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   __call__,   s    c         O` s   |  j  j | |   d S(   u=   Assume self.params is a dict and update it with supplied argsN(   R   t   update(   R	   R
   R   (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR   0   s    c         C` s   |    } | | _  | S(   u(  
        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(    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   from_params4   s    		(   t   __name__t
   __module__R   R   R   R   t   classmethodR   (    (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR      s
   			t   Appenderc           B` s#   e  Z d  Z d d  Z d   Z RS(   uf  
    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
    u    c         C` s   | |  _  | |  _ d  S(   N(   t   addendumt   join(   R	   R   R   (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR   T   s    	c         C` s4   | j  |  j g } | j  o* |  j j |  | _  | S(   N(   R   R   R   (   R	   R   t   docitems(    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR   X   s    (   R   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR   A   s   c         C` s"   |  j  o t j |  j   |  _  |  S(   u   Dedent a docstring (if present)(   R   R   t   dedent(   R   (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyR   ^   s    c         ` s     f d   } | S(   u:   Copy a docstring from another source function (if present)c         ` s     j  r   j  |  _  n  |  S(   N(   R   (   t   target(   t   source(    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   do_copyf   s    	(    (   R   R   (    (   R   s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   copyd   s    c         C` s8   t  |  t j  r( t j r( |  j }  n  t t |    S(   uX   A special case of the interpd that first performs a dedent on
    the incoming docstring(   t
   isinstancet   typest
   MethodTypet   sixt   PY3t   im_funct   interpdR   (   R   (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   dedent_interpdq   s    c         ` s     f d   S(   uO   A decorator that will copy the docstring from the source and
    then dedent itc         ` s   t  t    |    S(   N(   R   R   (   R   (   R   (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   <lambda>   s    (    (   R   (    (   R   s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   copy_dedenty   s    (   t
   __future__R    R   R   R   R#   t
   matplotlibR   t   sysR!   t   objectR   R   R   R   R&   R'   R)   (    (    (    s3   lib/python2.7/site-packages/matplotlib/docstring.pyt   <module>   s   "6		
		