
    [d                         d Z ddl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mZ ddlmZ  edd	
          Z	  G d d	e
          ZdS )zV
This module provides :class:`.GitIgnoreSpec` which replicates
*.gitignore* behavior.
    )AnyStrCallable
CollectionIterableTypeTypeVarUnion   )PathSpec)Pattern)GitWildMatchPatternGitWildMatchPatternError	_DIR_MARK)_is_iterableSelfGitIgnoreSpec)boundc                        e Zd ZdZdedef fdZe	 ddee	         de
e         deeeegef         df         de	f fd	            Zed
ee         dedefd            Z xZS )r   zc
	The :class:`GitIgnoreSpec` class extends :class:`PathSpec` to
	replicate *.gitignore* behavior.
	otherreturnc                     t          |t                    r!t                                          |          S t          |t                    rdS t
          S )z
		Tests the equality of this gitignore-spec with *other*
		(:class:`GitIgnoreSpec`) by comparing their :attr:`~PathSpec.patterns`
		attributes. A non-:class:`GitIgnoreSpec` will not compare equal.
		F)
isinstancer   super__eq__r   NotImplemented)selfr   	__class__s     2lib/python3.11/site-packages/pathspec/gitignore.pyr   zGitIgnoreSpec.__eq__'   sJ     }%% 
''..

%"" 
%
    Nclslinespattern_factoryc                     |t           }n7t          |t                    st          |          rt	          |          r||}}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:`.Pattern`).
		Default is :data:`None` for :class:`.GitWildMatchPattern`).

		Returns the :class:`GitIgnoreSpec` instance.
		)r   r   strcallabler   r   
from_lines)r    r!   r"   r   r   s       r   r&   zGitIgnoreSpec.from_lines4   si    ,  3(??5# 3(5// 3|O7T7T 3!?E?			OU	3	3$	+r   patternsfilec                 >   d}d}| D ]}|j         |                    |          }|u	 |j                            t                    }n># t
          $ r1}t          d|d|j        dt          d|j        d	          |d}~ww xY w|rd	}nd
}||k    r	|j         }|}|S )a  
		Matches the file to the patterns.

		.. NOTE:: Subclasses of :class:`.PathSpec` may override this
		   method as an instance method. It does not have to be a static
		   method.

		*patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`)
		contains the patterns to use.

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

		Returns :data:`True` if *file* matched; otherwise, :data:`False`.
		Fr   NzJInvalid git pattern: directory marker regex group is missing. Debug: file=z regex=z group=z match=.r
      )include
match_filematchgroupr   
IndexErrorr   regex)	r'   r(   out_matchedout_prioritypatternr.   dir_markeprioritys	            r   _match_filezGitIgnoreSpec._match_fileT   s   ( +,  go t$$E 	""9--hh    %55 5%,]5 55 5$)K5 5 5	 	 	 	 hh hL  Okl	s   A
B,A>>B)N)__name__
__module____qualname____doc__objectboolr   classmethodr   r   r   r   r	   r$   r   r   r&   staticmethodr   r   r8   __classcell__)r   s   @r   r   r   !   s        
 D        DH Dz	&	 hx'894?@ 	     +> 2*+22 2 2 2 ,2 2 2 2 2r   N)r<   typingr   r   r   r   r   r   r	   pathspecr   r4   r   patterns.gitwildmatchr   r   r   utilr   r   r    r   r   <module>rG      sN   
                      
 
 
 
 
 
               wv_---f f f f fH f f f f fr   