
    &`is                     N    d Z ddlmZ ddlmZmZmZmZmZ  G d de	          Z
dS )zR
This module provides an object oriented interface for pattern matching
of files.
   )util)
Collectioniterkeysizip_longeststring_typesunicodec                   r    e Zd ZdZd Zd Zd Zd Zd Ze	d             Z
dd	Zdd
ZddZddZddZeZdS )PathSpeczd
	The :class:`PathSpec` class is a wrapper around a list of compiled
	:class:`.Pattern` instances.
	c                 \    t          |t                    r|nt          |          | _        dS )z
		Initializes the :class:`PathSpec` instance.

		*patterns* (:class:`~collections.abc.Collection` or :class:`~collections.abc.Iterable`)
		yields each compiled pattern (:class:`.Pattern`).
		N)
isinstancer   listpatterns)selfr   s     }/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/thirdparty/pathspec/pathspec.py__init__zPathSpec.__init__   s.     ):>>R((DNN$-     c                     t          |t                    r3t          | j        |j                  }t	          d |D                       S t
          S )z
		Tests the equality of this path-spec with *other* (:class:`PathSpec`)
		by comparing their :attr:`~PathSpec.patterns` attributes.
		c              3   (   K   | ]\  }}||k    V  d S N ).0abs      r   	<genexpr>z"PathSpec.__eq__.<locals>.<genexpr>&   s*      11Aa1f111111r   )r   r
   r   r   allNotImplemented)r   otherpaired_patternss      r   __eq__zPathSpec.__eq__   sL    
 x   !$-@@?
11111
1
11
r   c                 *    t          | j                  S )zW
		Returns the number of compiled patterns this path-spec contains
		(:class:`int`).
		)lenr   )r   s    r   __len__zPathSpec.__len__*   s    
 
T]		r   c                 r    t          |t                    rt          | j        |j        z             S t          S )z]
		Combines the :attr:`Pathspec.patterns` patterns from two
		:class:`PathSpec` instances.
		r   r
   r   r   r   r   s     r   __add__zPathSpec.__add__1   s3    
 x   
4=5>1
2
22
r   c                 h    t          |t                    r| xj        |j        z  c_        | S t          S )zi
		Adds the :attr:`Pathspec.patterns` patterns from one :class:`PathSpec`
		instance to this instance.
		r$   r%   s     r   __iadd__zPathSpec.__iadd__;   s3    
 x   ==EN"==
;
r   c                 V   t          t                    rt          j                  t	                    s"t          d                                        t          j        |          s"t          d                    |                    fd|D             } | |          S )a[  
		Compiles the pattern lines.

		*pattern_factory* can be either the name of a registered pattern
		factory (:class:`str`), or a :class:`~collections.abc.Callable` used
		to compile patterns. It must accept an uncompiled pattern (:class:`str`)
		and return the compiled pattern (:class:`.Pattern`).

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

		Returns the :class:`PathSpec` instance.
		z%pattern_factory:{!r} is not callable.zlines:{!r} is not an iterable.c                 *    g | ]}| |          S r   r   )r   linepattern_factorys     r   
<listcomp>z'PathSpec.from_lines.<locals>.<listcomp>_   s(    
;
;
;Td
;??4  
;
;
;r   )r   r   r   lookup_patterncallable	TypeErrorformat_is_iterable)clsr,   liness    ` r   
from_lineszPathSpec.from_linesF   s    " .. :(99?	/	"	" T	:AA/RR	S	SS		5	!	! C	3::5AA	B	BB
;
;
;
;U
;
;
;%	Ur   Nc                 b    t          j        ||          }t          j        | j        |          S )a  
		Matches the file to this path-spec.

		*file* (:class:`str` or :class:`~pathlib.PurePath`) is the file path
		to be matched against :attr:`self.patterns <PathSpec.patterns>`.

		*separators* (:class:`~collections.abc.Collection` of :class:`str`)
		optionally contains the path separators to normalize. See
		:func:`~pathspec.util.normalize_file` for more information.

		Returns :data:`True` if *file* matched; otherwise, :data:`False`.
		
separators)r   normalize_file
match_filer   )r   filer8   	norm_files       r   r:   zPathSpec.match_fileb   s-     !$:>>>)			2	22r   c              #     K   t          j        |          s"t          d                    |                    t          j        ||          }t          j        | j        t          |                    }|D ]}||         V  dS )a	  
		Matches the entries to this path-spec.

		*entries* (:class:`~collections.abc.Iterable` of :class:`~util.TreeEntry`)
		contains the entries to be matched against :attr:`self.patterns <PathSpec.patterns>`.

		*separators* (:class:`~collections.abc.Collection` of :class:`str`;
		or :data:`None`) optionally contains the path separators to
		normalize. See :func:`~pathspec.util.normalize_file` for more
		information.

		Returns the matched entries (:class:`~collections.abc.Iterable` of
		:class:`~util.TreeEntry`).
		z entries:{!r} is not an iterable.r7   N)r   r2   r0   r1   _normalize_entriesmatch_filesr   r   )r   entriesr8   	entry_mapmatch_pathspaths         r   match_entrieszPathSpec.match_entriesr   s       
	7	#	# G	5<<WEE	F	FF%g*EEE) 0C0CDD+  d	4 r   c              #     K   t          j        |          s"t          d                    |                    t          j        ||          }t          j        | j        t          |                    }|D ]}||         V  dS )a  
		Matches the files to this path-spec.

		*files* (:class:`~collections.abc.Iterable` of :class:`str; or
		:class:`pathlib.PurePath`) contains the file paths to be matched
		against :attr:`self.patterns <PathSpec.patterns>`.

		*separators* (:class:`~collections.abc.Collection` of :class:`str`;
		or :data:`None`) optionally contains the path separators to
		normalize. See :func:`~pathspec.util.normalize_file` for more
		information.

		Returns the matched files (:class:`~collections.abc.Iterable` of
		:class:`str`).
		zfiles:{!r} is not an iterable.r7   N)r   r2   r0   r1   normalize_filesr?   r   r   )r   filesr8   file_mapmatched_filesrC   s         r   r?   zPathSpec.match_files   s        
	5	!	! C	3::5AA	B	BB!%J???("4=(82D2DEE-  d	$ r   c                 Z    t          j        |||          }|                     |          S )a  
		Walks the specified root path for all files and matches them to this
		path-spec.

		*root* (:class:`str`; or :class:`pathlib.PurePath`) is the root
		directory to search.

		*on_error* (:class:`~collections.abc.Callable` or :data:`None`)
		optionally is the error handler for file-system exceptions. See
		:func:`~pathspec.util.iter_tree_entries` for more information.

		*follow_links* (:class:`bool` or :data:`None`) optionally is whether
		to walk symbolic links that resolve to directories. See
		:func:`~pathspec.util.iter_tree_files` for more information.

		Returns the matched files (:class:`~collections.abc.Iterable` of
		:class:`str`).
		on_errorfollow_links)r   iter_tree_entriesrD   )r   rootrL   rM   r@   s        r   match_tree_entrieszPathSpec.match_tree_entries   s/    & "4(VVV'			G	$	$$r   c                 Z    t          j        |||          }|                     |          S )a  
		Walks the specified root path for all files and matches them to this
		path-spec.

		*root* (:class:`str`; or :class:`pathlib.PurePath`) is the root
		directory to search for files.

		*on_error* (:class:`~collections.abc.Callable` or :data:`None`)
		optionally is the error handler for file-system exceptions. See
		:func:`~pathspec.util.iter_tree_files` for more information.

		*follow_links* (:class:`bool` or :data:`None`) optionally is whether
		to walk symbolic links that resolve to directories. See
		:func:`~pathspec.util.iter_tree_files` for more information.

		Returns the matched files (:class:`~collections.abc.Iterable` of
		:class:`str`).
		rK   )r   iter_tree_filesr?   )r   rO   rL   rM   rG   s        r   match_tree_fileszPathSpec.match_tree_files   s/    & 
th\
R
R
R%			%	 	  r   r   )NN)__name__
__module____qualname____doc__r   r   r"   r&   r(   classmethodr5   r:   rD   r?   rP   rS   
match_treer   r   r   r
   r
      s         
  	 	 	    	 	 	   +63 3 3 3    .   0% % % %,! ! ! !. r   r
   N)rW    r   compatr   r   r   r   r   objectr
   r   r   r   <module>r]      s    
       M M M M M M M M M M M M M MC C C C Cv C C C C Cr   