� L�g�X� �Z�dZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl mZddlmZddlmZmZmZm Z mZmZm Z mZmZmZmZmZmZmZmZddlmZej d kree!ee!fZ"n ee!efZ"ed e"� ��Z# d �ej$ej%fD��Z& iZ' d ej(de!fd�Z)de ee*efde!deee+ee*ffd�Z, d9de ede e!dee+dee!dffd�Z-de edeee*effd�Z.dede+fd�Z/ d:de"deee0gdfdee+dedfd�Z1de!d e!d!ee!e!fdee0gdfde+dedf d"�Z2 d:de"deee0gdfdee+dee!fd#�Z3d:d$�Z4d%e!deegeffd&�Z5de ede!de+fd'�Z6de ede e!dee!fd(�Z7 d9de"d)ee e!de!fd*�Z8 d9de e"d)ee e!dee!ee"ffd+�Z9 d9d%e!d,eegefd-ee+ddfd.�Z:Gd/�d0e;��Z<Gd1�d2e;��Z=ed3�4��Gd5�d6ee#����Z>Gd7�de?��Z@Gd8�de?��ZAdS);zC This module provides utility methods for dealing with path-specs. �N)� Collection�Iterable)� dataclass)�PathLike)�Any�AnyStr�Callabler�Dict�Genericr�Iterator�List�Optional�Sequence�Set�Tuple�TypeVar�Union�)�Pattern)�� �TStrPath)�boundc�6�g|]}|r|tjk�|��S�)� posixpath�sep)�.0�__seps �]/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/pathspec/util.py� <listcomp>r!1s9����� � ���y�}�$�$��$�$�$��path�returnc�j�t|��}|���r|tjz }|S)a5 Appends the path separator to the path if the path is a directory. This can be used to aid in distinguishing between directories and files on the file-system by relying on the presence of a trailing path separator. *path* (:class:`pathlib.Path`) is the path to use. Returns the path (:class:`str`). )�str�is_dir�osr)r#�str_paths r �append_dir_sepr*Ds0�� ��I�I���K�K�M�M�� �b�f��(��r"�patterns�filec�l�d}d}|D]*\}}|j�|�|��� |j}|}�+||fS)a� Check the file against the patterns. *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`). N��include� match_file)r+r,� out_include� out_index�index�patterns r �check_match_filer5VsT��$ $�� �����^�U�G� �_� �W�%7�%7��%=�%=�%I���;��9���Y��r"�files� all_matches� MatchDetailc�X�t|t��r|nt|��}i}|D]~}|j�u|�|��}|jrQ|D]M}||vr4|r!||j�|���)|||jd<�:t|g��||<�N�v|D]}||=��|S)a� Matches the files to the patterns, and returns which patterns matched the files. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the normalized file paths to be matched against *patterns*. *all_matches* (:class:`bool` or :data:`None`) is whether to return all matches patterns (:data:`True`), or only the last matched pattern (:data:`False`). Default is :data:`None` for :data:`False`. Returns the matched files (:class:`dict`) which maps each matched file (:class:`str`) to the patterns that matched in order (:class:`.MatchDetail`). Nr)� isinstance�CollectionType�listr/�matchr+�appendr8) r+r6r7� all_files� return_filesr4� result_files� result_filer,s r �detailed_match_filesrCrs���,!���7�7� H�U�U�T�%�[�[�������W� �_� ��-�-� �*�*�<� �o��#�9�9� ��|�#�#� �7��K� �)�0�0��9�9�9�9�/6�|�K� �)�!�,�,�"-�w�i�"8�"8�l�;���9����� �d� � ���r"c�4�d�t|��D��S)a& Filters out null-patterns. *patterns* (:class:`Iterable` of :class:`.Pattern`) contains the patterns. Returns a :class:`list` containing each indexed pattern (:class:`tuple`) which contains the pattern index (:class:`int`) and the actual pattern (:class:`~pathspec.pattern.Pattern`). c�*�g|]\}}|j� ||f��S�N�r/)r�__index�__pats r r!z*_filter_check_patterns.<locals>.<listcomp>�s3�� � � ��g�u� �]�� �E����r")� enumerate�r+s r �_filter_check_patternsrL�s+�� � �!�(�+�+� � � �r"�valuec�f�t|t��ot|ttf�� S)z� Check whether the value is an iterable (excludes strings). *value* is the value to check, Returns whether *value* is a iterable (:class:`bool`). )r:� IterableTyper&�bytes)rMs r � _is_iterablerQ�s*�� �5�,�'�'�O� �5�3��,�0O�0O�,O�Or"�root�on_error� follow_links� TreeEntryc#��K�|�"t|��std|�d����|�d}ttj�|��di||��Ed{V��dS)a Walks the specified directory for all files and directories. *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`. Raises :exc:`RecursionError` if recursion is detected. Returns an :class:`~collections.abc.Iterator` yielding each file or directory entry (:class:`.TreeEntry`) relative to *root*. Nz on_error:� is not callable.T�)�callable� TypeError�_iter_tree_entries_nextr(r#�abspath�rRrSrTs r �iter_tree_entriesr^�s|����4 ���(�!3�!3���;�h�;�;�;�<�<�<����,� #�B�G�O�O�D�$9�$9�2�r�8�\� Z� Z�Z�Z�Z�Z�Z�Z�Z�Z�Zr"� root_full�dir_rel�memoc #�K�tj�||��}tj�|��}||vr|||<nt ||||����tj|��5}|D�]>}tj�||j��} |�d���} n$#t$r} |� || ��Yd} ~ �\d} ~ wwxYw|� ��r: |���} n&#t$r} |� || ��Yd} ~ ��d} ~ wwxYw| } |� |���r3t|j| | | ��V�t|| |||��Ed{V����|� ��s|� ��rt|j| | | ��V���@ ddd��n #1swxYwY||=dS)aq Scan the directory for all descendant files. *root_full* (:class:`str`) the absolute path to the root directory. *dir_rel* (:class:`str`) the path to the directory to scan relative to *root_full*. *memo* (:class:`dict`) keeps track of ancestor directories encountered. Maps each ancestor real path (:class:`str`) to relative path (:class:`str`). *on_error* (:class:`~collections.abc.Callable` or :data:`None`) optionally is the error handler for file-system exceptions. *follow_links* (:class:`bool`) is whether to walk symbolic links that resolve to directories. Yields each entry (:class:`.TreeEntry`). )� real_path� first_path� second_pathF)�follow_symlinksN)r(r#�join�realpath�RecursionError�scandir�name�stat�OSError� is_symlinkr'rUr[�is_file) r_r`rarSrT�dir_full�dir_real� scan_iter�node_ent�node_rel� node_lstat�e� node_stats r r[r[�s}����6 �G�L�L��G� ,� ,�� �G� � �X� &� &��  �D����$�x�.�.���d�8�n�RY�Z�Z�Z�Z��j����!D�i��D�D�h��g�l�l�7�H�M�2�2�8� ����u��5�5�J�J�� � � � ��� �X�a�[�[�[� �H�H�H�H����� ���� ����� �������Y�Y�� �������h�q�k�k�k� �X�X�X�X��������� �I��o�o�l�o�3�3� D� �H�M�8�Z�� C� C�C�C�C�&�y�(�D�(�L�Y�Y�Y�Y�Y�Y�Y�Y�Y�Y������D�h�1�1�3�3�D� �H�M�8�Z�� C� C�C�C�C��?D�!D�!D�!D�!D�!D�!D�!D�!D�!D�!D�!D����!D�!D�!D�!D�P �(�^�^�^sg�8+G�$B;�:G�; C� C�G�C�G�4D �G� D*� D%� G�%D*�*BG�G �G c#�pK�t|||���D] }|�|��s |jV��!dS)a� Walks the specified directory for all files. *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`. Raises :exc:`RecursionError` if recursion is detected. Returns an :class:`~collections.abc.Iterator` yielding the path to each file (:class:`str`) relative to *root*. �rSrTN)r^r'r#)rRrSrT�entrys r �iter_tree_filesr{3sS����4 ��x�l�S�S�S���U� ���l� #� #�� �������r"c�^�tjdtd���t|||���S)zg DEPRECATED: The :func:`.iter_tree` function is an alias for the :func:`.iter_tree_files` function. zCutil.iter_tree() is deprecated. Use util.iter_tree_files() instead.��� stacklevelry)�warnings�warn�DeprecationWarningr{r]s r � iter_treer�Rs<��  ��G��1�&�&�&�&� ��x�l�K�K�K�Kr"rkc��t|S)z� Lookups a registered pattern factory by name. *name* (:class:`str`) is the name of the pattern factory. Returns the registered pattern factory (:class:`~collections.abc.Callable`). If no pattern factory is registered, raises :exc:`KeyError`. )�_registered_patterns)rks r �lookup_patternr�]s�� �T�"�"r"c�Z�d}|D]%}|j�|�|���|j}�&|S)a7 Matches the file to the patterns. *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.)r+r,�matchedr4s r r0r0is@�� �����W� �_� �W�%7�%7��%=�%=�%I� �_�7���r"c���tjt�dt�d�td���d�|D��}t ��}|D]'}t ||��r|�|���(|S)a� DEPRECATED: This is an old function no longer used. Use the :func:`~pathspec.util.match_file` function with a loop for better results. Matches the files to the patterns. *patterns* (:class:`~collections.abc.Iterable` of :class:`~pathspec.pattern.Pattern`) contains the patterns to use. *files* (:class:`~collections.abc.Iterable` of :class:`str`) contains the normalized file paths to be matched against *patterns*. Returns the matched files (:class:`set` of :class:`str`). z".match_files() is deprecated. Use z-.match_file() with a loop for better results.r}r~c� �g|] }|j� |�� SrFrG)rrIs r r!zmatch_files.<locals>.<listcomp>�s��J�J�J�5�� �0I��0I�0I�0Ir")r�r��__name__r��setr0�add)r+r6� use_patternsr@r,s r � match_filesr�}s���$ �� � � �� � � ��1�&�&�&�&� K�J�H�J�J�J������ ���T�� �d�#�#�����D������r"� separatorsc��|�t}tj|��}|D]"}|�|tj��}�#|�d��r |dd�}n|�d��r |dd�}|S)ay Normalizes the file path to use the POSIX path separator (i.e., ``"/"``), and make the paths relative (remove leading ``"/"``). *file* (:class:`str` or :class:`os.PathLike`) is the file path. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or ``None``) optionally contains the path separators to normalize. This does not need to include the POSIX path separator (``"/"``), but including it will not affect the results. Default is ``None`` for ``NORMALIZE_PATH_SEPS``. To prevent normalization, pass an empty container (e.g., an empty tuple ``()``). Returns the normalized file path (:class:`str`). N�/rz./r})�NORMALIZE_PATH_SEPSr(�fspath�replacerr� startswith)r,r�� norm_filers r �normalize_filer��s���(��"�*��)�D�/�/�� �4�4�S�����Y�]�3�3�)�)� �����������m�)�)����4� � ������m�)��r"c��tjdtd���i}|D]9}t||���}||vr||�|���3|g||<�:|S)a� DEPRECATED: This function is no longer used. Use the :func:`.normalize_file` function with a loop for better results. Normalizes the file paths to use the POSIX path separator. *files* (:class:`~collections.abc.Iterable` of :class:`str` or :class:`os.PathLike`) contains the file paths to be normalized. *separators* (:class:`~collections.abc.Collection` of :class:`str`; or :data:`None`) optionally contains the path separators to normalize. See :func:`normalize_file` for more information. Returns a :class:`dict` mapping each normalized file path (:class:`str`) to the original file paths (:class:`list` of :class:`str` or :class:`os.PathLike`). z_util.normalize_files() is deprecated. Use util.normalize_file() with a loop for better results.r}r~)r�)r�r�r�r�r>)r6r�� norm_filesr#r�s r �normalize_filesr��s���* ��$��1�&�&�&�&� �� �"�"�T��T�j�9�9�9�)��*��� �i�����%�%�%�%� �6�:�i����r"�pattern_factory�overridec���t|t��std|�d����t|��std|�d����|tvr|st |t|���|t|<dS)aE Registers the specified pattern factory. *name* (:class:`str`) is the name to register the pattern factory under. *pattern_factory* (:class:`~collections.abc.Callable`) is used to compile patterns. It must accept an uncompiled pattern (:class:`str`) and return the compiled pattern (:class:`.Pattern`). *override* (:class:`bool` or :data:`None`) optionally is whether to allow overriding an already registered pattern under the same name (:data:`True`), instead of raising an :exc:`AlreadyRegisteredError` (:data:`False`). Default is :data:`None` for :data:`False`. zname:z is not a string.zpattern_factory:rWN)r:r&rZrYr��AlreadyRegisteredError)rkr�r�s r �register_patternr��s���( �4����5��3�$�3�3�3�4�4�4���!�!�K��I�_�I�I�I�J�J�J�� � � �� ��t�%9�$�%?�@�@�@�-��d���r"c���eZdZdZdedeegefddf�fd� Ze defd���Z e defd���Z e deegeffd ���Z �xZ S) r�z| The :exc:`AlreadyRegisteredError` exception is raised when a pattern factory is registered under a name already in use. rkr�r$Nc�Z��tt|���||��dS)z� Initializes the :exc:`AlreadyRegisteredError` instance. *name* (:class:`str`) is the name of the registered pattern. *pattern_factory* (:class:`~collections.abc.Callable`) is the registered pattern factory. N)�superr��__init__)�selfrkr�� __class__s �r r�zAlreadyRegisteredError.__init__s,������%�%�.�.�t�_�E�E�E�E�Er"c�D�d�|j|j���S)�4 *message* (:class:`str`) is the error message. zG{name!r} is already registered for pattern factory:{pattern_factory!r}.)rkr�)�formatrkr��r�s r �messagezAlreadyRegisteredError.message s.�� S� Y� Y� � ��'� Z� � �r"c��|jdS)zB *name* (:class:`str`) is the name of the registered pattern. r��argsr�s r rkzAlreadyRegisteredError.name*s�� ��1��r"c��|jdS)za *pattern_factory* (:class:`~collections.abc.Callable`) is the registered pattern factory. rr�r�s r r�z&AlreadyRegisteredError.pattern_factory1��� ��1��r")r�� __module__� __qualname__�__doc__r&r rrr��propertyr�rkr�� __classcell__�r�s@r r�r� s���������� F� � F��V�H�g�-�.� F� � F� F� F� F� F� F� ��c���� �(�� ��3���� �(��  ��h��x��'8�9���� �(�����r"r�c���eZdZdZdedededdf�fd� Zedefd���Zedefd ���Zedefd ���Z edefd ���Z �xZ S) rizN The :exc:`RecursionError` exception is raised when recursion is detected. rcrdrer$Nc�\��tt|���|||��dS)a+ Initializes the :exc:`RecursionError` instance. *real_path* (:class:`str`) is the real path that recursion was encountered on. *first_path* (:class:`str`) is the first path encountered for *real_path*. *second_path* (:class:`str`) is the second path encountered for *real_path*. N)r�rir�)r�rcrdrer�s �r r�zRecursionError.__init__@s-���$�����&�&�y�*�k�J�J�J�J�Jr"c��|jdS)zx *first_path* (:class:`str`) is the first path encountered for :attr:`self.real_path <RecursionError.real_path>`. rr�r�s r rdzRecursionError.first_pathTr�r"c�P�d�|j|j|j���S)r�zDReal path {real!r} was encountered at {first!r} and then {second!r}.)�real�first�second)r�rcrdrer�s r r�zRecursionError.message\s3�� P� V� V� �� �� � � W� � �r"c��|jdS)zV *real_path* (:class:`str`) is the real path that recursion was encountered on. rr�r�s r rczRecursionError.real_pathgr�r"c��|jdS)zz *second_path* (:class:`str`) is the second path encountered for :attr:`self.real_path <RecursionError.real_path>`. r}r�r�s r rezRecursionError.second_pathor�r") r�r�r�r�r&r�r�rdr�rcrer�r�s@r riri:s��������� K� �K��K�� K�  � K�K�K�K�K�K�( ������ �(�� ��c���� �(�� ������ �(�� ��#���� �(�����r"riT)�frozenc�R�eZdZUdZdZeed< eeed< ee ed<dS)� CheckResultze The :class:`CheckResult` class contains information about the file and which pattern matched it. )r,r/r3r,r/r3N) r�r�r�r�� __slots__r�__annotations__r�bool�intrr"r r�r�xs`��������� �� ����� �4�.����� �� �����r"r�c�2�eZdZdZdZdeeddfd�ZdS)r8z> The :class:`.MatchDetail` class contains information about rKr+r$Nc��||_dS)z� Initialize the :class:`.MatchDetail` instance. *patterns* (:class:`~collections.abc.Sequence` of :class:`~pathspec.pattern.Pattern`) contains the patterns that matched the file in the order they were encountered. NrK)r�r+s r r�zMatchDetail.__init__�s���$�-��r")r�r�r�r�r�rrr�rr"r r8r8�sL�������� ���h�w�/��D������r"c ��eZdZdZdZdededejdejddf d �Zdd e e de fd �Z dd e e de fd �Z de fd �Z dd e e dejfd�ZdS)rUzR The :class:`.TreeEntry` class contains information about a file-system entry. ��_lstatrkr#�_statrkr#�lstatrlr$Nc�D�||_ ||_ ||_ ||_dS)aP Initialize the :class:`.TreeEntry` instance. *name* (:class:`str`) is the base name of the entry. *path* (:class:`str`) is the relative path of the entry. *lstat* (:class:`os.stat_result`) is the stat result of the direct entry. *stat* (:class:`os.stat_result`) is the stat result of the entry, potentially linked. Nr�)r�rkr#r�rls r r�zTreeEntry.__init__�s?��*!&�$�+�� �$�)���$�)�� $�$�*��r"rTc�\�|�d}|r|jn|j}tj|j��S)a< Get whether the entry is a directory. *follow_links* (:class:`bool` or :data:`None`) is whether to follow symbolic links. If this is :data:`True`, a symlink to a directory will result in :data:`True`. Default is :data:`None` for :data:`True`. Returns whether the entry is a directory (:class:`bool`). NT)r�r�rl�S_ISDIR�st_mode�r�rTrws r r'zTreeEntry.is_dir��4�����<�(�9�d�j�j�d�k�)� ��i�'� (� (�(r"c�\�|�d}|r|jn|j}tj|j��S)aE Get whether the entry is a regular file. *follow_links* (:class:`bool` or :data:`None`) is whether to follow symbolic links. If this is :data:`True`, a symlink to a regular file will result in :data:`True`. Default is :data:`None` for :data:`True`. Returns whether the entry is a regular file (:class:`bool`). NT)r�r�rl�S_ISREGr�r�s r rozTreeEntry.is_file�r�r"c�>�tj|jj��S)zC Returns whether the entry is a symbolic link (:class:`bool`). )rl�S_ISLNKr�r�r�s r rnzTreeEntry.is_symlinks�� ��d�k�)� *� *�*r"c�*�|�d}|r|jn|jS)a9 Get the cached stat result for the entry. *follow_links* (:class:`bool` or :data:`None`) is whether to follow symbolic links. If this is :data:`True`, the stat result of the linked file will be returned. Default is :data:`None` for :data:`True`. Returns that stat result (:class:`os.stat_result`). NT)r�r�)r�rTs r rlzTreeEntry.stat s"�����<�#� 4������4r"rF)r�r�r�r�r�r&r(� stat_resultr�rr�r'rornrlrr"r rUrU�s �������� 1��)� �)� �)� �� )� �� )�  � )�)�)�)�V)�)����)�$�)�)�)�)� )�)��$��)�4�)�)�)�)� +��+�+�+�+� 5� 5�h�t�n� 5��� 5� 5� 5� 5� 5� 5r"rF)NN)Br�r(�os.path�pathlibrrl�sysr��collections.abcrr;rrO� dataclassesrr�typingrrr r r r r rrrrrrr4r� version_infor&�StrPathrr�altsepr�r��Pathr*r�r�r5rCrLrQrmr^r[r{r�r�r0r�r�r�r�� Exceptionr�rir��objectr8rUrr"r �<module>r�s���� � � � ������������� � � � � � � � ������������� � � � � � � � � � � � �����������������������������������" � � � � � ���v��� ��h�s�m�#� $��� ��h�� �� �7�:�W� -� -� -������v�r�y�!����� ���� ����#�����$� �E�#�w�,�'� (�� �� �8�D�>�8�C�=� (�)�����> $�+�+� �G� �+��� �+��t�n�+� �#�}� �� +�+�+�+�\� �G� �� �%��W� � ������(P��P��P�P�P�P�26� $� [� [�� [� �H�g�Y��_�-� .� [���~� [��k�� [� [� [� [�FN� �N� �N� �C��H�~�N� �W�I�t�O� $� N� � N� �k�� N�N�N�N�f26� $����� �H�g�Y��_�-� .����~���c�]� ����>L�L�L�L� #�� #��6�(�G�*;�!<� #� #� #� #���'�*��#��$�����(� �G� ���� �� ��X�����F*.�%�%��%� �j��o� &�%� �%�%�%�%�T*.�"�"����"� �j��o� &�"� �#�t�G�}� ��"�"�"�"�P!�.�.� �.��F�8�W�,�-�.� �D�>�.� � .�.�.�.�@,�,�,�,�,�Y�,�,�,�^;�;�;�;�;�Y�;�;�;�| ��$���������'�(�#������>�����&����2g5�g5�g5�g5�g5��g5�g5�g5�g5�g5r"
Memory