ó
±éRc           @  sû  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l Z d d l m Z d d l m Z d d l m Z e j Z d d l Z e j j d ƒ Z e g  e d  D]" Z e e
 j d	 e ƒ d
 ƒ ^ qó ƒ Z y d d l Z d „  Z Wn& e k
 r_d d l Z d „  Z n Xd d l Z d d l  j! Z! e j" d ƒ d d l# j$ Z% d d l m& Z& d Z y d d l' m( Z( Wne e k
 r(d e j) k rõe j* j+ d „ Z( q)d e j) k re j* j+ d „ Z( q)e, d ƒ ‚ n Xd „  Z- e  e- _  d „  Z. d „  Z/ d „  Z0 d „  Z1 d „  Z2 d „  Z3 d „  Z4 d „  Z5 d Z6 d Z7 e8 ƒ  Z9 d  e: f d! „  ƒ  YZ; d" „  Z< d# e, f d$ „  ƒ  YZ= d d d% „ Z? d& „  Z@ d' „  ZA d( „  ZB d S()   s*  
A directive for including a matplotlib plot in a Sphinx document.

By default, in HTML output, `plot` will include a .png file with a
link to a high-res .png and .pdf.  In LaTeX output, it will include a
.pdf.

The source code for the plot may be included in one of three ways:

  1. **A path to a source file** as the argument to the directive::

       .. plot:: path/to/plot.py

     When a path to a source file is given, the content of the
     directive may optionally contain a caption for the plot::

       .. plot:: path/to/plot.py

          This is the caption for the plot

     Additionally, one my specify the name of a function to call (with
     no arguments) immediately after importing the module::

       .. plot:: path/to/plot.py plot_function1

  2. Included as **inline content** to the directive::

       .. plot::

          import matplotlib.pyplot as plt
          import matplotlib.image as mpimg
          import numpy as np
          img = mpimg.imread('_static/stinkbug.png')
          imgplot = plt.imshow(img)

  3. Using **doctest** syntax::

       .. plot::
          A plotting example:
          >>> import matplotlib.pyplot as plt
          >>> plt.plot([1,2,3], [4,5,6])

Options
-------

The ``plot`` directive supports the following options:

    format : {'python', 'doctest'}
        Specify the format of the input

    include-source : bool
        Whether to display the source code. The default can be changed
        using the `plot_include_source` variable in conf.py

    encoding : str
        If this source file is in a non-UTF8 or non-ASCII encoding,
        the encoding must be specified using the `:encoding:` option.
        The encoding will not be inferred using the ``-*- coding -*-``
        metacomment.

    context : bool
        If provided, the code will be run in the context of all
        previous plot directives for which the `:context:` option was
        specified.  This only applies to inline code plot directives,
        not those run from files.

    nofigs : bool
        If specified, the code block will be run, but no figures will
        be inserted.  This is usually useful with the ``:context:``
        option.

Additionally, this directive supports all of the options of the
`image` directive, except for `target` (since plot will add its own
target).  These include `alt`, `height`, `width`, `scale`, `align` and
`class`.

Configuration options
---------------------

The plot directive has the following configuration options:

    plot_include_source
        Default value for the include-source option

    plot_pre_code
        Code that should be executed before each plot.

    plot_basedir
        Base directory, to which ``plot::`` file names are relative
        to.  (If None or empty, file names are relative to the
        directoly where the file containing the directive is.)

    plot_formats
        File formats to generate. List of tuples or strings::

            [(suffix, dpi), suffix, ...]

        that determine the file format and the DPI. For entries whose
        DPI was omitted, sensible defaults are chosen.

    plot_html_show_formats
        Whether to show links to the files in HTML.

    plot_rcparams
        A dictionary containing any non-standard rcParams that should
        be applied before each plot.

    plot_apply_rcparams
        By default, rcParams are applied when `context` option is not used in 
        a plot  directive.  This configuration option overrides this behaviour 
        and applies rcParams before each plot.

    plot_working_directory
        By default, the working directory will be changed to the directory of 
        the example, so the code can get at its data files, if any.  Also its 
        path will be added to `sys.path` so it can import any helper modules 
        sitting beside it.  This configuration option can be used to specify 
        a central directory (also added to `sys.path`) where data files and 
        helper modules for all code are located. 

    plot_template
        Provide a customized template for preparing resturctured text.
        

iÿÿÿÿ(   t   print_functionN(   t
   directives(   t   nodes(   t   Imaget   .i   s   [a-z]i    c         K  s   t  j |  ƒ j | �  S(   N(   t   jinja2t   Templatet   render(   t   templatet   kw(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   format_template’   s    c         K  s   t  j |  | � S(   N(   t   jinjat   from_string(   R   R	   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR
   –   s    t   Agg(   t   _pylab_helpers(   t   relpatht   posixc         C  s¸   d d l  m } m } m } m } m } m } |  sC t d ƒ ‚ n  | | ƒ j | ƒ } | |  ƒ j | ƒ }	 t	 | | |	 g ƒ ƒ }
 | g t	 | ƒ |
 |	 |
 } | s® | S| | Œ  S(   s#   Return a relative version of a pathiÿÿÿÿ(   t   sept   curdirt   joint   abspatht   commonprefixt   pardirs   no path specified(
   t   os.pathR   R   R   R   R   R   t
   ValueErrort   splitt   len(   t   patht   startR   R   R   R   R   R   t
   start_listt	   path_listt   it   rel_list(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR   «   s    .t   ntc         C  s”  d d l  m } m } m } m } m } m } m } |  sI t d ƒ ‚ n  | | ƒ j	 | ƒ }	 | |  ƒ j	 | ƒ }
 |	 d j
 ƒ  |
 d j
 ƒ  k r| |  ƒ \ } } | | ƒ \ } } t | ƒ t | ƒ Aræ t d |  | f ƒ ‚ qt d |
 d |	 d f ƒ ‚ n  xW t t t |	 ƒ t |
 ƒ ƒ ƒ D]* } |	 | j
 ƒ  |
 | j
 ƒ  k r)Pq)q)W| d 7} | g t |	 ƒ | |
 | } | sŠ| S| | Œ  S(   s#   Return a relative version of a pathiÿÿÿÿ(   R   R   R   R   R   R   t   splituncs   no path specifiedi    s,   Cannot mix UNC and non-UNC paths (%s and %s)s&   path is on drive %s, start on drive %si   (   R   R   R   R   R   R   R   R"   R   R   t   lowert   boolt   ranget   minR   (   R   R   R   R   R   R   R   R   R"   R   R   t   unc_patht   restt	   unc_startR   R    (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR   ¾   s*    4 ( 
s,   Unsupported platform (no relpath available!)c	   	      C  s   t  | | | | | | ƒ S(   N(   t   run(	   t   namet	   argumentst   optionst   contentt   linenot   content_offsett
   block_textt   statet   state_machine(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   plot_directiveâ   s    c         C  sd   |  s |  j  ƒ  r t S|  j  ƒ  j ƒ  d k r4 t S|  j  ƒ  j ƒ  d	 k rP t St d |  ƒ ‚ d  S(
   Nt   not   0t   falset   yest   1t   trues   "%s" unknown boolean(   s   noR6   s   false(   s   yesR9   s   true(   t   stript   TrueR#   t   FalseR   (   t   arg(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   _option_booleanç   s    c         C  s   t  j |  d ƒ S(   Nt   pythont   doctest(   s   pythons   doctest(   R   t   choice(   R>   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   _option_formatò   s    c         C  s   t  j |  d ƒ S(   Nt   topt   middlet   bottomt   leftt   centert   right(   s   topRE   RF   s   lefts   centers   right(   R   RB   (   R>   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   _option_alignõ   s    	c   	      C  s1  x*| j  j ƒ  D]\ } } | s( q n  | j | } | d k rG q n  | j | } | j d k r xÃ | D]¸ } | j d k rj | } x- | D]% } | j d k rŒ | j ƒ  } PqŒ qŒ W| d j | ƒ | d j | ƒ | d j | ƒ | d j | ƒ | j	 j
 j | | f | j	 j
 j | <Pqj qj Wq q Wd S(	   s˜   
    To make plots referenceable, we need to move the reference from
    the "htmlonly" (or "latexonly") node to the actual figure node
    itself.
    t	   html_onlyt
   latex_onlyt   figuret   captiont   idst   namesN(   RK   RL   (   t	   nametypest	   iteritemst   nameidst   NoneRO   t   tagnamet   astextt   removet   appendt   settingst   envt   docnamet   labels(	   t   appt   documentR+   t   explicitt   labelidt   nodet   nt   sectnamet   c(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   mark_plot_labelsù   s*    %c         C  sv  |  t  _ |  j t  _ |  j t  _ i t j d 6t j d 6t j d 6t j d 6t	 d 6t j
 d 6t d 6t d 6t j d	 6t j d
 6t j d 6} |  j d t t d d t f | � |  j d d  t ƒ |  j d t t ƒ |  j d d d d g t ƒ |  j d d  t ƒ |  j d t t ƒ |  j d i  t ƒ |  j d t t ƒ |  j d d  t ƒ |  j d d  t ƒ |  j d t ƒ d  S(   Nt   altt   heightt   widtht   scalet   alignt   classs   include-sourcet   formatt   contextt   nofigst   encodingt   ploti    i   t   plot_pre_codet   plot_include_sourcet   plot_formatst   pngs	   hires.pngt   pdft   plot_basedirt   plot_html_show_formatst   plot_rcparamst   plot_apply_rcparamst   plot_working_directoryt   plot_templates   doctree-read(   t   setupR]   t   configt   confdirR   t	   unchangedt   length_or_unitlesst    length_or_percentage_or_unitlesst   nonnegative_intRJ   t   class_optionR?   RC   t   flagRo   t   add_directiveR4   R<   R=   t   add_config_valueRT   t   connectRe   (   R]   R-   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR|     s2    	





"c         C  sZ   y t  |  d d ƒ t SWn t k
 r+ n Xt j  d t j ƒ } | j |  ƒ } t | ƒ S(   Ns   <string>t   execs   ^\s*>>>(   t   compileR=   t   SyntaxErrort   ret   Mt   searchR$   (   t   textt   rt   m(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   contains_doctest:  s    c         C  s—   t  |  ƒ s |  Sd } xz |  j d ƒ D]i } t j d | ƒ } | r^ | | j d ƒ d 7} q& | j ƒ  r… | d | j ƒ  d 7} q& | d 7} q& W| S(   s`   
    Extract code from a piece of text, which contains either Python code
    or doctests.

    t    s   
s   ^\s*(>>>|\.\.\.) (.*)$i   s   # (   R‘   R   R‹   t   matcht   groupR;   (   RŽ   t   codet   lineR�   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   unescape_doctestE  s    c         C  sÎ   g  } t  |  ƒ } g  } x� |  j d ƒ D]p } | rG | j ƒ  d k s_ | r‹ | j ƒ  d k r‹ | j | ƒ | j d j | ƒ ƒ g  } q( | j | ƒ q( Wd j | ƒ j ƒ  rÊ | j d j | ƒ ƒ n  | S(   s#   
    Split code at plt.show()

    s   
s
   plt.show()s   >>> plt.show()(   R‘   R   R;   RX   R   (   RŽ   t   partst
   is_doctestt   partR–   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   split_code_at_showY  s    	s  
{{ source_code }}

{{ only_html }}

   {% if source_link or (html_show_formats and not multi_image) %}
   (
   {%- if source_link -%}
   `Source code <{{ source_link }}>`__
   {%- endif -%}
   {%- if html_show_formats and not multi_image -%}
     {%- for img in images -%}
       {%- for fmt in img.formats -%}
         {%- if source_link or not loop.first -%}, {% endif -%}
         `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__
       {%- endfor -%}
     {%- endfor -%}
   {%- endif -%}
   )
   {% endif %}

   {% for img in images %}
   .. figure:: {{ build_dir }}/{{ img.basename }}.png
      {%- for option in options %}
      {{ option }}
      {% endfor %}

      {% if html_show_formats and multi_image -%}
        (
        {%- for fmt in img.formats -%}
        {%- if not loop.first -%}, {% endif -%}
        `{{ fmt }} <{{ dest_dir }}/{{ img.basename }}.{{ fmt }}>`__
        {%- endfor -%}
        )
      {%- endif -%}

      {{ caption }}
   {% endfor %}

{{ only_latex }}

   {% for img in images %}
   .. image:: {{ build_dir }}/{{ img.basename }}.pdf
   {% endfor %}

{{ only_texinfo }}

   {% for img in images %}
   .. image:: {{ build_dir }}/{{ img.basename }}.png
      {%- for option in options %}
      {{ option }}
      {% endfor %}

   {% endfor %}

sh   
.. htmlonly::

   [`source code <%(linkdir)s/%(basename)s.py>`__]

Exception occurred rendering plot.

t	   ImageFilec           B  s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C  s   | |  _  | |  _ g  |  _ d  S(   N(   t   basenamet   dirnamet   formats(   t   selfR�   Rž   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   __init__»  s    		c         C  s#   t  j j |  j d |  j | f ƒ S(   Ns   %s.%s(   t   osR   R   Rž   R�   (   R    Rl   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   filenameÀ  s    c         C  s#   g  |  j  D] } |  j | ƒ ^ q
 S(   N(   RŸ   R£   (   R    t   fmt(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt	   filenamesÃ  s    (   t   __name__t
   __module__R¡   R£   R¥   (    (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyRœ   º  s   		c         C  sG   t  j j | ƒ pF t  j j |  ƒ oF t  j | ƒ j t  j |  ƒ j k  S(   sh   
    Returns True if derivative is out-of-date wrt original,
    both of which are full file paths.
    (   R¢   R   t   existst   statt   st_mtime(   t   originalt   derived(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   out_of_dateÆ  s    t	   PlotErrorc           B  s   e  Z RS(    (   R¦   R§   (    (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR®   Ï  s   c   
      B  s$  e  j ƒ  } e e j ƒ } e j j d k	 r´ y e  j	 e j j ƒ WnQ e
 k
 ro } e
 e | ƒ d ƒ ‚ n) e k
 r— } e e | ƒ d ƒ ‚ n Xe j j d e j j ƒ nM | d k	 re  j j e  j j | ƒ ƒ } e  j	 | ƒ e j j d | ƒ n  e j } e j ƒ  e _ e j }	 | g e _ zÅ y“ e |  ƒ }  | d k rUi  } n  | s‰e j j d k rxd | Uq‰e j j | Un  d |  k r d | Un  |  | U| d k	 rÃ| d | Un  Wn+ e e f k
 rñ} e e j ƒ  ƒ ‚ n XWd e  j	 | ƒ |	 e _ | e j (| e _ X| S(	   ss   
    Import a Python module from a path, and run the function given by
    name, if function_name is not None.
    s[   
`plot_working_directory` option inSphinx configuration file must be a valid directory pathsV   
`plot_working_directory` option in Sphinx configuration file must be a string or Nonei    s8   import numpy as np
from matplotlib import pyplot as plt
t   __main__s   __name__ = '__main__'s   ()N(   R¢   t   getcwdt   listt   sysR   R|   R}   Rz   RT   t   chdirt   OSErrort   strt	   TypeErrort   insertR   Rž   t   stdoutt	   cStringIOt   StringIOt   argvR—   Rq   t	   Exceptiont
   SystemExitR®   t	   tracebackt
   format_exc(
   R•   t	   code_patht   nst   function_namet   pwdt   old_sys_patht   errRž   R¸   t   old_sys_argv(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   run_codeÒ  sN    
				

c         C  s+   t  j d ƒ t j ƒ  t j j |  ƒ d  S(   Nt   all(   t   pltt   closet
   matplotlibt   rc_file_defaultst   rcParamst   update(   Rx   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   clear_state  s    
c         C  sm  i d d 6d d 6d d 6} g  } | j  }	 t |	 t t f ƒ rN t |	 ƒ }	 n  x£ |	 D]› }
 t |
 t ƒ rŒ | j |
 | j |
 d ƒ f ƒ qU t |
 ƒ t t	 f k rà t
 |
 ƒ d k rà | j t |
 d ƒ t |
 d ƒ f ƒ qU t d	 |
 ƒ ‚ qU Wt |  ƒ } t } t | | ƒ } xF | D]> \ } } t | | j | ƒ ƒ rJt } Pn  | j j | ƒ qW| rt|  | g f g Sg  } t } x
t | ƒ D]ü \ } } g  } xÊ t d
 ƒ D]¼ } t
 | ƒ d k rãt d | | | f | ƒ } n t d | | f | ƒ } xF | D]> \ } } t | | j | ƒ ƒ r1t } Pn  | j j | ƒ qW| s[| d k } Pn  | j | ƒ q¬W| svPn  | j | | f ƒ q�W| r—| Sg  } | r¬t } n i  } x”t | ƒ D]†\ } } | sÛ| j rët | j ƒ n  t | | | | ƒ g  } t j j ƒ  } xt | ƒ D]\ } } t
 | ƒ d k rbt
 | ƒ d k rbt | | ƒ } nJ t
 | ƒ d k r�t d | | f | ƒ } n t d | | | f | ƒ } | j | ƒ xr | D]j \ } } y& | j j j  | j | ƒ d | ƒWn% t! k
 r} t t" j# ƒ  ƒ ‚ n X| j j | ƒ qÀWq W| j | | f ƒ q¿W| sY| j rit | j ƒ n  | S(   s°   
    Run a pyplot script and save the low and high res PNGs and a PDF
    in outdir.

    Save the images under *output_dir* with file names derived from
    *output_base*
    iP   Rt   iÈ   s	   hires.pngRu   i   i    i   s)   invalid image format "%r" in plot_formatsiè  s   %s_%02d_%02ds   %s_%02dt   dpi($   Rs   t
   isinstanceRµ   t   unicodet   evalRX   t   gett   typet   tupleR±   R   t   intR®   R›   R<   Rœ   R­   R£   R=   RŸ   t	   enumeratet   xranget   plot_contextRy   RÏ   Rx   RÇ   R   t   Gcft   get_all_fig_managerst   canvasRM   t   savefigR¼   R¾   R¿   (   R•   RÀ   t
   output_dirt   output_baseRm   RÂ   R}   t   default_dpiRŸ   Rs   R¤   t   code_piecest
   all_existst   imgRl   RÐ   t   resultsR   t
   code_piecet   imagest   jRÁ   t   fig_managerst   figmanRÅ   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   render_figures  sŽ    
	"**	$	&c   8      C  s[  |  r | r t  d ƒ ‚ n  | j } | j j j } | j d ƒ } | j d | j ƒ | j d ƒ }	 | j d }
 t	 j
 j |
 ƒ } t |  ƒ r^| j sÆ t	 j
 j t j j j t j |  d ƒ ƒ } n+ t	 j
 j t j | j t j |  d ƒ ƒ } d j | ƒ } t |  ƒ d k r|  d	 } n d  } t | d
 ƒ � } | j ƒ  } Wd  QXt	 j
 j | ƒ } n� |
 } t j d j t t | ƒ ƒ ƒ } | j j d d ƒ d	 } | | j d <t	 j
 j t	 j
 j | ƒ ƒ \ } } d | | f } d  } d } t	 j
 j | ƒ \ } } | d3 k r| } n d } | j  d d ƒ } t! | ƒ } | j d ƒ rm| d d k rdt" } qmt# } n  t$ | t j ƒ } t	 j
 j | ƒ } x# | j% t	 j
 j& ƒ r¶| d	 } q”Wt	 j
 j t	 j
 j t j j' ƒ d | ƒ } t	 j
 j( | ƒ } t	 j
 j) | ƒ st	 j* | ƒ n  t	 j
 j+ t	 j
 j t j j j, | ƒ ƒ } t	 j
 j) | ƒ sat	 j* | ƒ n  t	 j
 j t$ t j | ƒ | ƒ j  t	 j
 j& d ƒ } t$ | | ƒ j  t	 j
 j& d ƒ } | d | | } y( t- | | | | |	 | | ƒ } g  } Wn\ t. k
 rM}  | j/ j0 }! |! j1 d d | | |  f d | ƒ}" | g  f g } |" g } n Xd j d „  | j2 d ƒ Dƒ ƒ } g  }# xÂt3 | ƒ D]´\ }$ \ }% }& | d r+| rÝd g }' |' g  |% j2 d ƒ D] }( |( j4 ƒ  ^ qÁ7}' n< d d g }' |' g  |% j2 d ƒ D] }( d |( j4 ƒ  ^ qü7}' d j |' ƒ }) n d }) | r@g  }& n  g  | j5 ƒ  D]( \ }* }+ |* d4 k rMd" |* |+ f ^ qM}, d# }- d$ }. d% }/ |$ d k r¢| }0 n d  }0 t6 | j7 p·t8 d& | d' | d( |0 d) t |& ƒ d	 k d* |- d+ |. d, |/ d- |, d. |& d/ |) d0 | j9 d1 | ƒ}1 |# j: |1 j2 d ƒ ƒ |# j: d ƒ qƒW|# rW| j; |# d | ƒn  t	 j
 j) | ƒ syt< j= | ƒ n  x| | D]t \ }% }& xe |& D]] }2 xT |2 j> ƒ  D]F }3 t	 j
 j | t	 j
 j |3 ƒ ƒ }4 |3 |4 k r¦t? j@ |3 |4 ƒ q¦q¦Wq“Wq€Wt	 j
 j | | | ƒ }5 t |5 d2 ƒ �5 }6 | |
 k r>tA | ƒ }7 n | }7 |6 jB |7 ƒ Wd  QX| S(5   Ns1   plot:: directive can't have both args and contentRn   s   include-sourceRm   t   sourcei    s   
i   i   R�   t   _plot_counters   %s-%d.pyR’   s   .pys   .rsts   .txtR   t   -Rl   R@   R4   t   /s.   Exception occurred in plotting %s
 from %s:
%sR–   c         s  s   |  ] } d  | j  ƒ  Vq d S(   s         N(   R;   (   t   .0R–   (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pys	   <genexpr>é  s   s   .. code-block:: pythons       %sRf   Rg   Rh   Ri   Rj   Rk   s   :%s: %ss   .. only:: htmls   .. only:: latexs   .. only:: texinfot   dest_dirt	   build_dirt   source_linkt   multi_imaget	   only_htmlt
   only_latext   only_texinfoR-   Rç   t   source_codet   html_show_formatsRN   t   w(   s   .pys   .rsts   .txt(   s   alts   heights   widths   scales   aligns   class(C   t   RuntimeErrorR^   RY   RZ   R}   t   has_keyt
   setdefaultRr   t
   attributesR¢   R   Rž   R   Rv   R   R|   R]   t   buildert   srcdirR   t   uriR~   RT   t   opent   readR�   t   textwrapt   dedentt   mapRµ   RÔ   t   splitextt   replaceR‘   R=   R<   R   t
   startswithR   t
   doctreedirt   normpathR¨   t   makedirsR   t   outdirRë   R®   t   memot   reportert   system_messageR   RØ   t   rstript   itemsR
   R{   t   TEMPLATERw   t   extendt   insert_inputt   cbookt   mkdirsR¥   t   shutilt   copyfileR—   t   write(8   R,   R.   R-   R3   R2   R/   R^   R}   Rn   Rm   t   rst_filet   rst_dirt   source_file_nameRN   RÂ   t   fdR•   Rà   t   countert   baset   extt
   source_extR™   t   source_rel_namet   source_rel_dirRò   Rñ   t   dest_dir_linkt   build_dir_linkRó   Rå   t   errorsRÅ   R  t   smt   total_linesRè   Ræ   Rç   t   linest   rowRø   t   keyt   valt   optsRõ   Rö   R÷   t   src_linkt   resultRä   t   fnt   destimgt   target_namet   ft   code_escaped(    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyR*   ~  sü    		!$				!
		
	/*	"			!(C   t   __doc__t
   __future__R    R²   R¢   t   globR  t   impt   warningsR¹   R‹   R  R¾   t   docutils.parsers.rstR   t   docutilsR   t&   docutils.parsers.rst.directives.imagesR   Rj   t   sphinxt   __version__R   t   sphinx_versionRÖ   t   xR×   R   R
   t   ImportErrorR   RË   t   matplotlib.cbookR  t   uset   matplotlib.pyplott   pyplotRÉ   R   R   R   t   builtin_module_namesR   R   Rû   R4   R?   RC   RJ   Re   R|   R‘   R—   R›   R  t   exception_templatet   dictRÚ   t   objectRœ   R­   R®   RT   RÇ   RÏ   Rë   R*   (    (    (    s]   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/sphinxext/plot_directive.pyt   <module>}   sf   l	3							#			R				=		j