� ��^i�9���dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z dgZ ej e��Zejdej��Zejd ejejz��Zejdd �ZGd �de��ZdS) zu Class representing the list of files in a distribution. Equivalent to distutils.filelist, but fixes some problems. �N�)�DistlibException)�fsdecode�� convert_path�Manifestz\\w* z#.*?(?= )| (?=$)�c�p�eZdZdZdd�Zd�Zd�Zd�Zdd�Zd �Z d �Z d �Z dd �Z dd�Z dd�Zd�ZdS)rz~A list of files built by on exploring the filesystem and filtered by applying various patterns to what we find there. Nc��tj�tj�|ptj������|_|jtjz|_d|_t��|_ dS)zd Initialise an instance. :param base: The base directory to explore under. N) �os�path�abspath�normpath�getcwd�base�sep�prefix�allfiles�set�files)�selfrs ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/distlib/manifest.py�__init__zManifest.__init__*sZ�� �G�O�O�B�G�$4�$4�T�5H�R�Y�[�[�$I�$I�J�J�� ��i�"�&�(�� ��� ��U�U�� � � �c���ddlm}m}m}gx|_}|j}|g}|j}|j}|r�|��}tj |��} | D]�} tj � || ��} tj| ��} | j } || ��r#|�t| �����k|| ��r|| ��s || ����|��dSdS)zmFind all files under the base and set ``allfiles`` to the absolute pathnames of files found. r)�S_ISREG�S_ISDIR�S_ISLNKN)�statrrrrr�pop�appendr �listdirr �join�st_moder)rrrrr�root�stackr �push�names�name�fullnamer�modes r�findallzManifest.findall9s �� 3�2�2�2�2�2�2�2�2�2�#%�%�� ���y������i���|��� #��3�5�5�D��J�t�$�$�E�� #� #���7�<�<��d�3�3���w�x�(�(���|���7�4�=�=�#��O�O�H�X�$6�$6�7�7�7�7��W�T�]�]�#�7�7�4�=�=�#��D��N�N�N��� #� #� #� #� #rc���|�|j��s%tj�|j|��}|j�tj�|����dS)zz Add a file to the manifest. :param item: The pathname to add. This can be relative to the base. N) � startswithrr r r#rr�addr)r�items rr/z Manifest.addTs[�� ���t�{�+�+� 1��7�<�<�� �4�0�0�D� � ���r�w�'�'��-�-�.�.�.�.�.rc�:�|D]}|�|���dS)z� Add a list of files to the manifest. :param items: The pathnames to add. These can be relative to the base. N)r/)r�itemsr0s r�add_manyzManifest.add_many^s.�� � � �D� �H�H�T�N�N�N�N� � rFc������fd��t�j��}|rAt��}|D]+}�|tj�|�����,||z}d�t d�|D����D��S)z8 Return sorted files in directory order c����|�|��t�d|��|�jkr6tj�|��\}}|dvsJ��||��dSdS)Nzadd_dir added %s)��/)r/�logger�debugrr r �split)�dirs�d�parent�_�add_dirrs ��rr?z Manifest.sorted..add_dirlsy��� �H�H�Q�K�K�K� �L�L�+�Q� /� /� /��D�I�~�~��G�M�M�!�,�,� ����Y�.�.�.�.����f�%�%�%�%�%��~rc�4�g|]}tjj|���S�)r r r#)�.0� path_tuples r� z#Manifest.sorted..zs3��@�@�@�j��� �j�)�@�@�@rc3�TK�|]#}tj�|��V��$dS�N)r r r:)rBr s r� z"Manifest.sorted..{s0����>�>�t�r�w�}�}�T�*�*�>�>�>�>�>�>r)rrr r �dirname�sorted)r�wantdirs�resultr;�fr?s` @rrIzManifest.sortedgs�����  &� &� &� &� &� &��T�Z���� � ��5�5�D�� 2� 2�����b�g�o�o�a�0�0�1�1�1�1� �d�N�F�@�@��>�>�v�>�>�>�>�>�@�@�@� @rc�:�t��|_g|_dS)zClear all collected files.N)rrr)rs r�clearzManifest.clear}s���U�U�� ��� � � rc��|�|��\}}}}|dkr9|D]4}|�|d���st�d|���5dS|dkr|D]}|�|d���}�dS|dkr9|D]4}|�|d���st�d|���5dS|d kr|D]}|�|d���}�dS|d kr:|D]5}|�||� ��st�d ||���6dS|d kr|D]}|�||� ��}�dS|dkr6|�d|� ��st�d|��dSdS|dkr6|�d|� ��st�d|��dSdSt d|z���)av Process a directive which either adds some files from ``allfiles`` to ``files``, or removes some files from ``files``. :param directive: The directive to process. This should be in a format compatible with distutils ``MANIFEST.in`` files: http://docs.python.org/distutils/sourcedist.html#commands �includeT)�anchorzno files found matching %r�exclude�global-includeFz3no files found matching %r anywhere in distribution�global-exclude�recursive-include)rz-no files found matching %r under directory %r�recursive-exclude�graftNz no directories found matching %r�prunez4no previously-included directories found matching %rzinvalid action %r)�_parse_directive�_include_patternr8�warning�_exclude_patternr)r� directive�action�patterns�thedir� dirpattern�pattern�founds r�process_directivezManifest.process_directive�s���04�/D�/D�Y�/O�/O�,���&�*� �Y� � �#� J� J���,�,�W�T�,�B�B�J��N�N�#?��I�I�I�� J� J��y� � �#� D� D���-�-�g�d�-�C�C��� D� D� �'� '� '�#� H� H���,�,�W�U�,�C�C�H��N�N�$>�?F�H�H�H�� H� H� �'� '� '�#� E� E���-�-�g�e�-�D�D��� E� E��*� *� *�#� J� J���,�,�W�V�,�D�D�J��N�N�$8�9@�&�J�J�J�� J� J� �*� *� *�#� F� F���-�-�g�f�-�E�E��� F� F��w� � ��(�(��j�(�A�A� +����A�)�+�+�+�+�+� +� +��w� � ��(�(��j�(�A�A� :���� -�.8�:�:�:�:�:� :� :� #�#�f�,�.�.� .rc�|�|���}t|��dkr |ddvr|�dd��|d}dx}x}}|dvr:t|��dkrtd|z���d �|dd�D��}n�|d vrOt|��d krtd |z���t |d��}d �|dd�D��}nQ|dvr;t|��dkrtd|z���t |d��}ntd|z���||||fS)z� Validate a directive. :param directive: The directive to validate. :return: A tuple of action, patterns, thedir, dir_patterns rr)rPrRrSrTrUrVrWrXrPN)rPrRrSrTr z$%r expects ...c�,�g|]}t|����SrAr�rB�words rrDz-Manifest._parse_directive..�� ��A�A�A�t� �T�*�*�A�A�Ar)rUrV�z*%r expects ...c�,�g|]}t|����SrArrgs rrDz-Manifest._parse_directive..�rir)rWrXz!%r expects a single zunknown action %r)r:�len�insertrr)rr]�wordsr^r_r`� dir_patterns rrYzManifest._parse_directive�s��� ���!�!�� �u�:�:��?�?�u�Q�x�0B� B� B� �L�L��I� &� &� &��q���*.�.��.�6�K� �:� :� :��5�z�z�A�~�~�&�:�V�C�E�E�E�B�A�u�Q�R�R�y�A�A�A�H�H� �A� A� A��5�z�z�A�~�~�&�@�6�I�K�K�K�"�%��(�+�+�F�A�A�u�Q�R�R�y�A�A�A�H�H� �)� )� )��5�z�z�Q���&�7�&�@�B�B�B�'�u�Q�x�0�0�K�K�#�#6��#?�@�@� @��x���4�4rTc���d}|�||||��}|j�|���|jD]3}|�|��r|j�|��d}�4|S)a�Select strings (presumably filenames) from 'self.files' that match 'pattern', a Unix-style wildcard (glob) pattern. Patterns are not quite the same as implemented by the 'fnmatch' module: '*' and '?' match non-special characters, where "special" is platform-dependent: slash on Unix; colon, slash, and backslash on DOS/Windows; and colon on Mac OS. If 'anchor' is true (the default), then the pattern match is more stringent: "*.py" will match "foo.py" but not "foo/bar.py". If 'anchor' is false, both of these will match. If 'prefix' is supplied, then only filenames starting with 'prefix' (itself a pattern) and ending with 'pattern', with anything in between them, will match. 'anchor' is ignored in this case. If 'is_regex' is true, 'anchor' and 'prefix' are ignored, and 'pattern' is assumed to be either a string containing a regex or a regex object -- no translation is done, the regex is just compiled and used as-is. Selected strings will be added to self.files. Return True if files are found. FNT)�_translate_patternrr,�searchrr/)rrbrQr�is_regexrc� pattern_rer)s rrZzManifest._include_patterns��8���,�,�W�f�f�h�O�O� � �=� � �L�L�N�N�N��M� � �D�� � ��&�&� �� ���t�$�$�$����� rc���d}|�||||��}t|j��D]3}|�|��r|j�|��d}�4|S)atRemove strings (presumably filenames) from 'files' that match 'pattern'. Other parameters are the same as for 'include_pattern()', above. The list 'self.files' is modified in place. Return True if files are found. This API is public to allow e.g. exclusion of SCM subdirs, e.g. when packaging source distributions FT)rq�listrrr�remove)rrbrQrrsrcrtrLs rr\zManifest._exclude_pattern)sr�����,�,�W�f�f�h�O�O� ��d�j�!�!� � �A�� � ��#�#� �� �!�!�!�$�$�$����� rc� �|r+t|t��rtj|��S|Stdkr,|�d���d��\}}}|rM|�|��}tdkr,|�|��r|�|��sJ�nd}tj tj � |j d����} |��OtdkrA|�d��} |�|��dt| �� �} nu|�|��} | �|��r| �|��sJ�| t|��t| ��t|��z �} tj} tjdkrd} tdkr!d| z| � | d|zf��z}nw|t|��t|��t|��z �}|�| �| �| �d|�|��}n3|r1tdkr d| z|z}n|�| �|t|��d���}tj|��S) aTranslate a shell-like wildcard pattern to a compiled regular expression. Return the compiled regex. If 'is_regex' true, then 'pattern' is directly compiled to a regex (if it's a string) or just returned as-is (assumes it's a regex object). )rjr r>r6N�\z\\�^z.*)� isinstance�str�re�compile�_PYTHON_VERSION� _glob_to_re� partitionr.�endswith�escaper r r#rrlr) rrbrQrrs�startr>�endrtr� empty_pattern� prefix_rers rrqzManifest._translate_pattern=s��� � ��'�3�'�'� ��z�'�*�*�*��� �V� #� #� �,�,�S�1�1�;�;�C�@�@�M�E�1�c� � ��)�)�'�2�2�J���'�'�!�,�,�U�3�3�P� �8K�8K�C�8P�8P�P�P�P���J��y�����d�i��4�4�5�5�� � ��&�(�(� $� 0� 0�� 4� 4� � �,�,�V�4�4�5I�s�=�7I�7I�6I�5I�J� � � �,�,�V�4�4� � �+�+�E�2�2�N�y�7I�7I�#�7N�7N�N�N�N�%�c�%�j�j�#�i�.�.�3�s�8�8�2K�&K�L� ��&�C��v��~�~����&�(�(� �4�Z�#�(�(�I�48�:�4E�4G�+H�+H�H� � �(��E� � �C� �O�O�c�#�h�h�4N�(N�O� �27�%���y�y�#�#�#�2<�*�c�c�C� � �� T�"�f�,�,�!$�t��j�!8�J�J�.3�e�T�T�:�c�%�j�j�k�k�;R�;R�!S�J��z�*�%�%�%rc��tj|��}tj}tjdkrd}d|z}t jd||��}|S)z�Translate a shell-like glob pattern to a regular expression. Return a string containing the regex. Differs from 'fnmatch.translate()' in that '*' does not match "special characters" (which are platform-specific). ryz\\\\z\1[^%s]z((?�>��C��s�"���V�1�7�J�G�G� ��rrF)F)TNF)�__name__� __module__� __qualname__�__doc__rr,r/r3rIrNrdrYrZr\rqr�rArrrr%s�������� � � � �#�#�#�6/�/�/����@�@�@�@�,��� I.�I.�I.�^-5�-5�-5�^=A�"'�'�'�'�'�R=A�"'�����(?C�$)�5&�5&�5&�5&�n����r)r�r��loggingr r}�sysr6r�compatr�utilr�__all__� getLoggerr�r8r~�M�_COLLAPSE_PATTERN�S�_COMMENTED_LINE� version_infor�objectrrArr�r�s�� �� �������� � � � � � � � � � � � ������������������� �,�� �� �8� $� $���B�J�z�2�4�0�0���"�*�1�2�4�"�$�;�?�?���"�2�A�2�&��d�d�d�d�d�v�d�d�d�d�dr