� L�g�3����dZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZddlmZddlmZddlmZmZmZmZmZmZmZe d d � ��Z Gd �d e��Zd S)zR This module provides an object oriented interface for pattern matching of files. �)� Collection)� zip_longest) �AnyStr�Callabler�Iterable�Iterator�Optional�Type�TypeVar�Union�)�util)�Pattern)� CheckResult�StrPath�TStrPath� TreeEntry�_filter_check_patterns� _is_iterable�normalize_file�Self�PathSpec)�boundc ��eZdZdZdeeddfd�Zdedefd�Z de fd�Z d e ddde fd �Z d e ddde fd �Z d!d ed eeedeefd�Z d!deed eeedeeefd�Z d"dedeeegdfdeedeeefd�Zedee deeeegeffdeede fd���Z d!dd�dee d eeedeedee fd�Z!e"e#j$��Z% d!d ed eeedefd�Z& d!dd�deed eeedeedeefd�Z' d"dd�dedeeegdfdeedeedee f d�Z( d"dd�dedeeegdfdeedeedeef d �Z)e)Z*dS)#rzd The :class:`PathSpec` class is a wrapper around a list of compiled :class:`.Pattern` instances. �patterns�returnNc�\�t|t��st|��}||_dS)z� Initializes the :class:`PathSpec` instance. *patterns* (:class:`~collections.abc.Collection` or :class:`~collections.abc.Iterable`) yields each compiled pattern (:class:`.Pattern`). N)� isinstance�CollectionType�listr)�selfrs �a/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/pathspec/pathspec.py�__init__zPathSpec.__init__-s2�� �H�n� -� -���8�n�n�8�'/�$�-����otherc��t|t��r3t|j|j��}t d�|D����St S)z� Tests the equality of this path-spec with *other* (:class:`PathSpec`) by comparing their :attr:`~PathSpec.patterns` attributes. c3�(K�|] \}}||kV��dS�N�)�.0�a�bs r"� <genexpr>z"PathSpec.__eq__.<locals>.<genexpr>Ds*���� 1� 1���A�a�1�f� 1� 1� 1� 1� 1� 1r$)rrrr�all�NotImplemented)r!r%�paired_patternss r"�__eq__zPathSpec.__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__zPathSpec.__len__Hs�� �T�]� � �r$r!c�~�t|t��r"|�|j|jz��StS)z] Combines the :attr:`Pathspec.patterns` patterns from two :class:`PathSpec` instances. )rr� __class__rr/�r!r%s r"�__add__zPathSpec.__add__Os7�� ��x� � �� �.�.�����7� 8� 8�8� �r$c�h�t|t��r|xj|jz c_|StS)zi Adds the :attr:`Pathspec.patterns` patterns from one :class:`PathSpec` instance to this instance. )rrrr/r7s r"�__iadd__zPathSpec.__iadd__Ys3�� ��x� � ���=�=�E�N�"�=�=� �;� �r$�file� separatorsc��t||��}|�t|j��|��\}}t |||��S)a� Check the files against this path-spec. *file* (:class:`str` or :class:`os.PathLike`) is the file path 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 file check result (:class:`~pathspec.util.CheckResult`). )r� _match_file� enumeraterr)r!r;r<� norm_file�include�indexs r"� check_filezPathSpec.check_filedsH��"�T�:�.�.�)��#�#�I�d�m�$<�$<�i�H�H�.�'�5� �T�7�E� *� *�*r$�filesc#��K�t|��std|�d����t|j��}|D]>}t ||��}|�||��\}}t |||��V��?dS)a. Check the files against this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str` or :class:`os.PathLike`) contains the file paths to be checked 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 an :class:`~collections.abc.Iterator` yielding each file check result (:class:`~pathspec.util.CheckResult`). �files:� is not an iterable.N)r� TypeErrorrrrr>r)r!rDr<� use_patterns� orig_filer@rArBs r"� check_fileszPathSpec.check_filesys�����& �e� � �;� �9�E�9�9�9� :� :�:�'�� �6�6�,��0�0�i��i��4�4�9��$�$�\�9�=�=�>�7�E� �Y��� /� /�/�/�/�/�0�0r$�root�on_error� follow_linksc#�nK�tj|||���}|�|��Ed{V��dS)a� Walks the specified root path for all files and checks them against this path-spec. *root* (:class:`str` or :class:`os.PathLike`) 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. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns an :class:`~collections.abc.Iterator` yielding each file check result (:class:`~pathspec.util.CheckResult`). �rMrNN)r�iter_tree_filesrK)r!rLrMrNrDs r"�check_tree_fileszPathSpec.check_tree_files�sK����< � �t�h�\� R� R� R�%� � � �e� $� $�$�$�$�$�$�$�$�$�$r$�cls�pattern_factory�linesc���t�t��rtj����t ���st d��d����t |��st d|�d�����fd�|D��}||��S)ai 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 that it can be a :class:`io.TextIOBase` (e.g., from :func:`open` or :class:`io.StringIO`) or the result from :meth:`str.splitlines`. Returns the :class:`PathSpec` instance. zpattern_factory:z is not callable.zlines:rGc�*��g|]}|��|����Sr)r))r*�linerTs �r"� <listcomp>z'PathSpec.from_lines.<locals>.<listcomp>�s(��� >� >� >��� >�o�o�d�#�#� >� >� >r$)r�strr�lookup_pattern�callablerHr)rSrTrUrs ` r"� from_lineszPathSpec.from_lines�s����*���%�%�:��(��9�9�?� �/� "� "�L� �J�o�J�J�J� K� K�K� �e� � �;� �9�E�9�9�9� :� :�:� >� >� >� >�� >� >� >�(� ��X���r$��negate�entriesr_c#��K�t|��std|�d����t|j��}|D];}t |j|��}|�||��\}}|r| }|r|V��<dS)a Matches the entries to this path-spec. *entries* (:class:`~collections.abc.Iterable` of :class:`~pathspec.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. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched entries (:class:`~collections.abc.Iterator` of :class:`~pathspec.util.TreeEntry`). zentries:rGN)rrHrrr�pathr>) r!r`r<r_rI�entryr@rA�_indexs r"� match_entrieszPathSpec.match_entries�s�����2 �g� � �?� �=�g�=�=�=� >� >�>�'�� �6�6�,����e��e�j�*�5�5�9��%�%�l�I�>�>�?�7�F� ���k�G� �� �K�K�K���r$c��t||��}|�t|j��|��\}}t |��S)a� Matches the file to this path-spec. *file* (:class:`str` or :class:`os.PathLike`) 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`. )rr>r?r�bool)r!r;r<r@rArds r"� match_filezPathSpec.match_filesB��"�T�:�.�.�)��$�$�Y�t�}�%=�%=�y�I�I�/�'�6� �g���r$c#��K�t|��std|�d����t|j��}|D]6}t ||��}|�||��\}}|r| }|r|V��7dS)a  Matches the files to this path-spec. *files* (:class:`~collections.abc.Iterable` of :class:`str` or :class:`os.PathLike`) 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. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterator` of :class:`str` or :class:`os.PathLike`). rFrGN)rrHrrrr>) r!rDr<r_rIrJr@rArds r"� match_fileszPathSpec.match_filess�����4 �e� � �;� �9�E�9�9�9� :� :�:�'�� �6�6�,����i��i��4�4�9��%�%�l�I�>�>�?�7�F� ���k�G� �� �O�O�O���r$c#�rK�tj|||���}|�||���Ed{V��dS)a� Walks the specified root path for all files and matches them to this path-spec. *root* (:class:`str` or :class:`os.PathLike`) is the root directory to search. *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterator` of :class:`.TreeEntry`). rPr^N)r�iter_tree_entriesre)r!rLrMrNr_r`s r"�match_tree_entrieszPathSpec.match_tree_entriesBsQ����@ � "�4�(�� V� V� V�'� � � ��� � 7� 7�7�7�7�7�7�7�7�7�7r$c#�rK�tj|||���}|�||���Ed{V��dS)a� Walks the specified root path for all files and matches them to this path-spec. *root* (:class:`str` or :class:`os.PathLike`) 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. It will be called with the exception (:exc:`OSError`). Reraise the exception to abort the walk. Default is :data:`None` to ignore file-system exceptions. *follow_links* (:class:`bool` or :data:`None`) optionally is whether to walk symbolic links that resolve to directories. Default is :data:`None` for :data:`True`. *negate* (:class:`bool` or :data:`None`) is whether to negate the match results of the patterns. If :data:`True`, a pattern matching a file will exclude the file rather than include it. Default is :data:`None` for :data:`False`. Returns the matched files (:class:`~collections.abc.Iterable` of :class:`str`). rPr^N)rrQrj)r!rLrMrNr_rDs r"�match_tree_fileszPathSpec.match_tree_filesesQ����@ � �t�h�\� R� R� R�%� � � �e�F� � 3� 3�3�3�3�3�3�3�3�3�3r$r()NN)+�__name__� __module__� __qualname__�__doc__rrr#�objectrgr1�intr4rr8r:rr rrZrrCrrKrr�OSErrorrR� classmethodr r rr]rre� staticmethodr�check_match_filer>rhrjrmro� match_treer)r$r"rr'sf�������� �h�w�/��D����� �� �D� � � � ��c������4�� ��t����� �D� �� �� � � � �+/�+�+��+��z�#��'�+��(�� +�+�+�+�0+/�0�0� �(� �0��z�#��'�0��{�8�$�%� 0�0�0�0�>37�!%� %�%��%� �X�w�i��o�.� /�%���� %� �{�3�� � %�%�%�%�B�� �D�z����h��x��'8�9�9�:�� �&� �� � ����+��F+/�%�  � %�%�%� �I� �%��z�#��'�%� �4�.� %� �y�� %�%�%�%�N�|�D�1�2�2���+/������z�#��'�� � ����0+/�&�  � &�&�&� �'� �&��z�#��'�&� �4�.� &� �w�� &�&�&�&�V37�!%� !8�  � !8�!8�!8��!8� �X�w�i��o�.� /�!8���� !8� �4�.� !8��y��!8�!8�!8�!8�L37�!%� !4�  � !4�!4�!4��!4� �X�w�i��o�.� /�!4���� !4� �4�.� !4��s�m�!4�!4�!4�!4�J���r$N)rs�collections.abcrr� itertoolsr�typingrrrrr r r r �r�patternrrrrrrrrrrtrr)r$r"�<module>r�s����������������� � � � � � � � � � � � � � � � � � � � � � ������� � � � � � ��������������������w�v�Z�(�(�(��� c�c�c�c�c�v�c�c�c�c�cr$
Memory