o
    ooim                     @   sL   d Z ddgZdZddlZddlmZ ddlmZ ddl	Z	G dd deZ
dS )	a   
Module cdifflib -- c implementation of difflib.

Class CSequenceMatcher:
    A faster version of difflib.SequenceMatcher.  Reimplements a single
    bottleneck function - find_longest_match - in native C.  The rest of the
    implementation is inherited.
CSequenceMatcher__version__z1.2.5    N)SequenceMatcher)Matchc                   @   s6   e Zd ZdddZdd Zdd	 Zd
d Zdd ZdS )r   N Tc                 C   sF   t jd dkrt jd dk rt| ||| dS t| |||| dS )zYConstruct a CSequenceMatcher.

        Simply wraps the difflib.SequenceMatcher.
        r            N)sysversion_info_SequenceMatcher__init__)selfisjunkabautojunk r   </home/ubuntu/.local/lib/python3.10/site-packages/cdifflib.pyr      s   zCSequenceMatcher.__init__c                 C   s$   t | ||||\}}}t|||S )z~Find longest matching block in a[alo:ahi] and b[blo:bhi].

        Wrapper for the C implementation of this function.
        )	_cdifflibfind_longest_match_Match)r   aloahiblobhibestibestjbestsizer   r   r   r       s   z#CSequenceMatcher.find_longest_matchc                 C   sL   || j u rdS || _ t| j tst| j | _ dd | j D  d | _| _dS )zWSame as SequenceMatcher.set_seq1, but check for non-list inputs
        implementation.Nc                 S      g | ]}t |qS r   hash.0xr   r   r   
<listcomp>2       z-CSequenceMatcher.set_seq1.<locals>.<listcomp>)r   
isinstancelistmatching_blocksopcodes)r   r   r   r   r   set_seq1(   s   
zCSequenceMatcher.set_seq1c                 C   s   || j u rt| drdS || _ t| jtst| j| _t| j ts't| j | _ dd | jD  dd | j D  d | _| _d| _t	| \}}t|dsNJ t|dsUJ |j
| _|j
| _dS )zXSame as SequenceMatcher.set_seq2, but uses the c chainb
        implementation.
        isbjunkNc                 S   r   r   r    r"   r   r   r   r%   C   r&   z-CSequenceMatcher.set_seq2.<locals>.<listcomp>c                 S   r   r   r    r"   r   r   r   r%   D   r&   __contains__)r   hasattrr'   r   r(   r)   r*   
fullbcountr   chain_br-   r,   
isbpopular)r   r   junkpopularr   r   r   set_seq25   s    zCSequenceMatcher.set_seq2c                 C   sJ   | j dur| j S t | }|t| jt| jdf || _ ttj| j S )zSame as SequenceMatcher.get_matching_blocks, but calls through to a
        faster loop for find_longest_match.  The rest is the same.
        Nr   )	r)   r   appendlenr   r   mapr   _make)r   r)   r   r   r   get_matching_blocksO   s   

z$CSequenceMatcher.get_matching_blocks)Nr   r   T)__name__
__module____qualname__r   r   r+   r4   r9   r   r   r   r   r      s    
)__doc____all__r   r
   difflibr   r   r   r   r   r   r   r   r   r   <module>   s    	