o
    °-$`W9  ã                   @   s2  d Z d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 ejdkr5e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/d0“d1d2“d3d4“d5d6“d7d8“d9d:“d;d<“d=d>“d?d@“dAdB“dCdD“dEdF“dGdH“dIdJ“dKdL“¥dMdNdOdPdQdRdSdTdUdVœ	¥Z	 i Z	 dWdX„ ZdYdZ„ Zd[d\„ Zd]d^„ Zd_d`„ Zdadb„ Zdcdd„ Zdedf„ Zdgdh„ Zg di¢Zdjdk„ Z dldm„ Z!dˆdodp„Z"dqdr„ Z#e $dsej%¡Z&dtdu„ Z'dvdw„ Z(dxdy„ Z)dzd{„ Z*d|d}„ Z+d~d„ Z,d€d�„ Z-d‚dƒ„ Z.d„d…„ Z/d†d‡„ Z0dS )‰z9
This package contains directive implementation modules.
ÚreStructuredTexté    N)Úimport_module)ÚnodesÚparsers)Úsplit_escaped_whitespaceÚescape2nullÚunescape)Úen)é   r   Ú	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)r7   ÚCSVTablez
list-table)r7   Ú	ListTableÚimage)ÚimagesÚImageÚfigure)r<   ÚFigureÚcontents)ÚpartsÚContentsÚsectnum)rA   ÚSectnumÚheader)rA   ÚHeaderÚfooter)rA   ÚFooterztarget-notes)Ú
referencesÚTargetNotesÚmeta)ÚhtmlÚMetaÚraw)ÚmiscÚRaw)rO   ÚInclude)rO   ÚReplace)rO   ÚUnicode)rO   ÚClass)rO   ÚRole)rO   ÚDefaultRole)rO   ÚTitle)rO   ÚDate)rO   ÚTestDirective)	ÚincludeÚreplaceÚunicodeÚclassÚrolezdefault-roleÚtitleÚdatezrestructuredtext-test-directivec              
   C   sä  |   ¡ }g }g }|tv rt| |fS d}z|j| }W n- ty6 } z| d||f ¡ W Y d}~nd}~w tyH   | d| |jf ¡ Y nw |slztj| }| d|  ¡ W n tyk   | d|  ¡ |}Y nw |r|jj	d 
|¡|jd�}| |¡ zt| \}	}
W n ty”   d|f Y S w ztd|	 ƒ}W n' tyÄ } z| |jjd	|	| |f |jd�¡ d|fW  Y d}~S d}~ww zt||
ƒ}|t|< W ||fS  tyñ   | |jjd
|
|	| f |jd�¡ d|f Y S 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.
    Nz?Problem retrieving directive entry from language module %r: %s.z+No directive entry for "%s" in module "%s".z*Using English fallback for directive "%s".z(Trying "%s" as canonical directive name.Ú
)Úlinez docutils.parsers.rst.directives.z:Error importing directive module "%s" (directive "%s"):
%sz8No directive class "%s" in module "%s" (directive "%s").)Ú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Ú	directive© r   úJ/usr/lib/python3/dist-packages/docutils/parsers/rst/directives/__init__.pyr~   O   s‚   ÿ€
ÿÿ

ÿÿüÿ
þ
ÿý€û

ú
ÿýûr~   c                 C   s   |t | < dS )z€
    Register a nonstandard application-defined directive function.
    Language lookups are not needed for such functions.
    N)rd   )Únamer~   r   r   r€   Úregister_directive‰   s   r‚   c                 C   s   | r|   ¡ rtd|  ƒ‚dS )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©Úargumentr   r   r€   Úflag�   s   r‡   c                 C   s   | du rt dƒ‚| S )z�
    Return the argument text, unchanged.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    Nú#argument required but none supplied)r„   r…   r   r   r€   Úunchanged_requiredœ   s   r‰   c                 C   s   | du rdS | S )z†
    Return the argument text, unchanged.
    (Directive option conversion function.)

    No argument implies empty string ("").
    NÚ r   r…   r   r   r€   Ú	unchanged¨   s   r‹   c                 C   s,   | du rt dƒ‚d dd„ |  ¡ D ƒ¡}|S )z¤
    Return the path argument unwrapped (with newlines removed).
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    Nrˆ   rŠ   c                 S   s   g | ]}|  ¡ ‘qS r   )rƒ   ©Ú.0Úsr   r   r€   Ú
<listcomp>¾   ó    zpath.<locals>.<listcomp>)r„   rm   Ú
splitlines)r†   Úpathr   r   r€   r’   ´   s   r’   c                 C   s4   | du rt dƒ‚tt| ƒƒ}d dd„ |D ƒ¡}|S )z£
    Return the URI argument with unescaped whitespace removed.
    (Directive option conversion function.)

    Raise ``ValueError`` if no argument is found.
    Nrˆ   ú c                 s   s"   � | ]}d   t|ƒ ¡ ¡V  qdS )rŠ   N)rm   r   Úsplit)r�   Úpartr   r   r€   Ú	<genexpr>Ì   s   €  zuri.<locals>.<genexpr>)r„   r   r   rm   )r†   rA   Úurir   r   r€   r—   Á   s
   r—   c                 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†   Úvaluer   r   r€   Únonnegative_intÏ   ó   r�   c                 C   s.   z
|   d¡} W t| ƒS  ty   Y t| ƒS w )zw
    Check for an integer percentage value with optional percent sign.
    (Directive option conversion function.)
    z %)Úrstriprf   r�   r…   r   r   r€   Ú
percentageÙ   s   þþr    )ÚemÚexÚpxÚinÚcmÚmmÚptÚpcc              	   C   sl   t  dd |¡ | ¡}z	t| d¡ƒ W n ttfy+   tdd dd„ |D ƒ¡ ƒ‚w | d¡| d¡ S )	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                 S   ó   g | ]}d | ‘qS ©z"%s"r   )r�   Úir   r   r€   r�   õ   r�   zget_measure.<locals>.<listcomp>é   )ÚreÚmatchrm   ÚfloatÚgrouprf   r„   )r†   Úunitsr°   r   r   r€   Úget_measureæ   s   	ÿÿÿr´   c                 C   s   t | tdg ƒS )NrŠ   )r´   Úlength_unitsr…   r   r   r€   Úlength_or_unitlessø   s   r¶   rŠ   c                 C   s`   z	t | tdg ƒW S  ty/   zt | dgƒ| W  Y S  ty.   t | tdg ƒ Y  Y S w 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†   Údefaultr   r   r€   Ú length_or_percentage_or_unitlessû   s   þýr¹   c                 C   sN   | du rt dƒ‚|  ¡ }g }|D ]}t |¡}|st d| ƒ‚| |¡ q|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.
    Nrˆ   z"cannot make "%s" into a class name)r„   r”   r   Úmake_idrg   )r†   ÚnamesÚclass_namesr�   Ú
class_namer   r   r€   Úclass_option  s   
r¾   z2(?:0x|x|\\x|U\+?|\\u)([0-9a-f]+)$|&#x([0-9a-f]+);$c              
   C   st   z'|   ¡ rtt| ƒƒW S t | ¡}|r%| d¡p| d¡}tt|dƒƒW S | W S  ty9 } ztd| ƒ‚d}~w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Úunichrrš   Úunicode_patternr°   r²   ÚOverflowErrorr„   )r   r°   rœ   r}   r   r   r€   Úunicode_code*  s   
€ÿrÄ   c                 C   s$   t | ƒ}t|ƒdkrtd| ƒ‚|S )zš
    A single character is returned as-is.  Unicode characters 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†   Úcharr   r   r€   Úsingle_char_or_unicodeB  s   ÿrÈ   c                 C   s,   | 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Æ   r   r   r€   Ú$single_char_or_whitespace_or_unicodeM  s   üÿrÌ   c                 C   r˜   )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›   r   r   r€   Úpositive_intZ  rž   rÍ   c                 C   s*   d| v r
|   d¡}n|   ¡ }dd„ |D ƒS )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.
    ú,c                 S   s   g | ]}t |ƒ‘qS r   )rÍ   )r�   Úentryr   r   r€   r�   p  r�   z%positive_int_list.<locals>.<listcomp>)r”   )r†   Úentriesr   r   r€   Úpositive_int_listd  s   rÑ   c                 C   s,   zt  | ¡ W | S  ty   td|  ƒ‚w )zŒ
    Verfies the encoding argument by lookup.
    (Directive option conversion function.)

    Raises ValueError for unknown encodings.
    zunknown encoding: "%s")ÚcodecsÚlookupÚLookupErrorr„   r…   r   r   r€   Úencodingr  s   þÿrÕ   c                 C   sP   z|   ¡  ¡ }W n ty   tdt|ƒ ƒ‚w ||v r|S td| t|ƒf ƒ‚)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 %sz"%s" unknown; choose from %s)rc   rƒ   rf   r„   Úformat_values)r†   Úvaluesrœ   r   r   r€   Úchoice  s   ÿÿ
ÿrØ   c                 C   s(   dd  dd„ | d d… D ƒ¡| d f S )Nz%s, or "%s"z, c                 S   r«   r¬   r   rŒ   r   r   r€   r�   š  r�   z!format_values.<locals>.<listcomp>éÿÿÿÿ)rm   )r×   r   r   r€   rÖ   ™  s   ÿrÖ   c                    s   ‡ ‡fdd„}|S )zp
    Directive option conversion function.
    
    The argument can be any of `values` or `argument_type`.
    c                    s   | ˆv r| S ˆ | ƒS )Nr   r…   ©Úotherr×   r   r€   Úauto_or_other£  s   zvalue_or.<locals>.auto_or_otherr   )r×   rÛ   rÜ   r   rÚ   r€   Úvalue_or�  s   rÝ   c                 C   s0   | sdS zt  | ¡W S  ty   td|  ƒ‚w )z©
    Return a docutils parser whose name matches the argument.
    (Directive option conversion function.)

    Return `None`, if the argument evaluates to `False`.
    NzUnknown parser name "%s".)r   Úget_parser_classrp   r„   r…   r   r   r€   Úparser_nameª  s   ÿrß   )rŠ   )1Ú__doc__Ú__docformat__r¯   rÒ   ÚsysÚ	importlibr   Údocutilsr   r   Údocutils.utilsr   r   r   Údocutils.parsers.rst.languagesr	   rj   Úversion_infoÚchrrÁ   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   r€   Ú<module>   sð   
ÿþýüûúùø	÷
öõôóòñðïîíìëêèçæåäãâá à#Ý$Ü&Ú'Ñ0:

ÿ
