https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/minirst.cpython-310.pyc
o

�]Lb�t�
@s�dZddlmZddlZddlmZddlmZmZm	Z	ddl
mZdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�Ze�d�Zdd�Zdd�Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�Zdd�Zd Zd!d"�Zd#d$�Zd%d&�Ze�d'�Z d(d)�Z!d*d+�Z"d,d-�Z#d.d/�Z$d0d1�Z%d2d3�Z&dWd4d5�Z'ed6�ed7�ed8�ed9�ed:�ed;�ed<�ed=�ed>�d?�	Z(d@dA�Z)dBdC�Z*dDdE�Z+dXdFdG�Z,dHdI�Z-dJdK�Z.dYdNdO�Z/dPdQ�Z0dRdS�Z1dZdUdV�Z2dS)[a�simplified reStructuredText parser.

This parser knows just enough about reStructuredText to parse the
Mercurial docstrings.

It cheats in a major way: nested blocks are not really nested. They
are just indented blocks that look like they are nested. This relies
on the user to keep the right indentation for the blocks.

Remember to update https://mercurial-scm.org/wiki/HelpStyleGuide
when adding support for new constructs.
�)�absolute_importN�)�_)�encoding�pycompat�url)�
stringutilcC�d|dt�|�fS)N�%s
%s

�"�r�colwidth��s�r�3/usr/lib/python3/dist-packages/mercurial/minirst.py�section"�rcCr	)Nr
�=rrrrr�
subsection&rrcCr	)Nr
�-rrrrr�
subsubsection*rrcCr	)Nr
�.rrrrr�subsubsubsection.rrcCr	)Nr
�'rrrrr�subsubsubsubsection2rrcCsJ|�t�tj��}|D]\}}|�|�d�|�d��}q|�t�tj��S)aB
    Apply a list of (find, replace) pairs to a text.

    >>> replace(b"foo bar", [(b'f', b'F'), (b'b', b'B')])
    'Foo Bar'
    >>> encoding.encoding = b'latin1'
    >>> replace(b'\x81\\', [(b'\\', b'/')])
    '\x81/'
    >>> encoding.encoding = b'shiftjis'
    >>> replace(b'\x81\\', [(b'\\', b'/')])
    '\x81\\'
    �ascii)�decoder�sysstrr�replace�encode)�text�substs�utext�f�trrrr6srs\n(?:\s*\n)+csbg}t�|�d����D]"}|��}|r.tdd�|D����fdd�|D�}|��|d��q|S)z�Find continuous blocks of lines in text.

    Returns a list of dictionaries representing the blocks. Each block
    has an 'indent' field and a 'lines' field.
    �
css$�|]
}t|�t|���VqdS�N)�len�lstrip��.0�lrrr�	<genexpr>[s�"zfindblocks.<locals>.<genexpr>csg|]}|�d��qSr'rr*��indentrr�
<listcomp>\szfindblocks.<locals>.<listcomp>)�indent�lines)�_blockre�splitr)�rstrip�
splitlines�min�append)r!�blocks�b�linesrr.r�
findblocksQs�r<cCs�d}|t|�kr�d||d<||dd�d�r�|dt|�kr�||d}||dd|}||ddgkrB||=|d8}n[||dd�d	�r`||ddd
d�||dd<n=t||d�dkr�||dd�d��d
�r�||dd�dd�dkr�|d7}q||ddd
d�||dd<t�||dd�}|r�||��7}||��8}|dt|�kr�||dd|kr�d||dd<||dd|8<|d7}|dt|�kr�||dd|ks�|d7}|t|�ks|S)z�Finds literal blocks and adds a 'type' field to the blocks.

    Literal blocks are given the type 'literal', all other blocks are
    given type the 'paragraph'.
    r�	paragraph�typer2���s::rr1s ::N���� �.. ��literal)r(�endswithr)�
startswith�find�	_bulletre�match�end)r9�ir/�
adjustment�mrrr�findliteralblocksas<
&
&�$$$��2rNs+(\*|-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) s0^(-([a-zA-Z0-9]), )?(--[a-z0-9-]+)((.*)  +)(.*)$s&:(?![: ])((?:\:|[^:])*)(?<! ):[ ]+(.*)s[^ ]s
(=+\s+)*=+cCs�dtdfdtdfdtdfdtdfg}dd�}d	}|t|�krw||d
dkrm||d}|D]>\}}}||d	||�rlg}t|�D]!\}	}
|||	||�rX|�|g||d
d��|dd�|
�q@||||d�<nq.|d7}|t|�ks|S)zSplit paragraphs into lists.�bulletT�option�field�
definitionFcSsf||}|dt|�kr||dpd}|�|�sdS|r.|dkp-|dd�dkp-|�|�S|�d�S)z�Does itemre match an item at line i?

        A list item can be followed by an indented line or another list
        item (but only if singleline is True).
        r�FrrA)r(rIrF)r;rK�itemre�
singleline�line1�line2rrrrI�s 
"
zsplitparagraphs.<locals>.matchrr>r=r2r1)r>r2r1r?r)rH�	_optionre�_fieldre�
_definitionrer(�	enumerater8)r9�	listtypesrIrKr;�typerTrU�items�j�linerrr�splitparagraphs�s8�
����ra�cCs�d}|t|�krd||ddkr|d7}q|}|t|�krZ||ddkrZt�||dd�}|��\}}|||dd<|�dd�||d<|d7}|t|�krZ||ddks%|d}|t|�ks|S)	zFind key for field lists.rr>rQrr2s\:�:�key)r(rYrI�groupsr)r9rKr_rM�key�restrrr�updatefieldlists�s ��rhc
Cs\d}|t|�kr�||ddkr|d7}qd}|}|t|�kr�||ddkr�t�||dd�}|�d�}|�d�}|dd���}|�d���}|�d	���}	|||dd<d
}
|s`d}
d|rgd
|phd
d|
||	ff}|��}|||d<t|t�|��}|d7}|t|�kr�||ddks'|||�D]}||d<q�|d}|t|�ks|S)Nrr>rPrr2�rC��rS�   s%s%ss-%s s	%s--%s %s�optstr�optstrwidth)	r(rXrI�group�stripr5�maxrr
)
r9rK�optstrwidthr_rM�shortoption�group3�
longoption�desc�
longoptionarg�	noshortop�opt�blockrrr�updateoptionlists�s@

��
�!r{c
Cs6g}d}|dt|�kr�||ddkr�||dd�d�r�||d}||dd|}||dddd	�}d
}|D]}||�d�vrJd}q?|rR|�|�||=|}	|d8}|	t|�kr�||	d|kr�|ro||	=n||	d|8<|	d7}	|	t|�kr�||	d|ksi|d7}|dt|�ks||fS)
z�Prune unwanted containers.

    The blocks must have a 'type' field, i.e., they should have been
    run through findliteralblocks first.
    rrr>r=r2s.. container::r1�NTrF)r(rFr4r8)
r9�keep�prunedrKr/rL�
containertype�prune�cr_rrr�prunecontainerss<���
�� r�s^([-=`:.'"~^_*+#])\1+$csH|D]�}|ddkr�t|d�dkr�t�|dd�r�|dd|ddkr�d|d<d|d	<|dd��fd
d�t�t���D�}g}|ddd�D]O}|�krXd
|d	<qMg}|d}t|�D]4\}}|dt|�kr�||d|}	t�|||	�}
|t|
�7}|�|
�	��qb|�||d��	��qb|�|�qM||d<q|S)zNFind simple tables

    Only simple one-line table elements are supported
    r>r=r2rirr?�tableF�headercs@g|]}�||d�dkr|dks�|d|�dkr|�qS)rrrrAr)r+�x��divrrr0_s
0�zfindtables.<locals>.<listcomp>rTN)
r(�_tablererIr�xranger[r�getcolsr8rp)r9rz�columns�rowsr,�row�pos�n�start�width�vrr�r�
findtablesDs<
�
��r�cCs�|D]?}|ddkrAt|d�dkrAt�|dd�t|dd�krAt�|dd�rA|dddd�|d<d|d<|dd=q|S)	z�Finds sections.

    The blocks must have a 'type' field, i.e., they should have been
    run through findliteralblocks first.
    r>r=r2rirr�	underline�section)r(rr
�
_sectionrerI)r9rzrrr�findsections|s"�
�r�cs:dg�|D]}|ddvr�fdd�|dD�|d<q|S)N)s``rr>�r=r�c�g|]}t|���qSr�rr*�r"rrr0��z"inlineliterals.<locals>.<listcomp>r2r�r9r:rr�r�inlineliterals�s�r�cs<ddg�|D]}|ddvr�fdd�|dD�|d<q|S)N)s:hg:`s'hg )�`rr>r�cr�rr�r*r�rrr0�r�zhgrole.<locals>.<listcomp>r2rr�rr�r�hgrole�s�r�cCs�d}|t|�krE||d||ddkr#||ddvr#|d7}n||dds0|d7}n|�|dgddd��|d	7}|t|�ks|S)
z�Adds empty blocks for vertical spacing.

    This groups bullets, options, and definitions together with no vertical
    space between them, and adds an empty block between all other blocks.
    rr>)rOrPrQr2rSr�margin)r2r1r>ri)r(�insert)r9rKrrr�
addmargins�s "��

��r�cCs�d}|t|�krA||}|ddkr7|dd�d�s"|ddgkr7||=|t|�kr6||ddkr6||=n|d7}|t|�ks|S)	zRemove comments.rr>r=r2rBs..r�r)r(rF)r9rKr:rrr�
prunecomments�s���
r�cCs�|pt��}tjdd�t|��tjd�}d}|t|�krw|�||dd�}|rmd||d<||ddd|�	�d	��
�}||dd|�	�d
d�}|r`||d�d
d|�|||d
<||dd=|d
}|t|�ks|S)zj
    Makes the type of the block an admonition block if
    the first line is an admonition directive
    s\.\. (%s)::�|)�flagsrr2�
admonitionr>rCrirNrl�admonitiontitle)�_admonitiontitles�keys�re�compile�join�sorted�
IGNORECASEr(rIrJ�lowerr�)r9�admonitions�admonitionrerKrM�admonitiontitle�	firstlinerrr�findadmonitions�s$�$ �
r�s
Attention:sCaution:s!Danger!sError:sHint:s
Important:sNote:sTip:sWarning!)	s	attentionscautionsdangerserrorshints	importantsnotestipswarningcCstd�ttj|d��}t�|d�}|d}|d}d|dd||f}dt�|�d}dtj||||d�S)	NrAr2rmrrns%s%s  s %s
)�
initindent�
hangindent)r��map�bytesrprr
r�wrap)rzr�rvr
�usablewidth�hangingr�r�rrr�formatoption�s��r�cCs�|dkrd}d|d}|ddkrTt|d}|ds"||d	St|dd
�t|dd
���}||d}d�ttj|d��}d||tj||||d�fS|dd
kr\d	S|ddkrs|d7}|d	|�|d�d	S|ddkr�t	�
|dd�|d}d||dd||fS|ddk�r|d}dd�t|�D�}	d}t|	�t|	�d}
d|d}dt|�|
|	d
}|D]J}g}t|	|�D]\}
}d|
t	�
|�}|�
||�q�d�|�}tj||||d�}|�s
|d�r
|d	|dt||
�d	}q�||d	7}q�|S|ddk�rV||dd}t|dd
�t|dd
���}||d}d�ttj|ddd���}d|tj||||d�fS|}|ddk�r�|dd�d��rx|dddd�|dd<nPt�|dd�}||��d}n>|ddk�r�|d }|td}t|�dtk�r�|�|�}n|�t�}||dd|dd<n|dd!k�r�t||�Sd�ttj|d��}tj||||d�d	S)"z"Format a block according to width.r�NrAr1r>r�r�r2r&r?s%s
%s
)r�r�r�r�rDs  r�r�s
%s%s
%s%s
r�cS�g|]}tdd�|D���qS)cSsg|]}t�|��qSrr�r+�errrr0)r�z*formatblock.<locals>.<listcomp>.<listcomp>�rq�r+r�rrrr0)�zformatblock.<locals>.<listcomp>rSrr�rrRNrOs| rirQrdrP)r�r(r)r�r�r�rprr�rr
�zip�sumr8r7rFrHrIrJ�_fieldwidth�ljustr�)rzr�r/�
admonition�hang�	defindentr!�	underline�table�widths�spanr�r,�wr��pad�term�	subindentrMrfrrr�formatblocks�$��
� $��

���r�cs�g�d}g�dd�}��fdd�}dd�|D�}t|�D�]�\}}|d}|d	}|d
}|dkrO|t|d�}	|d
�ttj|���}
��d|	|
f��n6|dkra��d|d�|����n$|dkrg�n|dkry��d|d�|����n|dkr�|d}||vr�||7}|�|�d}��d|||d�|f�n�|dkr�|d}��d�|D]+}
��d�|
D]}��d���||����d���d�q������d�q���d �n�|d!k�r	|d"|�||d�}|d
�ttj|dd#����}
��d$||
f�n||d%k�r<|d�	d
d�\}}|d&v�r#|d'|�n|d(|���d)|d
�|g|dd#����nI|d*k�ra|d"|�||d+�}|d
�ttj|���}
��d$||
f�n$|d,k�r�|d"|�||d-�}|d
�ttj|���}��d$||f���rɈd.\}}|t
|�dk�r���d/|����q||d}|d	}||k�s�||k�r�|dd0v�rɈ�d/|����qd���S)1zFormat RST blocks as HTMLrScSst�|d�S)NT)r�escaperrrrr�nszformathtml.<locals>.escapecs8�r
�dd|kr��||f���d|�dSdS)Nr?rs<%s>
)r8)r��level��listnest�outrr�openlistqs�zformathtml.<locals>.openlistcSsg|]
}|ddkr|�qS)r>r�r�r+r:rrrr0v�zformathtml.<locals>.<listcomp>r>r1r2r�r�rAs<p>
<b>%s</b> %s
</p>
r=s<p>
%s
</p>
r&r�rDs<pre>
%s
</pre>
r�r�rs<h%d>%s</h%d>
rr�s<table>
s<tr>s<td>s</td>s</tr>
s	</table>
rRsdlNs <dt>%s
 <dd>%s
rO)�*rsulsols	 <li> %s
rQrdrPrmr?s</%s>
sdefinition bullet field option)r[r�r�r�r�rpr8�index�popr4r()r9�
headernestr�r�r�r:�btyper�r;r�r!rKr�r�r�r��bullet�headrfryrvr��nb�nirr�r�
formathtmlgs�








(






�
r�cCs�t|�}|D]
}|d|7<qt|�}t|�}t||pg�\}}t|�}t|�}t|�}t|�}t|�}t	|�}t
||d�}t|�}t|�}||fS)z Parse text into a list of blocksr1)r�)
r<rNr�r�r�r�r�rarhr{r�r�r�)r!r/r}r�r9r:r~rrr�parse�s r�csd��fdd�|D��}|S)NrSc3��|]}t|��VqdSr'�r�r��r�rrr-���zformatblocks.<locals>.<genexpr>�r�)r9r�r!rr�r�formatblocks�sr�csd��fdd�|D��S)z"Format parsed blocks as plain textrSc3r�r'r�r�r�rrr-�r�zformatplain.<locals>.<genexpr>r�)r9r�rr�r�formatplain�sr��P�plaincCs>t|||pg�\}}|rt||�}|dkrt|�St||d�S)z-Parse and format the text according to width.shtmlr�)r��filtersectionsr�r�)r!r�r/r}�stylerr9r~rrr�format�s
r�cs
g}t��}g�d}g}g}d}|t|�kr�||\}}	}
||	d�=|�|�||ks2|�d|�r�||kr�t|�}t|�}|rF||krFd}g}
t�d|d�D]+}||}||ks`|||kr{|
�t���||d}��|d���|d	�qP|
r�|�|
�|dd�}��|
�|dt|�kr�||dd|	kr�|d7}��||d�|dt|�kr�||dd|	ks�|d7}|t|�ks|�r|��|D]0}
�fd
d�|
D�}|
d	d}�|d}d
d�||dg��	dd�|d<�|
d|�=q҈S)z�Select parsed blocks under the specified section

    The section name is separated by a dot, and matches the suffix of the
    full section path.
    rTNrFrCrrir?csg|]
}�|dd�qS)r2rr)r+�syn�r9rrr0r�z"filtersections.<locals>.<listcomp>r2s"%s"rrS)
�_getsectionsr(r8rErr��extend�reverser�r)r9r�parents�sectionsrK�lastparents�	synthetic�collapse�path�nestr:�llen�plenrr_�parent�sec�real�reallinerr�rr��s^

�

$$��
�r�cCs�d}d}g}dd�}|D�]8}|ddkrF|d}||vr!||7}|�|�d}|d	|�}|d	|�||�f}|�d
�|�||gf�q|ddvr�d}||vrV||7}|�|�d}|d	|�}tdt|�d�D]8}||}|d|kr{n*d
d�|dD�}	|	r�|	dd}
|d}|
|kr�|d7}n|
|kr�|d}nql|d	|�||�f}|�d
�|�||gf�q|s�ddgfg}|ddk�r<d}|d}
|t|�k�r||dd}|ddk�r|d}t|d�dk�r|t|dd�t|dd�d��7}|
|k�rn
|d7}|t|�ks�|dk�r<||d}|d|dk�r4|d7}|�d|gf�|dd�|�q|S)z=return a list of (section path, nesting level, blocks) tuplesrSrcSsL|ddkr|d}n|dd}t�|��d�}d|vr$|�d�d}|S)Nr>rQrdr2rr�()rr�rpr4)r:r�rrr�getname+s
z_getsections.<locals>.getnamer>r�r�rNr)rRrQrAcSsg|]
}|ddkr|�qS)r>rRr)r+�arrrr0Hr�z _getsections.<locals>.<listcomp>rir?r1rr�r2)r�r8r��ranger(r))r9r��names�secsrr:rKr�r�siblings�
siblingindentr/�pointer�bindentr�sindent�blevelrrrr�%sx


��
�
r�FcCs�dd�t|�D�}d|}|d�dd�|D��d}|g}|D];}g}t||�D]%\}}	d|	vr>d�dd�|	�d�D��}	d|t�|	�}
|�|	|
�q)|�|d�|�d�q |rjt|�dkrj|�d	|�|�|�|S)
zAGenerate an RST table for the given table data as a list of linescSr�)css�|]}t�|�VqdSr'rr�rrrr-rr�z'maketable.<locals>.<listcomp>.<genexpr>r�r�rrrr0rr�zmaketable.<locals>.<listcomp>rAcss�|]}d|VqdS)rNr)r+r�rrrr-t��zmaketable.<locals>.<genexpr>r&css�|]}|��VqdSr')r)r�rrrr-}rrri)r�r�r4rr
r8r(r�)�datar/�headerr�r�r�r�r,r�r�r�rrr�	maketableos 
rr')rNN)r�rNr�N)rF)3�__doc__�
__future__rr��i18nr�rrr�utilsrrrrrrrr�r3r<rNrHrXrYrZr�rar�rhr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�<module>sn


<�


2&
+8
�
\
]
8J

https://t.me/RX1948 - 2025