Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/__pycache__/files.cpython-311.pyc
�
�܋f�K�� �UdZddlmZddlZddlZddlZddlZddlZddlZddl Z ddl
mZmZm
Z
mZmZmZddlmZddlmZddlmZmZmZee��Zdad ed
<iaded<d=d�Zd>d�Zd?d�Zd?d�ZdZ d?d�Z!ej"riZ#ded<iZ$ded<d@d�Z%nd@d�Z%d@d�Z&dAd�Z'dBd �Z(d?d!�Z)dCd"�Z*dDd&�Z+Gd'�d(��Z,Gd)�d*��Z-Gd+�d,��Z.dEd.�Z/d/�d0D��Z0dFd2�Z1 dGdHd7�Z2Gd8�d9��Z3dId<�Z4e��dS)JzFile wrangling.�)�annotationsN)�Callable�Dict�Iterable�List�Optional�Tuple)�env)�ConfigError)�human_sorted�isolate_module�
join_regex��str�RELATIVE_DIRzDict[str, str]�CANONICAL_FILENAME_CACHE�return�Nonec���ttj��}|�tj��s|tjz}tj�|��aiadS)z?Set the directory that `relative_filename` will be relative to.N) �abs_file�os�curdir�endswith�sep�path�normcaserr)�
abs_curdirs �a/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/coverage/files.py�set_relative_directoryrs\��
�"�)�$�$�J����r�v�&�&�)��"�&�(�
��7�#�#�J�/�/�L� "����c��tS)z=Return the directory that `relative_filename` is relative to.)r�r r�relative_directoryr#/s���r �filenamec��tj�|��}|�t��r|tt��d�}|S)z�Return the relative form of `filename`.
The file name will be relative to the current directory when the
`set_relative_directory` was called.
N)rrr�
startswithr�len)r$�fnorms r�relative_filenamer)4sL��
�G���X�&�&�E�����%�%�0��C��-�-�.�.�/���Or c��|tvr�|}tj�|��sytjgt
jzD]^}|��tj�||��} tj�|��}n#t$rd}YnwxYw|r|}n�_t|��}|t|<t|S)zzReturn a canonical file name for `filename`.
An absolute path with no redundant components and normalized case.
NF)
rrr�isabsr�sys�join�exists�UnicodeErrorr)r$�cfr�fr.s r�canonical_filenamer2As����/�/�/�
���w�}�}�X�&�&� ����c�h�.�
�
���<���G�L�L��x�0�0��#��W�^�^�A�.�.�F�F��#�#�#�#�"�F�F�F�#�������B��E���b�\�\��-/� ��*�#�H�-�-s�+B�B�B�dc��tj|��\}}|rItjd|�d�������dd�}d|�d�}nd}||�dd��zS) a7A base for a flat file name to correspond to this file.
Useful for writing files about the code where you want all the files in
the same directory, but need to differentiate same-named files from
different directories.
For example, the file a/b/c.py will return 'd_86bbcbe134d28fd2_c_py'
�sha3_256zUTF-8N��d_�_r�.)�ntpath�split�hashlib�new�encode� hexdigest�replace)r$�dirname�basename�fp�prefixs r�
flat_rootnamerE\s�����X�.�.��G�X���
�[��W�^�^�G�%<�%<�
=�
=�
G�
G�
I�
I�#�2�#�
N���b���������H�$�$�S�#�.�.�.�.r �_ACTUAL_PATH_CACHEzDict[str, List[str]]�_ACTUAL_PATH_LIST_CACHErc�H�|tvr
t|Stj�|��\}}|s|���}n�|s|}n�t|��}|tvrt|}n2 tj|��}n#t$rg}YnwxYw|t|<tj� |��}|D])}tj� |��|kr|}n�*tj�
||��}|t|<|S)z:Get the actual path of `path`, including the correct case.)rFrrr;�upper�actual_pathrG�listdir� Exceptionrr-)r�head�tail�actpath�files�normtailr1s rrJrJts9���%�%�%�%�d�+�+��W�]�]�4�(�(�
��d�� /��j�j�l�l�G�G�� /��G�G��t�$�$�D��.�.�.�/��5�����J�t�,�,�E�E�� �����E�E�E�����16�'��-��w�'�'��-�-�H��
�
���7�#�#�A�&�&�(�2�2��D��E�3��g�l�l�4��.�.�G�#*��4� ��s�<B�B �B c��|S)z*The actual path for non-Windows platforms.r"�rs rrJrJ�s���r c��ttj�tj�|������S)z.Return the absolute normalized form of `path`.)rJrr�abspath�realpathrSs rrr�s.���r�w���r�w�'7�'7��'=�'=�>�>�?�?�?r �Optional[Tuple[str, str]]c��dD]W}|�|t|��z��\}}}|r*||z}tj�|��r||fcS�XdS)z�Split a filename into a zipfile / inner name pair.
Only return a pair if the zipfile exists. No check is made if the inner
name is in the zipfile.
)z.zipz.whlz.eggz.pexN)� partitionrrrr.)r$�ext�zipbase� extension�inner�zipfiles r�zip_locationr_�su��0�&�&��$,�$6�$6�s�S��]�]�7J�$K�$K�!���E�� &���m�G��w�~�~�g�&�&�
&���~�%�%�%���4r �boolc�j�tj�|��rdSt|��rdSdS)z'Determine if a source file path exists.TF)rrr.r_rSs r�
source_existsrb�s9�� �w�~�~�d�����t��D�����t��5r c�f�tjjrtj�|��}|S)z:Return the string as Python would describe this file name.)r
�
PYBEHAVIOR�report_absolute_filesrrrU�r$s r�python_reported_filerg�s'��
�~�+�-��7�?�?�8�,�,���Or c�R�tj|��ptj|��S)z)Is `filename` an absolute path on any OS?)r:r+� posixpathrfs r�isabs_anywhererj�s!���<��!�!�>�Y�_�X�%>�%>�>r �patterns�
Iterable[str]� List[str]c��g}|pgD]N}|�|��|�d��s"|�t|�����O|S)aPrepare the file patterns for use in a `GlobMatcher`.
If a pattern starts with a wildcard, it is used as a pattern
as-is. If it does not start with a wildcard, then it is made
absolute with the current directory.
If `patterns` is None, an empty list is returned.
)�*�?)�appendr&r)rk�prepped�ps r�
prep_patternsrt�s`���G�
�^��(�(�����q�����|�|�J�'�'� (��N�N�8�A�;�;�'�'�'���Nr c�4�eZdZdZddd �Zdd
�Zdd�Zdd�ZdS)�TreeMatcherz�A matcher for files in a tree.
Construct with a list of paths, either files or directories. Paths match
with the `match` method if they are one of the files, or if they are
somewhere in a subtree rooted at one of the directories.
�unknown�pathsrl�namerrrc�^�t|��|_d�|D��|_||_dS)Nc�L�g|]!}tj�|����"Sr")rrr)�.0rss r�
<listcomp>z(TreeMatcher.__init__.<locals>.<listcomp>�s(��9�9�9�a�b�g�&�&�q�)�)�9�9�9r )r�original_pathsrxry)�selfrxrys r�__init__zTreeMatcher.__init__�s2��)5�e�)<�)<���9�9�5�9�9�9��
��� � � r c�(�d|j�d|j�d�S)Nz
<TreeMatcher � �>)ryr~�rs r�__repr__zTreeMatcher.__repr__�s ��C�t�y�C�C�4�+>�C�C�C�Cr rmc��|jS�z4A list of strings for displaying when dumping state.)r~r�s r�infozTreeMatcher.info�s���"�"r �fpathr`c���tj�|��}|jD]F}|�|��r/||krdS|t|��tjkrdS�GdS)z1Does `fpath` indicate a file in one of our trees?TF)rrrrxr&r'r)rr�rss r�matchzTreeMatcher.match�sr���� � ��'�'���� � �A�����"�"�
��A�:�:��4�4���Q���=�B�F�*�*��4�4���ur N�rw)rxrlryrrr�rr�rrm�r�rrr`��__name__�
__module__�__qualname__�__doc__r�r�r�r�r"r rrvrv�sw�������������D�D�D�D�#�#�#�#������r rvc�4�eZdZdZddd �Zdd
�Zdd�Zdd�ZdS)�
ModuleMatcherz A matcher for modules in a tree.rw�module_namesrlryrrrc�<�t|��|_||_dS�N)�list�modulesry)rr�rys rr�zModuleMatcher.__init__�s���L�)�)����� � � r c�(�d|j�d|j�d�S)Nz<ModuleMatcher r�r�)ryr�r�s rr�zModuleMatcher.__repr__s��>���>�>�T�\�>�>�>�>r rmc��|jSr�)r�r�s rr�zModuleMatcher.infos
���|�r �module_namer`c��|sdS|jD]<}|�|��r%||krdS|t|��dkrdS�=dS)z<Does `module_name` indicate a module in one of our packages?FTr9)r�r&r')rr��ms rr�zModuleMatcher.match
sk��� ��5��� � �A��%�%�a�(�(�
��!�#�#��4�4��s�1�v�v�&�#�-�-��4�4���ur Nr�)r�rlryrrrr�r�)r�rrr`r�r"r rr�r��so������*�*������?�?�?�?�����
�
�
�
�
�
r r�c�4�eZdZdZddd �Zdd
�Zdd�Zdd�ZdS)�GlobMatcherz)A matcher for files by file name pattern.rw�patsrlryrrrc��t|��|_t|jtj���|_||_dS)N)�case_insensitive)r�r��globs_to_regexr
�WINDOWS�rery)rr�rys rr�zGlobMatcher.__init__s2����J�J�� � ���S�[�I�I�I����� � � r c�(�d|j�d|j�d�S)Nz
<GlobMatcher r�r�)ryr�r�s rr�zGlobMatcher.__repr__!s��9�t�y�9�9�4�9�9�9�9�9r rmc��|jSr�)r�r�s rr�zGlobMatcher.info$s
���y�r r�r`c�:�|j�|��duS)z1Does `fpath` match one of our file name patterns?N)r�r�)rr�s rr�zGlobMatcher.match(s���w�}�}�U�#�#�4�/�/r Nr�)r�rlryrrrr�r�r�r�r"r rr�r�so������3�3������
:�:�:�:�����0�0�0�0�0�0r r��sc�^�tjd|��}|r |d}ntj}|S)z?Find the path separator used in this string, or os.sep if none.�[\\/]r)r��searchrr)r�� sep_match�the_seps rrr-s2��� �(�A�&�&�I����A�,����&���Nr c�@�g|]\}}tj|��|f��Sr")r��compile)r|�rx�subs rr}r}9s5�������S��
�2����$���r ))z\*\*\*+N)z
[^/]+\*\*+N)z
\*\*+[^/]+N)z \*\*/\*\*N)z^\*+/�(.*[/\\\\])?)z/\*+$z [/\\\\].*)z\*\*/r�)�/z[/\\\\])z\*z [^/\\\\]*)z\?z[^/\\\\])z\[.*?\]�\g<0>)z[a-zA-Z0-9_-]+r�)z[\[\]]N)r9z\\\g<0>�patternc��|�dd��}d|vrd|z}g}d}|t|��kr�tD]v\}}|�||���}|rX|�t d|d�����|�|�|����|���}n�w|t|��k��d�|��S) z.Convert a file-path glob pattern into a regex.�\r�z**/r)�posNzFile pattern can't include r) r@r'�G2RX_TOKENSr�rrq�expand�endr-)r��path_rxr�r�r�r�s r�_glob_to_regexr�Js����o�o�d�C�(�(�G�
�'����'�/���G�
�C�
��G���
�
�"� � �G�B������c��*�*�A��
��;�%�&L�A�a�D�&L�&L�M�M�M����q�x�x��}�}�-�-�-��e�e�g�g����
���G���
�
��7�7�7���r Fr��partial�re.Pattern[str]c��d}|r|tjz}ttt|����}|sd|�d�}tj||���}|S)a{Convert glob patterns to a compiled regex that matches any of them.
Slashes are always converted to match either slash or backslash, for
Windows support, even when running elsewhere.
If the pattern has no slash or backslash, then it is interpreted as
matching a file name anywhere it appears in the tree. Otherwise, the glob
pattern must match the whole file path.
If `partial` is true, then the pattern will match if the target string
starts with the pattern. Otherwise, it must match the entire string.
Returns: a compiled regex object. Use the .match method to compare target
strings.
rz(?:z)\Z)�flags)r��
IGNORECASEr�mapr�r�)rkr�r�r�r��compileds rr�r�^sb��*
�E���
����� �C���1�1� 2� 2�B���
�B�^�^�^���z�"�E�*�*�*�H��Or c�<�eZdZdZ ddd
�Zdd�Zdd�Zefdd�ZdS)�PathAliasesa�A collection of aliases for paths.
When combining data files from remote machines, often the paths to source
code are different, for example, due to OS differences, or because of
serialized checkouts on continuous integration machines.
A `PathAliases` object tracks a list of pattern/result pairs, and can
map a path through those aliases to produce a unified path.
NF�debugfn�Optional[Callable[[str], None]]�relativer`rrc�D�g|_|pd�|_||_d|_dS)Nc��dS)Nrr")�msgs r�<lambda>z&PathAliases.__init__.<locals>.<lambda>�s��q�r F)�aliasesr�r��pprinted)rr�r�s rr�zPathAliases.__init__�s-��@B����1�=�=��� ��
���
�
�
r c ��|�d|j�d���|jD])\}}}|�d|�d|�d|j�����*dS)z;Dump the important parts of the PathAliases, for debugging.zAliases (relative=z):z Rule: � -> �
using regex N)r�r�r�r�)r�original_pattern�regex�results r�pprintzPathAliases.pprint�s|�����;�$�-�;�;�;�<�<�<�/3�|� e� e�+��e�V��L�L�c�#3�c�c�6�c�c�RW�R_�c�c�d�d�d�d� e� er r�rr�c��|}t|��}t|��dkr|�d��}|�d��rt d���|js6|�d��s!t||z��st|��}|�|��s||z
}t|gdd���}t|��}|�d��|z}|j
�|||f��dS)a�Add the `pattern`/`result` pair to the list of aliases.
`pattern` is an `glob`-style pattern. `result` is a simple
string. When mapping paths, if a path starts with a match against
`pattern`, then that match is replaced with `result`. This models
isomorphic source trees being rooted at different places on two
different machines.
`pattern` can't end with a wildcard component, since that would
match an entire tree, and not just its root.
�z\/roz$Pattern must not end with wildcards.T)r�r�N)rr'�rstriprrr�r&rjrr�r�rq)rr�r�r��pattern_sepr��
result_seps r�addzPathAliases.add�s!��#���'�l�l���w�<�<�!����n�n�U�+�+�G����C� � � F��D�E�E�E��}� ,��%�%�c�*�*�
,�>�'�K�BW�3X�3X�
,�"�7�+�+������,�,� #��{�"�G���y�4��N�N�N����[�[�
����u�%�%�
�2������-�u�f�=�>�>�>�>�>r rr.�Callable[[str], bool]c
���|js|���d|_|jD�]!\}}}|�|��}|�r|�|d|��}|�t|��t|����}|jst|��}|�d��ot|��dk}|�d��r|s
|dd�}||��s#|�
d|�d|�d|�d �d
z����|�
d|�d|�d
|�d�d|��z��|cS��#|jr�t|��s�tj
d|��} t| ��dkr�| d}
d|
���dtj|
���d�}|
�tj��}t!�fd�|jD����sd|�
d��d
|�d|����|j��tj|��|f��|�||���S|�
d|�d���|S)a�Map `path` through the aliases.
`path` is checked against all of the patterns. The first pattern to
match is used to replace the root of the path with the result root.
Only one pattern is ever used. If no patterns match, `path` is
returned unchanged.
The separator style in the result is made to match that of the result
in the alias.
`exists` is a function to determine if the resulting path actually
exists.
Returns the mapped path. If a mapping has happened, this is a
canonical path. If no mapping has happened, it is the original value
of `path` unchanged.
Tr)z./z.\�NzRule z changed z to r�zwhich doesn't exist, continuingz
Matched path z to rule r�z, z
producing z[/\\]r�z*/z^(.*[\\/])?r�c3�,�K�|]\}}}|�kV��dSr�r")r|rsr8r�s �r� <genexpr>z"PathAliases.map.<locals>.<genexpr>�s-�����D�D�G�A�q�!�1��<�D�D�D�D�D�Dr zGenerating rule: r�)r.zNo rules match, path z
is unchanged)r�r�r�r�r@rr�r2r&r'r�rjr�r;�escaper�anyrqr�r�)
rrr.r�r�r�r�r=� dot_start�parts�dir1� regex_patr�s
@rr�zPathAliases.map�s����&�}� !��K�K�M�M�M� �D�M�/3�|� � �+��e�V����D�!�!�A��
��l�l�1�Q�4��0�0���k�k�#�d�)�)�S��[�[�9�9���}�2�,�S�1�1�C�"�-�-�m�<�<�P��V���q�� ��>�>�-�0�0�"��"��a�b�b�'�C��v�c�{�{���L�L�Q� 0�Q�Q�T�Q�Q��Q�Q�Q�9�:��������Y�D�Y�Y�5E�Y�Y�V�Y�Y�Y�(��(�(�)�����
�
�
�%
�,�=� 9���!5�!5� 9��H�X�t�,�,�E��5�z�z�A�~�~��Q�x��%�t�+�+��A�2�9�T�?�?�A�A�A� � �*�"�&�*�*���D�D�D�D�t�|�D�D�D�D�D�9��L�L�_�G�_�_�6�_�_�R[�_�_�����L�'�'��"�*�Y�2G�2G��(P�Q�Q�Q��8�8�D��8�8�8�8����B�T�B�B�B�C�C�C��r )NF)r�r�r�r`rr�rr)r�rr�rrr)rrr.r�rr) r�r�r�r�r�r�r�rbr�r"r rr�r�}s������� � �48�� � � � � �e�e�e�e�%?�%?�%?�%?�N=J�@�@�@�@�@�@�@r r�rA�include_namespace_packagesc#�K�ttj|����D]W\}\}}}|s|dkr
d|vr|dd�=�|D]9}tjd|��r"tj�||��V��:�XdS)a|Yield all of the importable Python files in `dirname`, recursively.
To be importable, the files have to be in a directory with a __init__.py,
except for `dirname` itself, which isn't required to have one. The
assumption is that `dirname` was specified directly, so the user knows
best, but sub-directories are checked for a __init__.py to be sure we only
find the importable files.
If `include_namespace_packages` is True, then the check for __init__.py
files is skipped.
Files with strange characters are skipped, since they couldn't have been
imported, and are probably editor side-files.
rz__init__.pyNz^[^.#~!$@%^&*()+=,]+\.pyw?$)� enumerater�walkr�r�rr-)rAr��i�dirpath�dirnames� filenamesr$s r�find_python_filesr�s����� .7�r�w�w�7G�7G�-H�-H�6�6�)��)�G�X�y�)� ��1�u�u��i�7�7��Q�Q�Q�K��!� 6� 6�H��x�6��A�A�
6��g�l�l�7�H�5�5�5�5�5�� 6�6�6r r�r�)r$rrr)rrrr)r$rrrW)rrrr`)r$rrr`)rkrlrrm)r�rrr)r�rrr)FF)rkrlr�r`r�r`rr�)rArr�r`rrl)5r��
__future__rr<r:r�os.pathrir�r,�typingrrrrrr �coverager
�coverage.exceptionsr�
coverage.miscrr
rr�__annotations__rrr#r)r2�MAX_FLATrEr�rFrGrJrr_rbrgrjrtrvr�r�rr�r�r�r�r�r"r r�<module>r�s������"�"�"�"�"�"�����
�
�
�
� � � � ��������� � � � �
�
�
�
�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�B�������+�+�+�+�+�+�B�B�B�B�B�B�B�B�B�B��^�B����������+-��-�-�-�-�"�"�"�"�$����
�
�
�
�.�.�.�.�2��/�/�/�/�&�;�(�)+��+�+�+�+�46��6�6�6�6������B����
@�@�@�@�
�
�
�
�
�
�
�
�����?�?�?�?�
����$ � � � � � � � �F��������:0�0�0�0�0�0�0�0�&������5�����"����,#�������>C�C�C�C�C�C�C�C�L6�6�6�6�@������r