File: //usr/lib/python3/dist-packages/trac/versioncontrol/__pycache__/diff.cpython-310.pyc
o
�k�`Q5 � @ s� d dl Z d dlZd dlmZmZ d dlmZ g d�Ze�dej �j
Zdd� Zdd � 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+c C s d� t| ��S )N� )�join�_whitespace_split)�text� r
�:/usr/lib/python3/dist-packages/trac/versioncontrol/diff.py�_norm_space_changes s r c C s� d}t t| �t|��}||k r'| | || kr'|d7 }||k r'| | || ksd}|| }| |krK| | || krK|d8 }| |krK| | || ks:||d fS )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
r r ! s ��r Fc C sh |rt tt| ��} t tt|��}|r dd� | D �} dd� |D �}t| ||�}|r2t|| |||dd�}|S )aT Retrieve 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.
c S � g | ]}|� � �qS r
��lower��.0�lr
r
r �
<listcomp>M � z&get_filtered_hunks.<locals>.<listcomp>c S r r
r r r
r
r r N r F)�list�mapr � get_hunks�filter_ignorable_lines)� fromlines�tolines�context�ignore_blank_lines�ignore_case�ignore_space_changes�hunksr
r
r �get_filtered_hunks5 s
�r, c C s4 t �d| |�}|du rdd� |�� fD �S |�|�S )z~Generator yielding grouped opcodes describing differences .
See `get_filtered_hunks` for the parameter descriptions.
Nc s s � | ]}|V qd S �Nr
)r �hunkr
r
r � <genexpr>] s � zget_hunks.<locals>.<genexpr>)�difflib�SequenceMatcher�get_opcodes�get_grouped_opcodes)r% r&