� L�gO1����dZddlZddlZddlmZmZmZddlmZddl m Z dZ dZ Gd �d e ��ZGd �d e ��Zejd e��Gd�de��Zejde��dS)z� This module implements Git's wildmatch pattern matching which itself is derived from Rsync's wildmatch. Git uses wildmatch for its ".gitignore" files. �N)�AnyStr�Optional�Tuple�)�util)� RegexPattern�latin1�ps_dc��eZdZdZdS)�GitWildMatchPatternErrorzW The :class:`GitWildMatchPatternError` indicates an invalid git wild match pattern. N)�__name__� __module__� __qualname__�__doc__���n/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/pathspec/patterns/gitwildmatch.pyr r s���������rr c��eZdZdZdZededeeeee ffd���Z e de de fd���Z e dedefd���Zd S) �GitWildMatchPatternzX The :class:`GitWildMatchPattern` class represents a compiled Git wildmatch pattern. r�pattern�returnc�X�t|t��rt}nJt|t��r"t}|�t��}nt d|�d����|}|�d��r|���}n|���}|� d��rd}d}�n@|dkrd}d}�n4|�r-|� d��r d}|d d�}nd }d}|� d��}|d  }tt|��d z d d ��D]$} || d z } || } | d kr | d kr|| =�%t|��dkr|d d kr|d s dt�d�}|d s|d =nRt|��d kst|��dkr+|d s#|d d kr|�d d ��n |std|�����|d st|��d krd |d <|���dg} d} t|��d z }t!|��D�]�\} } | d kr�| d kr| |kr| �d���.| d kr| �d��d} �L| |kr7|r| �dt�d����s| �d����| �d��d } ��| dkrS| r| �d��| �d��| |kr| �dt�d���d } ��| r| �d�� | �|�| ����n%#t&$r}td|����|�d}~wwxYw| |kr| �dt�d���d } ���| �d��d�| ��}n|}nd}d}|�#|tur|�t��}||fS)a Convert the pattern into a regular expression. *pattern* (:class:`str` or :class:`bytes`) is the pattern to convert into a regular expression. Returns the uncompiled regular expression (:class:`str`, :class:`bytes`, or :data:`None`); and whether matched files should be included (:data:`True`), excluded (:data:`False`), or if it is a null-operation (:data:`None`). zpattern:�! is not a unicode or byte string.z\ �#N�/�!F�T�����rz**rz^.+(?P<z>/).*$zInvalid git pattern: �^z [^/]+(?:/.*)?z(?:.+/)?z(?P<z>/).*z/.*z(?:/.+)?�*z[^/]+z(?:(?P<z>/).*)?�$�)� isinstance�str�bytes�decode�_BYTES_ENCODING� TypeError�endswith�lstrip�strip� startswith�split�range�len� _DIR_MARK�insertr � enumerate�append�_translate_segment_glob� ValueError�join�encode)�clsr� return_type�original_pattern�regex�include�override_regex� pattern_segs�is_dir_pattern�i�prev�seg�output� need_slash�end�es r�pattern_to_regexz$GitWildMatchPattern.pattern_to_regex-s �������L��;�;��'�5�!�!�L��;� �^�^�O� ,� ,�7�7� �J�g�J�J�J� K� K�K��� ���e�����^�^� � �7�7� �]�]�_�_�7� ������a� �5� �7�7��#�~�~� �5� �7�7��T� ��������G��a�b�b�k�G�G��G��>��-�-��$�$�<�%�R�(�(�>� �#�l�#�#�a�'��B� /� /���q� ��!�� �D� �q�/�C� �t�|�|��t� � � �a��� �,���1����a��D�!8�!8��a��!8�1�y�0�0�0�N� �q�/� � �Q��� �L���Q���3�|�#4�#4��#9�#9�,�q�/�#9� �A��$�������D�!�!�!��  � �Q� #�#O�;K�#O�#O� P� P�P� �r� ��s�<�0�0�1�4�4� �L������U�F��J� �l� � �a� �C��L�)�)�:�:���3� �t� � � �a���A��H�H��}�}�%�&�&�&�&� ��6�6��}�}�Z� � � ��z�z� ��8�8� ��� � �-�Y�-�-�-�.�.�.�.�� � �f����� �}�}�Z� � � ��z�z� ��*�*� �� �}�}�S���� �m�m�G���� �c����}�}�1�y�1�1�1�2�2�2��j�j� �� �}�}�S����[� �}�}�S�0�0��5�5�6�6�6�6�� �[�[�[� %�&R�>N�&R�&R� S� S�YZ�Z�����[���� �c����}�}�1�y�1�1�1�2�2�2��j�j� �M�M�#���� �G�G�F�O�O�E�E� �E�E� �5� �7� ��;�%�/�/� �<�<�� (� (�5� ���s�(N� N&�N!�!N&c���d}d}dt|��}}||k�r>||}|dz }|rd}|tj|��z }�n |dkrd}�n|dkr|dz }n�|d kr|d z }n�|d kr�|}||kr||d ks ||d kr|dz }||kr||dkr|dz }||kr#||dkr|dz }||kr ||dk�||kr]|dz }d }||d kr |d z }|dz }n||d kr |d z }|dz }||||��dd��z }||z }|}n|dz }n|tj|��z }||k��>|rt d|�����|S)a Translates the glob pattern to a regular expression. This is used in the constructor to translate a path segment glob pattern to its corresponding regular expression. *pattern* (:class:`str`) is the glob pattern. Returns the regular expression (:class:`str`). Fr"rr�\Tr z[^/]*�?z[^/]�[rr�]z\\z\[z9Escape character found with no next character to escape: )r/�re�escape�replacer5)rrNr;r@rE�char�j�exprs rr4z+GitWildMatchPattern._translate_segment_glob�s#�� �&� �%� �c�'�l�l�S�!� �C��� �!�*�4���6�1� �R� �F� �R�Y�t�_�_��E�E� �� � � �F�F� �� � � �W��E�E� �� � � �V�O�E�E� �� � � �A� �3�w�w�G�A�J�#�%�%����s�):�):��!�V�Q� �3�w�w�7�1�:��$�$��!�V�Q� �c�'�'�g�a�j�C�'�'��!�V�Q� �c�'�'�g�a�j�C�'�'� �3�w�w��!�V�Q� �T��� �c��� �c�k�d��1�f�a�a� �!�*�� � �  �c�k�d��1�f�a� �W�Q�q�S�\� !� !�$�� /� /�/�T� �d�]�U� �Q�Q�  �e�^�U�U� �R�Y�t�_�_��E�o �C���r �]� �[�PW�[�[� \� \�\� �,r�sc�f��t|t��r t}|}nJt|t��r"t}|�t��}nt d|�d����d�d��fd�|D����}|tur|�t��S|S)z� Escape special characters in the given string. *s* (:class:`str` or :class:`bytes`) a filename or a string that you want to escape, usually before adding it to a ".gitignore". Returns the escaped string (:class:`str` or :class:`bytes`). zs:rz[]!*#?r"c3�.�K�|]}|�vrd|zn|V��dS)rINr)�.0�x�meta_characterss �r� <genexpr>z-GitWildMatchPattern.escape.<locals>.<genexpr>zs5�����O�O�1�1��#7�#7�t�a�x�x�Q�O�O�O�O�O�Or)r#r$r%r&r'r(r6r7)rSr9�string� out_stringrXs @rrNzGitWildMatchPattern.escapeds������3���@��;� �6�6��!�U���@��;� �H�H�_� %� %�6�6� �>��>�>�>� ?� ?�?��/��w�w�O�O�O�O��O�O�O�O�O�*��E��� � � �O� ,� ,�,� �rN)r rrr� __slots__� classmethodrrr�boolrG� staticmethodr$r4rNrrrrr$s��������� �� �E� �E� �H�V� �h�t�n� ,�-�E�E�E��+�E�N�l�c�l�c�l�l�l��,�l�\��v��&�����,���rr� gitwildmatchc�V��eZdZdZd�fd� Zedd���Ze�fd���Z�xZ S)�GitIgnorePatternz� The :class:`GitIgnorePattern` class is deprecated by :class:`GitWildMatchPattern`. This class only exists to maintain compatibility with v0.4. rNc�p��|���tt|��j|i|��dS)� Warn about deprecation. N)� _deprecated�superrb�__init__)�self�args�kw� __class__s �rrgzGitIgnorePattern.__init__�s@���������(�%��$���(�$�5�"�5�5�5�5�5rc�>�tjdtd���dS)rdz_GitIgnorePattern ('gitignore') is deprecated. Use GitWildMatchPattern ('gitwildmatch') instead.�)� stacklevelN)�warnings�warn�DeprecationWarningrrrrezGitIgnorePattern._deprecated�s1��  �-���A�'�'�'�'�'�'rc�l��|���tt|��j|i|��S)rd)rerfrbrG)r8rirjrks �rrGz!GitIgnorePattern.pattern_to_regex�s8��� �/�/���� 6���� %� %� 6�� C�� C� C�Cr)rN) r rrrrgr_rer]rG� __classcell__)rks@rrbrb�s���������� 6�6�6�6�6�6��'�'�'��,�'��D�D�D�D��+�D�D�D�D�Drrb� gitignore)rrMro�typingrrrr"rrrr'r0r5r r�register_patternrbrrr�<module>rwsX����  � � � ��������������� ������"�"�"�"�"�"���� � �� �����z����[�[�[�[�[�,�[�[�[�z ���n�&9�:�:�:�D�D�D�D�D�*�D�D�D�B���k�#3�4�4�4�4�4r
Memory