� ,�Re�5���dZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z Gd�d��Z d �Z Gd �d e��Zejfd �Zd �Zdd�ZdS)zsdistutils.filelist Provides the FileList class, used for poking about the filesystem and building lists of files. �N��� convert_path)�DistutilsTemplateError�DistutilsInternalError)�logc�n�eZdZdZdd�Zd�Zejfd�Zd�Z d�Z d�Z d �Z d �Z d �Zd �Zdd�Zdd�ZdS)�FileLista�A list of files built by on exploring the filesystem and filtered by applying various patterns to what we find there. Instance attributes: dir directory from which files will be taken -- only used if 'allfiles' not supplied to constructor files list of filenames currently being built/filtered/manipulated allfiles complete list of files under consideration (ie. without any filtering applied) Nc�"�d|_g|_dS�N)�allfiles�files)�self�warn� debug_prints ��/builddir/build/BUILDROOT/alt-python311-setuptools-65.6.3-2.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/setuptools/_distutils/filelist.py�__init__zFileList.__init__ s���� ��� � � �c��||_dSr )r )rr s r� set_allfileszFileList.set_allfiles&s �� �� � � rc�.�t|��|_dSr )�findallr )r�dirs rrzFileList.findall)s���� � �� � � rc�8�ddlm}|rt|��dSdS)z~Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true. r)�DEBUGN)�distutils.debugr�print)r�msgrs rrzFileList.debug_print,s7�� *�)�)�)�)�)� � � �#�J�J�J�J�J� � rc�:�|j�|��dSr )r�append)r�items rr zFileList.append7s�� � ���$�����rc�:�|j�|��dSr )r�extend)r�itemss rr#zFileList.extend:s�� � ���%� � � � � rc���tttjj|j����}g|_|D]-}|j�tjj|����.dSr )�sorted�map�os�path�splitrr �join)r�sortable_files� sort_tuples r�sortz FileList.sort=sa����B�G�M�4�:� >� >�?�?���� �(� 9� 9�J� �J� � �b�g�l�J�7� 8� 8� 8� 8� 9� 9rc��tt|j��dz dd��D])}|j||j|dz kr|j|=�*dS)Nrr�����)�range�lenr)r�is r�remove_duplicateszFileList.remove_duplicatesFsZ���s�4�:����*�A�r�2�2� "� "�A��z�!�}�� �1�q�5� 1�1�1��J�q�M�� "� "rc��|���}|d}dx}x}}|dvr:t|��dkrtd|z���d�|dd�D��}n�|dvrOt|��dkrtd |z���t|d��}d �|dd�D��}nQ|d vr;t|��dkrtd |z���t|d��}ntd |z���||||fS)Nr)�include�exclude�global-include�global-exclude�z&'%s' expects ...c�,�g|]}t|����S�r��.0�ws r� z1FileList._parse_template_line..Y���;�;�;�A� �Q���;�;�;rr)�recursive-include�recursive-exclude�z,'%s' expects ...c�,�g|]}t|����Sr<rr=s rr@z1FileList._parse_template_line..`rAr)�graft�prunez#'%s' expects a single zunknown action '%s')r*r2rr)r�line�words�action�patternsr� dir_patterns r�_parse_template_linezFileList._parse_template_lineNsM��� � � � ���q���'+�+��+�3�� �O� O� O��5�z�z�A�~�~�,�<�v�E����<�;��q�r�r��;�;�;�H�H� �A� A� A��5�z�z�A�~�~�,�B�V�K�����u�Q�x�(�(�C�;�;��q�r�r��;�;�;�H�H� �)� )� )��5�z�z�Q���,�9�F�B����'�u�Q�x�0�0�K�K�(�)>��)G�H�H� H���#�{�3�3rc��|�|��\}}}}|dkr^|�dd�|��z��|D].}|�|d���st jd|���/dS|dkr^|�dd�|��z��|D].}|�|d���st jd |���/dS|d kr^|�d d�|��z��|D].}|�|d ���st jd |���/dS|dkr^|�dd�|��z��|D].}|�|d ���st jd|���/dS|dkrr|�d�|d�|������|D]1}|�||���sd}t j|||���2dS|dkrp|�d�|d�|������|D]/}|�||���st jd||���0dS|dkrH|�d|z��|�d|���st jd|��dSdS|dkrH|�d|z��|�d|���st jd|��dSdStd|z���)Nr6zinclude � r)�anchorz%warning: no files found matching '%s'r7zexclude z9warning: no previously-included files found matching '%s'r8zglobal-include rz>warning: no files found matching '%s' anywhere in distributionr9zglobal-exclude zRwarning: no previously-included files matching '%s' found anywhere in distributionrBzrecursive-include {} {})�prefixz:warning: no files found matching '%s' under directory '%s'rCzrecursive-exclude {} {}zNwarning: no previously-included files matching '%s' found under directory '%s'rFzgraft z+warning: no directories found matching '%s'rGzprune z6no previously-included directories found matching '%s'z'this cannot happen: invalid action '%s') rMrr+�include_patternr�warning�exclude_pattern�formatr)rrHrJrKrrL�patternrs r�process_template_linezFileList.process_template_linelsL�� 04�/H�/H��/N�/N�,���3� � �Y� � � � � �Z�#�(�(�8�*<�*<�<� =� =� =�#� R� R���+�+�G�A�+�>�>�R��K� G��Q�Q�Q�� R� R��y� � � � � �Z�#�(�(�8�*<�*<�<� =� =� =�#� � ���+�+�G�A�+�>�>���K�2� � ���� � ��'� '� '� � � �.����(�1C�1C�C� D� D� D�#� � ���+�+�G�A�+�>�>���K�7� � ���� � ��'� '� '� � � �.����(�1C�1C�C� D� D� D�#� � ���+�+�G�A�+�>�>���K�B� � ���� � ��*� *� *� � � �6�=�=�c�3�8�8�H�CU�CU�V�V� W� W� W�#� 3� 3���+�+�G�C�+�@�@�3�W���K��W�c�2�2�2��  3� 3��*� *� *� � � �6�=�=�c�3�8�8�H�CU�CU�V�V� W� W� W�#� � ���+�+�G�C�+�@�@���K�>� �� ���� � ��w� � � � � �X� �3� 4� 4� 4��'�'��[�'�A�A� X�� �I�;�W�W�W�W�W� X� X��w� � � � � �X� �3� 4� 4� 4��'�'��[�'�A�A� �� �P������� � � )�9�F�B��� rrrc�D�d}t||||��}|�d|jz��|j�|���|jD]K}|�|��r4|�d|z��|j�|��d}�L|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, False otherwise. Fz%include_pattern: applying regex r'%s'Nz adding T)�translate_patternrrVr r�searchrr )rrVrPrQ�is_regex� files_found� pattern_re�names rrRzFileList.include_pattern�s���4� �&�w����I�I� � ���@�:�CU�U�V�V�V� �=� � �L�L�N�N�N��M� #� #�D�� � ��&�&� #�� � ��d�!2�3�3�3�� �!�!�$�'�'�'�"� ���rc�T�d}t||||��}|�d|jz��tt |j��dz dd��D]O}|�|j|��r-|�d|j|z��|j|=d}�P|S)aRemove 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, False otherwise. Fz%exclude_pattern: applying regex r'%s'rr0z removing T)rYrrVr1r2rrZ)rrVrPrQr[r\r]r3s rrTzFileList.exclude_pattern�s���� �&�w����I�I� � ���@�:�CU�U�V�V�V��s�4�:����*�B��3�3� #� #�A�� � ���A��/�/� #�� � ��� �1� �!=�>�>�>��J�q�M�"� ���r)NN�rNr)�__name__� __module__� __qualname__�__doc__rrr(�curdirrrr r#r.r4rMrWrRrTr<rrr r s������� � ����� !�!�!��)�%�%�%�%���� � � �!�!�!�9�9�9�"�"�"�4�4�4��base�dirsr�files r� z#_find_all_simple.. s^������%6�T�4��QV���IM��� � �T�4� � �������r)� _UniqueDirs�filterr(�walkr)�isfile)r)� all_unique�resultss r�_find_all_simplerssZ���#�#�B�G�D�d�$C�$C�$C�D�D�J���:D����G� �"�'�.�'� *� *�*rc�.�eZdZdZd�Zed���ZdS)rmz� Exclude previously-seen dirs from walk results, avoiding infinite recursion. Ref https://bugs.python.org/issue44497. c��|\}}}tj|��}|j|jf}||v}|r|dd�=|�|��| S)z� Given an item from an os.walk result, determine if the item represents a unique dir for this instance and if not, prevent further traversal. N)r(�stat�st_dev�st_ino�add)r� walk_itemrirjrrv� candidate�founds r�__call__z_UniqueDirs.__call__sb�� &���d�E��w�t�}�}���K���,� ��T�!�� � ��Q�Q�Q�� ��������y�rc�2�t|��|��Sr )rn)�clsr$s rrnz_UniqueDirs.filter)s���c�c�e�e�U�#�#�#rN)rarbrcrdr}� classmethodrnr<rrrmrmsH�������� � � ��$�$��[�$�$�$rrmc���t|��}|tjkr5tjtjj|���}t||��}t|��S)z� Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended. )�start) rsr(re� functools�partialr)�relpathr'�list)rr�make_rels rrr.sR�� �S� !� !�E� �b�i����$�R�W�_�C�@�@�@���H�e�$�$�� ��;�;�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). �\z\\\\z\1[^%s]z((?�>�C��H�H�+D�D�E� ��f�� �6�T�>�>��C���E� � �S��_�_�s�3�x�x�-G� G�H� �&�-�-�e�Y��Z�QT�U�U� � � � K�"�)�)�%��C��J�J�L�L�1I�J�J�J� �:�j� !� !�!rr`)rdr(r�r�r��utilr�errorsrr�_logrr rs�setrmrerr�rYr<rr�r�s&����  � � � � � � � ���������������B�B�B�B�B�B�B�B�������q�q�q�q�q�q�q�q�n+�+�+�$�$�$�$�$�#�$�$�$�6� � � � � ����.""�""�""�""�""�""r