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/trac/versioncontrol/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/versioncontrol/__pycache__/diff.cpython-310.pyc
o

�k�`Q5�@s�ddlZddlZddlmZmZddlmZgd�Ze�dej	�j
Zdd�Zdd	�Z
		
	
ddd�Zdd
d�Zdd�Z		ddd�Z		ddd�Zdd�ZdS)�N)�Markup�escape)�
expandtabs)�diff_blocks�get_change_extent�get_diff_options�unified_diffz\s+cCsd�t|��S)N� )�join�_whitespace_split)�text�r
�:/usr/lib/python3/dist-packages/trac/versioncontrol/diff.py�_norm_space_changessrcCs�d}tt|�t|��}||kr'||||kr'|d7}||kr'||||ksd}||}||krK||||krK|d8}||krK||||ks:||dfS)a Determines the extent of differences between two strings.

    Returns a pair containing the offset at which the changes start,
    and the negative offset at which the changes end.

    If the two strings have neither a common prefix nor a common
    suffix, ``(0, 0)`` is returned.
    r����)�min�len)�str1�str2�start�limit�endr
r
rr!s	��rFcCsh|rttt|��}ttt|��}|r dd�|D�}dd�|D�}t|||�}|r2t|||||dd�}|S)aTRetrieve differences in the form of `difflib.SequenceMatcher`
    opcodes, grouped according to the ``context`` and ``ignore_*``
    parameters.

    :param fromlines: list of lines corresponding to the old content
    :param tolines: list of lines corresponding to the new content
    :param ignore_blank_lines: differences about empty lines only are ignored
    :param ignore_case: upper case / lower case only differences are ignored
    :param ignore_space_changes: differences in amount of spaces are ignored
    :param context: the number of "equal" lines kept for representing
                    the context of the change
    :return: generator of grouped `difflib.SequenceMatcher` opcodes

    If none of the ``ignore_*`` parameters is `True`, there's nothing
    to filter out the results will come straight from the
    SequenceMatcher.
    cS�g|]}|���qSr
��lower��.0�lr
r
r�
<listcomp>M�z&get_filtered_hunks.<locals>.<listcomp>cSrr
rrr
r
rrNr F)�list�mapr�	get_hunks�filter_ignorable_lines)�	fromlines�tolines�context�ignore_blank_lines�ignore_case�ignore_space_changes�hunksr
r
r�get_filtered_hunks5s
�r,cCs4t�d||�}|durdd�|��fD�S|�|�S)z~Generator yielding grouped opcodes describing differences .

    See `get_filtered_hunks` for the parameter descriptions.
    Ncss�|]}|VqdS�Nr
)r�hunkr
r
r�	<genexpr>]s�zget_hunks.<locals>.<genexpr>)�difflib�SequenceMatcher�get_opcodes�get_grouped_opcodes)r%r&r'�matcherr
r
rr#Vs
r#c#s�����fdd�}t|�}g}d}	d}
|D]_}|D]Z\}}
}}}|dkr:|
r2||
d||
d|f}
q||
|||f}
q||||
|�|||��r`d}	|
rXd|
d||
d|f}
nd|
|||f}
q|
rg|�|
�|�||
|||f�d}
qq|
r||�|
�|	�rB|dur�|VdS|}||}g��fd	d
�}t|�D]`\}\}}
}}}|dkr�|dkr�t|
||�t|||�}
}n5|dkr�||
|kr��||
t||
|�|t|||�f�|�s߈Vg�t|
||�t|||�}
}��||
|||f�q���r<t��dk�r�dddk�s>�dddk�r3�d\}}
}}}||
t||
|�|t|||�f�d<|��s@�VdSdSdSdS|D]}|V�qDdS)
z�Detect line changes that should be ignored and emits them as
    tagged as "equal", possibly joined with the preceding and/or
    following "equal" block.

    See `get_filtered_hunks` for the parameter descriptions.
    cs��r|dkrt|�S|dkrt|�S�s�rI|dkrGt|�t|�kr&dS��fdd�}tt|��D]}|||�|||�krDdSq3dSdSdS)N�delete�insert�replaceFcs�r|��}�rt|�}|Sr-)rr)�value)r)r*r
r�fts
z7filter_ignorable_lines.<locals>.is_ignorable.<locals>.fT)�anyr�range)�tagr%r&r9�i)r(r)r*r
r�is_ignorableks

��z,filter_ignorable_lines.<locals>.is_ignorableFN�equalr�Tcstdd��D��dS)Ncss�|]	}|ddkVqdS)rr?Nr
)r�opr
r
rr/�s�z<filter_ignorable_lines.<locals>.all_equal.<locals>.<genexpr>)�allr
)�groupr
r�	all_equal�sz)filter_ignorable_lines.<locals>.all_equalrr)r!�append�	enumerate�maxrr)r+r%r&r'r(r)r*r>�opcodes�
ignored_lines�prevr.r<�i1�i2�j1�j2�n�nnrD�idxr
)rCr(r)r*rr$bsn�	
�

 �&&
�
�r$�c
sBddddd�}t�d��dd����fd	d
�}g}	t��||||�D]�}
g}d}||
�D]�\}
}}}}|
|krH|�||
|gd�|gd�d
��|
dkr��||�D] }|�|�}���t|dd��}|ddd�tt|���qR�||�D] }|�|�}���t|dd��}|ddd�tt|���qyq,|
dvrو||�D]3}t||d�}t|dd�}d�	��fdd�|�
d�D��}|�dd�}|ddd�tt|���q�|
dv�r�||�D]3}t||d�}t|dd�}d�	��fdd�|�
d�D��}|�dd �}|ddd�tt|���q�q,|	�|�q"|	S)!z�Return an array that is adequate for adding to the data dictionary

    See `get_filtered_hunks` for the parameter descriptions.

    See also the diff_div.html template.
    �mod�rem�add�unmod)r7r5r6r?z ( +)|^ cSs,tt|�d��d�\}}t|d|d�S)Nr�z&nbsp; z&nbsp;)�divmodrrCr)�match�divrSr
r
r�htmlify�szdiff_blocks.<locals>.htmlifyc3s�|D]�\}}}}}|dkr{||||kr{t||�D]^}�||�||}}t||�\}	}
|	dks:|
dkrz|
t|�}|d|	�d||	|�d||d��||<|
t|�}|d|	�d||	|�d||d��||<q|||||fVqdS)Nr7r��)r;rr)rHr<rKrLrMrNr=�fromline�tolinerr�last)r%r&r
r�markup_intraline_changes�s0��
�
��
�
���z-diff_blocks.<locals>.markup_intraline_changesN)�offset�lines)�type�base�changedr?F)�quotesrrercrf�r7r5zz<del>c3��|]	}���|�VqdSr-��sub�r�seg�r[�space_rer
rr/����zdiff_blocks.<locals>.<genexpr>r\r]z</del>�r7r6z<ins>c3rir-rjrlrnr
rr/rpz</ins>)�re�compiler,rErrkrr�strr
�splitr7)r%r&r'�tabwidthr(r)r*�type_mapra�changesrC�blocks�last_tagr<rKrLrMrN�liner
)r%r[ror&rr�sl	�
�
�
 
 ��
�
�
��rc
cs�t||||||�D]z}|dd|dd|dd|ddf\}}}	}
|dkr2|dkr2d\}}d|d|||	d|
|	fV|D]>\}}}}	}
|d	kr_|||�D]}d
|VqVqE|dvrq|||�D]}d|Vqi|d
vr�||	|
�D]}d|Vq{qEq
dS)z}Generator producing lines corresponding to a textual diff.

    See `get_filtered_hunks` for the parameter descriptions.
    rrrrWr@�)rrz@@ -%d,%d +%d,%d @@r?r	rh�-rq�+N)r,)
r%r&r'r(r)r*rCrKrLrMrNr<r{r
r
rr	s.��4"����rc	s2i}d|i}d�fdd�	}�j�dd�}�j�d|�}d�jvr,||kr,�j�d|d�||d<�j�d	d
�}�j�d|�}d�jvrO||krO�j�d	|d
�||d<�j�dd�}||d<d
|rcdn|g}|d�}|rr|�d�||d<|d�}|r�|�d�||d<|d�}|r�|�d�||d<|||fS)aRetrieve user preferences for diffs.

    :return: ``(style, options, data)`` triple.

      ``style``
        can be ``'inline'`` or ``'sidebyside'``,
      ``options``
        a sequence of "diff" flags,
      ``data``
        the style and options information represented as
        key/value pairs in dictionaries, for example::

          {'style': 'sidebyside',
           'options': {'contextall': 1, 'contextlines': 2,
                       'ignorecase': 0,  'ignoreblanklines': 0,
                       'ignorewhitespace': 1}}

    �optionsrcsR�j�d||�}t|�jv�}d�jvr%||kr%�j�d|||�|S|}|S)N�diff_�update)�session�as_int�int�args�set)�name�default�pref�arg��reqr
r�get_bool_option9s�z)get_diff_options.<locals>.get_bool_option�
diff_style�inline�styler��diff_contextlinesrW�contextlines�
contextallz-U%dr�ignoreblanklinesz-B�
ignorecasez-i�ignorewhitespacez-bN)r)r��getr�r�r�rE)	r��options_data�datar�r�r�r'r�rr
r�rr#s:	



r)NFFFr-)NrRrrr)Nrrr)r0rr�trac.util.htmlrr�trac.util.textr�__all__rs�UNICODErurrrr,r#r$rrrr
r
r
r�<module>s*
�
!Z
�M
�

https://t.me/RX1948 - 2025