
    dd<9                        d Z d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 ddlmZ i dd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)i d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdU	Z	 i Z	 dV ZdW ZdX ZdY ZdZ Zd[ Zd\ Zd] Zd^ Zg d_Zd` Zda ZdodbZdc Z ej>                  ddej@                        Z!de Z"df Z#dg Z$dh Z%di Z&dj Z'dk Z(dl Z)dm Z*dn Z+y)pz9
This package contains directive implementation modules.
reStructuredText    N)import_module)nodesparsers)split_escaped_whitespaceescape2null)en	attention)admonitions	Attentioncaution)r   Cautioncode)body	CodeBlockdanger)r   Dangererror)r   Error	important)r   	Importantnote)r   Notetip)r   Tiphint)r   Hintwarning)r   Warning
admonition)r   
Admonitionsidebar)r   Sidebartopic)r   Topicz
line-block)r   	LineBlockzparsed-literal)r   ParsedLiteralmath)r   	MathBlockrubric)r   Rubricepigraph)r   Epigraph
highlights)r   
Highlightsz
pull-quote)r   	PullQuotecompound)r   Compound	container)r   	Containertable)tablesRSTTablez	csv-table)r6   CSVTablez
list-table)r6   	ListTableimage)imagesImagefigure)r;   Figurecontents)partsContentssectnum)r@   Sectnumheader)r@   Headerfooter)r@   Footerztarget-notes)
referencesTargetNotesmeta)miscMetaraw)rK   Raw)rK   Include)rK   Replace)rK   Unicode)rK   Class)rK   Role)rK   DefaultRole)rK   Title)rK   Date)rK   TestDirective)	includereplaceunicodeclassrolezdefault-roletitledatezrestructuredtext-test-directivec                 B   | j                         }g }g }|t        v rt        |   |fS d}	 |j                  |   }|s(	 t        j                  |   }|j	                  d| z         |rG|j                  j                  d
j                  |      |j                        }|j	                  |       	 t        |   \  }	}
	 t        d|	z         }	 t!        ||
      }|t        |<   ||fS # t        $ r"}|j	                  d|d|d       Y d}~d}~wt
        $ r% |j	                  d| d|j                  d       Y w xY w# t
        $ r |j	                  d	| z         |}Y w xY w# t
        $ r d|fcY S w xY w# t        $ rM}|j	                  |j                  j                  d|	d| d||j                               d|fcY d}~S d}~ww xY w# t        $ rG |j	                  |j                  j                  d|
d|	d| d|j                               d|fcY S w xY w)z
    Locate and return a directive function from its language-dependent name.
    If not found in the current language, check English.  Return None if the
    named directive cannot be found.
    Nz8Problem retrieving directive entry from language module z: .zNo directive entry for "z" in module "z".z*Using English fallback for directive "%s".z(Trying "%s" as canonical directive name.
)linez docutils.parsers.rst.directives.z"Error importing directive module "z" (directive "z"):
zNo directive class "z").)lower_directives
directivesAttributeErrorappendKeyError__name___fallback_language_modulereporterinfojoincurrent_line_directive_registryr   ImportErrorr   getattr)directive_namelanguage_moduledocumentnormnamemessagesmsg_textcanonicalnamer   message
modulename	classnamemoduledetail	directives                 J/usr/lib/python3/dist-packages/docutils/parsers/rst/directives/__init__.pyr~   r~   M   s^    ##%HHH;8$h..MF'228< 	%5@@JMOOH,- . ##((IIhh&;&; ) =  3M B
IA*LMFI.	 )H hU  E,;UD 	E 	E F)?+C+CE 	FF  	%OOF,- . %M		%  X~
  ))//>63&& 0 ( 	) X~  ))//*n6&& 0 ( 	) X~sr   C# 'D= .E" ;E5 
G #	D:,D		.D:9D:=EE"E21E25	G>AG GGAHHc                     |t         | <   y)z
    Register a nonstandard application-defined directive function.
    Language lookups are not needed for such functions.
    N)rd   )namer~   s     r   register_directiver      s    
 "K    c                 D    | r| j                         rt        d| z        y)z
    Check for a valid flag option (no argument) and return ``None``.
    (Directive option conversion function.)

    Raise ``ValueError`` if an argument is found.
    z%no argument is allowed; "%s" suppliedN)strip
ValueErrorarguments    r   flagr      s$     HNN$@8KLLr   c                      | t        d      | S )z
    Return the argument text, unchanged.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    #argument required but none supplied)r   r   s    r   unchanged_requiredr      s     >??r   c                     | y| S )z
    Return the argument text, unchanged.
    (Directive option conversion function.)

    No argument implies empty string ("").
      r   s    r   	unchangedr      s     r   c                 h    | t        d      dj                  d | j                         D              S )z
    Return the path argument unwrapped (with newlines removed).
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    r   r   c              3   <   K   | ]  }|j                           y wN)r   .0ss     r   	<genexpr>zpath.<locals>.<genexpr>   s     @Qqwwy@s   )r   rm   
splitlinesr   s    r   pathr      s4     >??ww@(*=*=*?@@@r   c                 t    | t        d      t        t        |             }dj                  d |D              S )z
    Return the URI argument with unescaped whitespace removed.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    r    c              3      K   | ]6  }d j                  t        j                  |      j                                8 yw)r   N)rm   r   unescapesplit)r   parts     r   r   zuri.<locals>.<genexpr>   s3      +  t 4 : : <= +s   <>)r   r   r   rm   )r   r@   s     r   urir      sC     >??(X)>?xx +$)+ + 	+r   c                 <    t        |       }|dk  rt        d      |S )z|
    Check for a nonnegative integer argument; raise ``ValueError`` if not.
    (Directive option conversion function.)
    r   z(negative value; must be positive or zerointr   r   values     r   nonnegative_intr      %    
 MEqyCDDLr   c                 n    	 | j                  d      } t        |       S # t        $ r Y t        |       S w xY w)zw
    Check for an integer percentage value with optional percent sign.
    (Directive option conversion function.)
    z %)rstriprf   r   r   s    r   
percentager      sA    
??4( 8$$  8$$s    	44)emexpxincmmmptpcc                 <   t        j                  ddj                  |      z  |       }	 t        |j	                  d             |j	                  d      |j	                  d      z   S # t
        t        f$ r% t        ddj                  d |D              z        w xY w)a  
    Check for a positive argument of one of the units and return a
    normalized string of the form "<value><unit>" (without space in
    between).
    (Directive option conversion function.)

    To be called from directive option conversion functions.
    z^([0-9.]+) *(%s)$|   z8not a positive measure of one of the following units:
%sr   c              3   &   K   | ]	  }d |z    ywz"%s"Nr   )r   is     r   r   zget_measure.<locals>.<genexpr>   s     1avz1      )rematchrm   floatgrouprf   r   )r   unitsr   s      r   get_measurer      s     HH)CHHUO;XFE3ekk!n
 ;;q>EKKN**	 J' 3Ghh151123 	33s   A' '4Bc                 *    t        | t        dgz         S )Nr   )r   length_unitsr   s    r   length_or_unitlessr      s    x!455r   c                     	 t        | t        dgz         S # t        $ r9 	 t        | dg      |z   cY S # t        $ r t        | t        dgz         cY cY S w xY ww xY w)a  
    Return normalized string of a length or percentage unit.
    (Directive option conversion function.)

    Add <default> if there is no unit. Raise ValueError if the argument is not
    a positive measure of one of the valid CSS units (or without unit).

    >>> length_or_percentage_or_unitless('3 pt')
    '3pt'
    >>> length_or_percentage_or_unitless('3%', 'em')
    '3%'
    >>> length_or_percentage_or_unitless('3')
    '3'
    >>> length_or_percentage_or_unitless('3', 'px')
    '3px'
    %r   )r   r   r   )r   defaults     r    length_or_percentage_or_unitlessr     sf    "?8\SE%9:: ?	?x".88 	?x)=>>	??s)    	A2AAAAAc                     | t        d      | j                         }g }|D ]8  }t        j                  |      }|st        d|z        |j	                  |       : |S )z
    Convert the argument into a list of ID-compatible strings and return it.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    r   z"cannot make "%s" into a class name)r   r   r   make_idrg   )r   namesclass_namesr   
class_names        r   class_optionr     sn     >??NNEK ']]4(
ADHII:&	'
 r   z2(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$c                 .   	 | j                         rt        t        |             S t        j	                  |       }|r9|j                  d      xs |j                  d      }t        t        |d            S | S # t        $ r}t        d|z        d}~ww xY w)a  
    Convert a Unicode character code to a Unicode character.
    (Directive option conversion function.)

    Codes may be decimal numbers, hexadecimal numbers (prefixed by ``0x``,
    ``x``, ``\x``, ``U+``, ``u``, or ``\u``; e.g. ``U+262E``), or XML-style
    numeric character entities (e.g. ``&#x262E;``).  Other text remains as-is.

    Raise ValueError for illegal Unicode code values.
    r   r      zcode too large (%s)N)isdigitchrr   unicode_patternr   r   OverflowErrorr   )r   r   r   r}   s       r   unicode_coder   6  s    9<<>s4y>!#))$/EA8%++a.3ub>** 9.7889s#   #A8 AA8 6A8 8	BBBc                 T    t        |       }t        |      dkD  rt        d|z        |S )z
    A single character is returned as-is.  Unicode character codes are
    converted as in `unicode_code`.  (Directive option conversion function.)
    r   z8%r invalid; must be a single character or a Unicode code)r   lenr   r   chars     r   single_char_or_unicoder   O  s8    
 !D
4y1} *,01 2 	2Kr   c                 @    | dk(  rd}|S | dk(  rd}|S t        |       }|S )z
    As with `single_char_or_unicode`, but "tab" and "space" are also supported.
    (Directive option conversion function.)
    tab	spacer   )r   r   s     r   $single_char_or_whitespace_or_unicoder   [  s?    
 5
 K	 
W	 K &h/Kr   c                 <    t        |       }|dk  rt        d      |S )z
    Converts the argument into an integer.  Raises ValueError for negative,
    zero, or non-integer values.  (Directive option conversion function.)
    r   z(negative or zero value; must be positiver   r   s     r   positive_intr   i  r   r   c                     d| v r| j                  d      }n| j                         }|D cg c]  }t        |       c}S c c}w )z
    Converts a space- or comma-separated list of values into a Python list
    of integers.
    (Directive option conversion function.)

    Raises ValueError for non-positive-integer values.
    ,)r   r   )r   entriesentrys      r   positive_int_listr   t  s>     h..%.."-45EL555s   A c                 h    	 t        j                  |        | S # t        $ r t        d| z        w xY w)z
    Verifies the encoding argument by lookup.
    (Directive option conversion function.)

    Raises ValueError for unknown encodings.
    zunknown encoding: "%s")codecslookupLookupErrorr   r   s    r   encodingr     s<    >h O  >1H<==>s    1c                     	 | j                         j                         }||v r|S t        d| dt	        |            # t        $ r t        dt	        |      z        w xY w)a  
    Directive option utility function, supplied to enable options whose
    argument must be a member of a finite set of possible values (must be
    lower case).  A custom conversion function must be written to use it.  For
    example::

        from docutils.parsers.rst import directives

        def yesno(argument):
            return directives.choice(argument, ('yes', 'no'))

    Raise ``ValueError`` if no argument is found or if the argument's value is
    not valid (not an entry in the supplied list).
    z'must supply an argument; choose from %s"z" unknown; choose from )rc   r   rf   r   format_values)r   valuesr   s      r   choicer     st    2 &&( $mF&;= > 	>  2B(01 2 	22s   A   !A!c                 J    dj                  d | d d D              d| d   dS )Nz, c              3   &   K   | ]	  }d |z    ywr   r   r   s     r   r   z format_values.<locals>.<genexpr>  s     %FQfqj%Fr   z, or "r   )rm   )r   s    r   r   r     s+     II%F&"+%FF"2J( (r   c                       fd}|S )zl
    Directive option conversion function.

    The argument can be any of `values` or `argument_type`.
    c                      | v r| S  |       S r   r   )r   otherr   s    r   auto_or_otherzvalue_or.<locals>.auto_or_other  s    vO?"r   r   )r   r   r   s   `` r   value_orr     s    #
 r   c                 ~    | sy	 t        j                  |       S # t        $ r}t        t	        |            d}~ww xY w)z
    Return a docutils parser whose name matches the argument.
    (Directive option conversion function.)

    Return `None`, if the argument evaluates to `False`.
    Raise `ValueError` if importing the parser module fails.
    N)r   get_parser_classrp   r   str)r   errs     r   parser_namer     s?     #''11 #S""#s    	<7<)r   ),__doc____docformat__r   r   	importlibr   docutilsr   r   docutils.utilsr   r   docutils.parsers.rst.languagesr	   rj   ro   rd   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   compile
IGNORECASEr   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     s  
 # 	  # # @ J0/0+0 #0 )	0
 '0 /0 %0 #0 %0 +0 10 $0  0 )0 10  #!0" "#0$ &%0& *'0( ))0* &+0, (-00 %102 )304 +506 "708 $90: ';0< %=0> #?0@ #A0F 3G0H I0L _M0N %$$ - )B_0 b5  #8v"



A+	% @+&6?6& "**92==J92	6>6(
#r   