a
    e	g                     @   s   d Z ddlmZmZmZmZmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZ ddlmZ edd	d
ZG dd	 d	eZdS )zV
This module provides :class:`.GitIgnoreSpec` which replicates
*.gitignore* behavior.
    )
AnyStrCallableIterableOptionalTupleTypeTypeVarUnioncastoverload   )PathSpec)Pattern)GitWildMatchPattern	_DIR_MARK)_is_iterableSelfGitIgnoreSpec)boundc                
       s  e Zd ZdZeed fddZeee	e
 eeeegef f ee e
dddZeede	e
 ee eeeegef df e
d	d
dZede	e
 ee eeeegef df e
d	 fddZeeeeef  eeee ee f dddZ  ZS )r   zu
	The :class:`GitIgnoreSpec` class extends :class:`pathspec.pathspec.PathSpec` to
	replicate *.gitignore* behavior.
	)otherreturnc                    s,   t |trt |S t |tr$dS tS dS )z
		Tests the equality of this gitignore-spec with *other* (:class:`GitIgnoreSpec`)
		by comparing their :attr:`~pathspec.pattern.Pattern`
		attributes. A non-:class:`GitIgnoreSpec` will not compare equal.
		FN)
isinstancer   super__eq__r   NotImplemented)selfr   	__class__ U/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/pathspec/gitignore.pyr   )   s
    

zGitIgnoreSpec.__eq__)clspattern_factorylinesr   c                 C   s   d S Nr   )r    r!   r"   r   r   r   
from_lines7   s    zGitIgnoreSpec.from_linesN)r    r"   r!   r   c                 C   s   d S r#   r   )r    r"   r!   r   r   r   r$   @   s    c                    sN   |du rt }n(t|ttfs$t|r6t|r6|| }}t ||}tt	|S )a  
		Compiles the pattern lines.

		*lines* (:class:`~collections.abc.Iterable`) yields each uncompiled
		pattern (:class:`str`). This simply has to yield each line so it can
		be a :class:`io.TextIOBase` (e.g., from :func:`open` or
		:class:`io.StringIO`) or the result from :meth:`str.splitlines`.

		*pattern_factory* can be :data:`None`, the name of a registered
		pattern factory (:class:`str`), or a :class:`~collections.abc.Callable`
		used to compile patterns. The callable must accept an uncompiled
		pattern (:class:`str`) and return the compiled pattern
		(:class:`pathspec.pattern.Pattern`).
		Default is :data:`None` for :class:`.GitWildMatchPattern`).

		Returns the :class:`GitIgnoreSpec` instance.
		N)
r   r   strbytescallabler   r   r$   r
   r   )r    r"   r!   r   r   r   r   r$   I   s    
)patternsfiler   c           
      C   s   d}d}d}| D ]r\}}|j dur||}|dur|j t}|rNd}	nd}	|j rl|rl|j }|}|	}q|	|kr|j }|}|	}q||fS )a  
		Check the file against the patterns.

		.. NOTE:: Subclasses of :class:`~pathspec.pathspec.PathSpec` may override
		   this method as an instance method. It does not have to be a static
		   method. The signature for this method is subject to change.

		*patterns* (:class:`~collections.abc.Iterable`) yields each indexed pattern
		(:class:`tuple`) which contains the pattern index (:class:`int`) and actual
		pattern (:class:`~pathspec.pattern.Pattern`).

		*file* (:class:`str`) is the normalized file path to be matched against
		*patterns*.

		Returns a :class:`tuple` containing whether to include *file* (:class:`bool`
		or :data:`None`), and the index of the last matched pattern (:class:`int` or
		:data:`None`).
		Nr   r      )includeZ
match_filematch	groupdictgetr   )
r(   r)   Zout_includeZ	out_indexZout_priorityindexpatternr,   Zdir_markpriorityr   r   r   _match_filej   s(    


zGitIgnoreSpec._match_file)N)N)__name__
__module____qualname____doc__objectboolr   r   classmethodr   r   r	   r%   r   r   r   r   r$   staticmethodr   intr   r   r2   __classcell__r   r   r   r   r   #   s>      N)r6   typingr   r   r   r   r   r   r   r	   r
   r   Zpathspecr   r0   r   Zpatterns.gitwildmatchr   r   utilr   r   r   r   r   r   r   <module>   s   0