o
    Ni9                     @   s  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	 dVdW ZdXdY ZdZd[ Zd\d] Zd^d_ Zd`da Zdbdc Zddde Zdfdg Zg dhZdidj Zdkdl ZddndoZdpdq Zedrej Z!dsdt Z"dudv Z#dwdx Z$dydz Z%d{d| Z&d}d~ Z'dd Z(dd Z)dd Z*dd Z+dS )z9
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)r5   CSVTablez
list-table)r5   	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)rJ   Raw)rJ   Include)rJ   Replace)rJ   Unicode)rJ   Class)rJ   Role)rJ   DefaultRole)rJ   Title)rJ   Date)rJ   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|   \/home/ubuntu/.local/lib/python3.10/site-packages/docutils/parsers/rst/directives/__init__.pyr{   M   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)ra   )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    | ]}|  V  qd S N)r   .0sr|   r|   r}   	<genexpr>       zpath.<locals>.<genexpr>)r   rj   
splitlinesr   r|   r|   r}   path   s   r   c                 C   s0   | 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)rj   r   unescapesplit)r   partr|   r|   r}   r      s    zuri.<locals>.<genexpr>)r   r   r   rj   )r   r?   r|   r|   r}   uri   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 %)rstriprc   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       | ]}d | V  qdS z"%s"Nr|   )r   ir|   r|   r}   r     r   zget_measure.<locals>.<genexpr>   )rematchrj   floatgrouprc   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_idrd   )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chrr   unicode_patternr   r   OverflowErrorr   )r   r   r   rz   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 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   charr|   r|   r}   single_char_or_unicodeU  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_unicodea  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_into  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}   
<listcomp>  s    z%positive_int_list.<locals>.<listcomp>)r   )r   entriesr|   r|   r}   positive_int_listz  s   r   c                 C   s,   zt |  W | S  ty   td|  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   r|   r|   r}   encoding  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)r`   r   rc   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>.<genexpr>)rj   )r   r|   r|   r}   r     s   r   c                    s    fdd}|S )zl
    Directive option conversion function.

    The argument can be any of `values` or `argument_type`.
    c                    s   | v r| S  | S r   r|   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   s:   | sdS zt | W S  ty } ztt|d}~w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_classrm   r   str)r   errr|   r|   r}   parser_name  s   r   )r   ),__doc____docformat__r   r   	importlibr   docutilsr   r   docutils.utilsr   r   docutils.parsers.rst.languagesr   rg   rl   ra   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   	
 #$&'1;
