
\c           @   s  d  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 m	 Z	 d d l
 m Z m Z m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z m Z d d	 l m Z m Z d d
 l m  Z  d d l! m" Z" d d l# m$ Z$ d d l% m& Z& m' Z' e( rd d l
 m Z m) Z) m* Z* m+ Z+ m, Z, m- Z- m. Z. m Z d d l/ m0 Z0 d d l1 m2 Z2 n  e  j3 e4  Z5 d Z6 e e j7 e j8 f Z9 e j: d  Z; e re< Z= n  e d d e< f d e f d e e> e= f f g  Z? d   Z@ d eA f d     YZB e g ZC e rReC jD e  n  d eA f d     YZE d   ZF d   ZG d   ZH d   ZI d    ZJ d!   ZK d"   ZL d S(#   s   
    sphinx.config
    ~~~~~~~~~~~~~

    Build configuration file handling.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iN(   t   OrderedDict(   t   patht   getenv(   t   Anyt
   NamedTuplet   Union(   t   PY2t   PY3t	   iteritemst   string_typest   binary_typet	   text_typet   integer_typest   class_types(   t   RemovedInSphinx30Warning(   t   ConfigErrort   ExtensionError(   t   _t   __(   t   logging(   t   format_date(   t   cd(   t	   execfile_t   NoneType(   R   t   Callablet   Dictt	   Generatort   Iteratort   Listt   TupleR   (   t   Sphinx(   t   Tagss   conf.pys   ^((\d{4}-)?)(\d{4})(?=[ ,])t   ConfigValuet   namet   valuet   rebuildc         C   s   t  |  t  r t St  |  t  r` xg t |   D]* \ } } t |  sU t |  r/ t Sq/ Wn, t  |  t t t f  r t	 d   |  D  St
 S(   s'   Check if object is serializable or not.c         s   s   |  ] } t  |  Vq d  S(   N(   t   is_serializable(   t   .0t   i(    (    s,   lib/python2.7/site-packages/sphinx/config.pys	   <genexpr>>   s    (   t
   isinstancet   UNSERIALIZABLE_TYPESt   Falset   dictR   R$   t   listt   tuplet   sett   allt   True(   t   objt   keyR"   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR$   4   s    t   ENUMc           B   s    e  Z d  Z d   Z d   Z RS(   s   represents the config value should be a one of candidates.

    Example:
        app.add_config_value('latex_show_urls', 'no', None, ENUM('no', 'footnote', 'inline'))
    c         G   s   | |  _  d  S(   N(   t
   candidates(   t   selfR3   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __init__I   s    c            s@   t  | t t f  r/ t   f d   | D  S|   j k Sd  S(   Nc         3   s   |  ] } |   j  k Vq d  S(   N(   R3   (   R%   t   item(   R4   (    s,   lib/python2.7/site-packages/sphinx/config.pys	   <genexpr>P   s    (   R'   R+   R,   R.   R3   (   R4   R"   (    (   R4   s,   lib/python2.7/site-packages/sphinx/config.pyt   matchM   s    (   t   __name__t
   __module__t   __doc__R5   R7   (    (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR2   C   s   	t   Configc        c   B   s  e  Z d  Z e d d d g  f d d d g  f d d d g  f d	 d d g  f d
 d d g  f d d d g  f d dV d e f d dV d e f d d g d g  f d d d e g f d d d g  f d i d d 6d e f d d d g  f d i  d g  f d g  d g  f d dV d e f d e d g  f d e d g  f d e	 d g  f d e	 d g  f d  dV d e f d! d" d g  f d# i  d g  f d$ g  d g  f d% dV d e f d& e	 d g  f d' g  d g  f d( g  d g  f d) dV d e f d* dV d e f d+ e d g  f d, d- d e
 g f d. dV dV e f d/ i  dV g  f d0 dV d g  f d1 e	 dV g  f d2 g  dV g  f d3 e	 d g  f d4 d5 d g  f d6 i  d g  f d7 e	 d g  f d8 dV d e f d9 e d g  f d: e d g  f d; dV d g  f d< e d g  f d= d> d g  f d? i d@ g dA 6dB dC g dD 6d g  f  0Z dE   Z e dV dV dF   Z dG   Z dH   Z dI   Z dJ   Z dK   Z dL   Z dM   Z dN   Z dO   Z dP   Z dQ   Z dR   Z dS   Z dT   Z dU   Z RS(W   s  Configuration file abstraction.

    The config object makes the values of all config values available as
    attributes.

    It is exposed via the :py:attr:`sphinx.application.Application.config` and
    :py:attr:`sphinx.environment.Environment.config` attributes. For example,
    to get the value of :confval:`language`, use either ``app.config.language``
    or ``env.config.language``.
    t   projectt   Pythont   envt   authort   unknownt	   copyrightt    t   htmlt   versiont   releaset   todayt	   today_fmtt   languaget   locale_dirst   localest   figure_language_filenameu   {root}.{language}{ext}t
   master_doct   contentst   source_suffixt   restructuredtexts   .rstt   source_encodings	   utf-8-sigt   source_parserst   exclude_patternst   default_rolet   add_function_parenthesest   add_module_namest   trim_footnote_reference_spacet   show_authorst   pygments_stylet   highlight_languaget   defaultt   highlight_optionst   templates_patht   template_bridget   keep_warningst   suppress_warningst   modindex_common_prefixt
   rst_epilogt
   rst_prologt   trim_doctest_flagst   primary_domaint   pyt   needs_sphinxt   needs_extensionst   manpages_urlt   nitpickyt   nitpick_ignoret   numfigt   numfig_secnum_depthi   t   numfig_formatt   math_number_allt   math_eqref_formatt   math_numfigt
   tls_verifyt   tls_cacertst   smartquotest   smartquotes_actiont   qDet   smartquotes_excludest   jat	   languagest   mant   textt   buildersc         G   sk  t  |  d k rm t j d t d d | \ } } } } | d  k rO i  } q t t j | |  |  } nX t  |  d k r i  i  } } n6 t  |  d k r | d i  } } n | d  \ } } | |  _ t	 j
 j   |  _ | |  _ | j d d   |  _ d | k rRt | d t  r<| j d  j d	  | d <qR| j d  | d <n  | j d g   |  _ d  S(
   Ni   sf   The argument of Config() class has been changed. Use Config.read() to read configuration from conf.py.t
   stackleveli   i    i   t   setupt
   extensionst   ,(   t   lent   warningst   warnR   t   Nonet   eval_config_fileR   t   joint	   overridesR;   t   config_valuest   copyt   valuest   _raw_configt   getR}   R'   R	   t   popt   splitR~   (   R4   t   argst   dirnamet   filenameR   t   tagst   config(    (    s,   lib/python2.7/site-packages/sphinx/config.pyR5      s*    				c         C   s4   t  j | t  } t | |  } |  | | p0 i   S(   s/   Create a Config object from configuration file.(   R   R   t   CONFIG_FILENAMER   (   t   clst   confdirR   R   R   t	   namespace(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   read   s    c         C   s'   t  j d t d d t d  |   d  S(   NsF   Config.check_types() is deprecated. Use check_confval_types() instead.R|   i   (   R   R   R   t   check_confval_typesR   (   R4   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   check_types   s    	c         C   s$   t  j d t d d t |   d  S(   NsB   Config.check_unicode() is deprecated. Use check_unicode() instead.R|   i   (   R   R   R   t   check_unicode(   R4   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR      s    	c         C   s-  t  | t  s | S|  j | d } |  j | d t k r? | St  | t  rq t t d  | | d f   n t  | t  r | j d  St  | t	  r y t
 |  SWq)t k
 r t t d  | | f   q)XnL t | d  r | S| d  k	 r%t  | t  r%t t d  |   n | Sd  S(	   Ni    i   sZ   cannot override dictionary config setting %r, ignoring (use %r to set individual elements)s
   .key=valueR   s/   invalid number %r for config value %r, ignoringt   __call__sA   cannot override config setting %r with unsupported type, ignoring(   R'   R	   R   R   R*   t
   ValueErrorR   R+   R   R   t   intt   hasattrR   (   R4   R!   R"   t   defvalue(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   convert_overrides   s,    c         C   s   d d d d g } x | D] } y\ | |  j  k rT |  j | |  j  |  |  j | <n& | |  j k rz |  j | |  j | <n  Wq t k
 r } t j d |  q Xq Wd S(   sh   
        Initialize some limited config variables before initialize i18n and loading extensions
        Rf   R_   RH   RI   s   %sN(   R   R   t   __dict__R   R   t   loggert   warning(   R4   t	   variablesR!   t   exc(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   pre_init_values   s    #c         C   s(  |  j  } x t |  j  D] \ } } y d | k rh | j d d  \ } } | | j | i   | <w n+ | |  j k r t j t d  |  w n  t	 | t
  r |  j | |  | | <n
 | | | <Wq t k
 r } t j d |  q Xq Wx1 | D]) } | |  j k r | | |  j | <q q Wd  S(   Nt   .i   s-   unknown config value %r in override, ignorings   %s(   R   R   R   R   t
   setdefaultR   R   R   R   R'   R	   R   R   R   (   R4   R   t   valnameR"   t   realvalnameR1   R   R!   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   init_values  s&    	c         C   st   | j  d  r t |   n  | |  j k rF t t d  |   n  |  j | d } t | d  rp | |   S| S(   NR   s   No such config value: %si    R   (   t
   startswitht   AttributeErrorR   R   R   (   R4   R!   RZ   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __getattr__  s    
c         C   s   t  |  |  S(   N(   t   getattr(   R4   R!   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __getitem__'  s    c         C   s   t  |  | |  d  S(   N(   t   setattr(   R4   R!   R"   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __setitem__+  s    c         C   s   t  |  |  d  S(   N(   t   delattr(   R4   R!   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __delitem__/  s    c         C   s   | |  j  k S(   N(   R   (   R4   R!   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __contains__3  s    c         c   sB   x; t  |  j  D]* \ } } t | t |  |  | d  Vq Wd  S(   Ni   (   R   R   R    R   (   R4   R!   R"   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __iter__7  s    c         C   sB   | |  j  k r( t t d  |   n | | | f |  j  | <d  S(   Ns   Config value %r already present(   R   R   R   (   R4   R!   RZ   R#   t   types(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   add<  s    c            s/   t    t  r   g   n    f d   |  D S(   Nc         3   s$   |  ] } | j    k r | Vq d  S(   N(   R#   (   R%   R"   (   R#   (    s,   lib/python2.7/site-packages/sphinx/config.pys	   <genexpr>G  s    (   R'   R	   (   R4   R#   (    (   R#   s,   lib/python2.7/site-packages/sphinx/config.pyt   filterC  s    c         C   s   i  } xF t  |  j  D]5 \ } } | j d  sK t |  rA q | | | <q Wi  | d <x\ t  |  j  D]K \ } } t |  |  } t |  s d } n  | | d d f | d | <qi W| S(   s'   Obtains serializable data for pickling.R   R   i   N(   R   R   R   R$   R   R   R   (   R4   R   R1   R"   t
   real_value(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __getstate__I  s    
	c         C   s   |  j  j |  d  S(   N(   R   t   update(   R4   t   state(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   __setstate__a  s    N(   R8   R9   R:   R*   R   t   string_classest   strR   R/   R)   R   R   R5   t   classmethodR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR;   Z   s   
	!														c      	   C   s   i  } |  | d <| | d <t  t j |     y t |  |  Wn t k
 r } t d  } t rx | t d  7} n  t | |   n[ t k
 r t d  } t |   n3 t	 k
 r t d  } t | t
 j     n XWd QX| S(   s   Evaluate a config file.t   __file__R   s6   There is a syntax error in your configuration file: %ss+   
Did you change the syntax from 2.x to 3.x?sK   The configuration file (or one of the modules it imports) called sys.exit()s=   There is a programmable error in your configuration file:

%sN(   R   R   R   R   t   SyntaxErrorR   R   R   t
   SystemExitt	   Exceptiont	   tracebackt
   format_exc(   R   R   R   t   errt   msg(    (    s,   lib/python2.7/site-packages/sphinx/config.pyR   f  s$    

 c         C   s   | j  } t | t  r1 t i d | 6 | _  n{ t | t t f  rq t g  | D] } | d f ^ qP  | _  n; t | t  r t | j   | _  n t j	 t
 d |   d S(   s   This converts old styled source_suffix to new styled one.

    * old style: str or list
    * new style: a dict which maps from fileext to filetype
    sh   The config value `source_suffix' expected to a string, list of strings or dictionary. But `%r' is given.N(   RN   R'   R	   R    R   R+   R,   R*   R   R   R   (   t   appR   RN   t   s(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   convert_source_suffix  s    	+c         C   sW   i t  d  d 6t  d  d 6t  d  d 6t  d  d 6} | j | j  | | _ d	 S(
   s$   Initialize :confval:`numfig_format`.s
   Section %st   sections   Fig. %st   figures   Table %st   tables
   Listing %ss
   code-blockN(   R   R   Rm   (   R   R   Rm   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   init_numfig_format  s    c         C   sc   t  d  d k	 r_ xJ d D]? } | | k r d t d  } t j | | |  | | <q q Wn  d S(   s   correct values of copyright year that are not coherent with
    the SOURCE_DATE_EPOCH environment variable (if set)

    See https://reproducible-builds.org/specs/source-date-epoch/
    t   SOURCE_DATE_EPOCHRA   t   epub_copyrights   \g<1>%ss   %YN(   RA   R   (   R   R   R   t   copyright_year_ret   sub(   R   R   t   kt   replace(    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   correct_copyright_year  s
    c   	      C   s
  x| D]} | j  | j \ } } } t | d  rD | |  } n  | d
 k r] | r] q n  | t k rl q t | t  r | j | j  st	 d  } t
 j | j d | j d | j d | j   qq t | j  t |  k r q n  t | j  | k r	q n  t t | j  j t | j  f  t t |  j  @} | j t  | r]q n  | rt	 d  } t
 j | j d | j d t | j  d t g  | D] } | j ^ q   q t	 d  } t
 j | j d | j d t | j  d	 t |    q Wd
 S(   s   check all values for deviation from the default value's type, since
    that can result in TypeErrors all over the place NB.
    R   sT   The config value `{name}` has to be a one of {candidates}, but `{current}` is given.R!   t   currentR3   sQ   The config value `{name}' has type `{current.__name__}', expected to {permitted}.t	   permittedsZ   The config value `{name}' has type `{current.__name__}', defaults to `{default.__name__}'.RZ   N(   R   R!   R   R   R   R'   R2   R7   R"   R   R   R   t   formatR3   t   typeR-   t	   __bases__t   discardt   objectR   R8   (	   R   R   t   confvalRZ   R#   t   annotationsR   t   common_basest   c(    (    s,   lib/python2.7/site-packages/sphinx/config.pyR     s@    	%)c         C   sm   t  j d  } xW t |  j  D]F \ } } t | t  r | j |  r t j t	 d  | d  q q Wd S(   s   check all string values for non-ASCII characters in bytestrings,
    since that can result in UnicodeErrors all over the place
    s   [\x80-\xff]s   the config value %r is set to a string with non-ASCII characters; this can lead to Unicode errors occurring. Please use Unicode strings, e.g. %r.u   ContentN(
   t   ret   compileR   R   R'   R
   t   searchR   R   R   (   R   t   nonascii_reR!   R"   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR     s
    c         C   sY   |  j  d t  |  j  d t  |  j  d t  |  j  d t  i d d 6t d 6t d 6S(   Ns   config-initedt   builtinRD   t   parallel_read_safet   parallel_write_safe(   t   connectR   R   R   R   R/   (   R   (    (    s,   lib/python2.7/site-packages/sphinx/config.pyR}     s    (M   R:   R   R   R   R   t   collectionsR    t   osR   R   t   typingR   R   R   t   sixR   R   R   R	   R
   R   R   R   t   sphinx.deprecationR   t   sphinx.errorsR   R   t   sphinx.localeR   R   t   sphinx.utilR   t   sphinx.util.i18nR   t   sphinx.util.osutilR   t   sphinx.util.pycompatR   R   R)   R   R   R   R   R   R   t   sphinx.applicationR   t   sphinx.util.tagsR   t	   getLoggerR8   R   R   t
   ModuleTypet   FunctionTypeR(   R   R   R   t   unicodet   boolR    R$   R   R2   R   t   appendR;   R   R   R   R   R   R   R}   (    (    (    s,   lib/python2.7/site-packages/sphinx/config.pyt   <module>
   sT   ::				 					1	