HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/samba/tests/__pycache__/source.cpython-310.pyc
o

�/a�"�@s\dZddlZddlZddlZddlZddlZddlmZdd�Zdd�Z	Gdd	�d	e�Z
dS)
zSource level Python tests.�N)�TestCasec	cs��tj�tj�tj�t�ddd��}tj�|�sJ|��t�|�D]\}}}|D]}|�d�r;tj�tj�||��Vq(q!tj�tj�tj�t�ddddd��}tj�|�sZJ|��t�	|�D]%}tj�tj�||��}tj�
|�ssq_t�|�}tj�|��d�r�|Vq_tj�tj�tj�t�dddddd��}tj�|�s�J|��t�|�D]\}}}|D]}|�d�r�tj�tj�||��Vq�q�dS)	z%Iterate over all Python source files.z..�sambaz.py�binz
scripting/bin�
buildtools�wafsambaN)�os�path�abspath�join�dirname�__file__�isdir�walk�endswith�listdir�islink�readlink)	�library_dir�root�dirs�files�f�bindir�p�target�wafsambadir�r�4/usr/lib/python3/dist-packages/samba/tests/source.py�get_python_source_files!s8�"
��&
�(
���rccs��t�D]B}z
tj|ddd�}Wn ty0}z|jtjkr+t�d|�WYd}~q�d}~wwz
|��}W|�	�n|�	�w||fVqdS)z.Iterate over the contents of all python files.�rzutf-8)�mode�encodingzsource file %s broken link?N)
r�io�open�IOError�errno�ENOENT�warnings�warn�read�close)�fnamer�e�textrrr�get_source_file_contents<s �
��
�r.c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
TestSourcecCs�g}t�dtj�}t�D])\}}|�d�rqd|vrq|�d�r!q|�d�r'q|�|�}|s5|�|df�q|rYddg}|D]\}}|�|�|�d	|�q>|�d
�|��dSdS)z<Test that all Python files have a valid copyright statement.z#\s*copyright.*(?=
)zms_schema.pyr�"python/samba/tests/krb5/kcrypto.py�)python/samba/tests/krb5/rfc4120_pyasn1.pyzno copyright line found
z:Some files have missing or incorrect copyright statements.��    �
N)	�re�compile�Ir.r�search�append�failr
)�self�	incorrect�copyright_rer+r-�match�	help_text�commentrrr�test_copyrightPs0



��
�zTestSource.test_copyrightcCs�g}d}t�t�|�tj�}t�D]%\}}d|vrq|�d�r q|�d�r&q|�d�r,q|�|�s6|�|�q|rSd|g}|D]	}|�d|�q?|�d�	|��d	Sd	S)
z.Test that all .py files have a GPL disclaimer.a{
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
rz/python/samba/subunit/run.pyr0r1z3Some files have missing or incomplete GPL statementr3r4N)
r5r6�escape�	MULTILINEr.rr8r9r:r
)r;r<�gpl_txt�gpl_rer+r-r?rrr�test_gplqs.




���zTestSource.test_gplcCs(||vr|g||<dS||�|�dS)N)r9)r;�dict_r+�line_norrr�
_push_file�szTestSource._push_filecCs,dd�|��D�}|��|dd�|�S)NcSs,g|]\}}d|d�dd�|D��f�qS)z%s: %sz, cSsg|]}t|d��qS)�)�str)�.0�irrr�
<listcomp>�sz9TestSource._format_message.<locals>.<listcomp>.<listcomp>)r
)rLr�linesrrrrN�s �z.TestSource._format_message.<locals>.<listcomp>z

    %sz
    )�items�sortr
)r;rG�messagerrrr�_format_message�s
�zTestSource._format_messageccs>�t�D]\}}|�d�}t|�D]
\}}|||fVqqdS)NT)r.�
splitlines�	enumerate)r;r+r-rOrH�linerrr�_iter_source_files_lines�s�
��z#TestSource._iter_source_files_linescCsLi}|��D]\}}}d|vr|�|||�q|r$|�|�|d��dSdS)z-Check that there are no tabs in Python files.�	zmTab characters were found in the following source files.
They should either be replaced by "\t" or by spaces:N)rWrIr:rS)r;�tabsr+rHrVrrr�test_no_tabs�s�

��zTestSource.test_no_tabscCsXi}|��D]\}}}|�d�r|�d�r|�|||�q|r*|�|�|d��dSdS)zCheck for unix new lines.r4z
z;Non-unix newlines were found in the following source files:N)rWrrIr:rS)r;�illegal_newlinesr+rHrVrrr�test_unix_newlines�s�

��zTestSource.test_unix_newlinescCsTi}|��D]\}}}|�d��d�r|�|||�q|r(|�|�|d��dSdS)z<Check that there is not trailing whitespace in Python files.r4� z<Trailing whitespace was found in the following source files.N)rW�rstriprrIr:rS)r;�trailing_whitespacer+rHrVrrr�test_trailing_whitespace�s�

��z#TestSource.test_trailing_whitespacecCs�i}i}|��D]-\}}}|dkrqt�|�jd@}|�d�}|r*|s*|�|||�|s5|r5|�|||�q|rA|�|�|d��|rN|�|�|d��dSdS)zBCheck that files with shebang lines and only those are executable.rJ�Iz#!z0Files with shebang line that are not executable:z/Files without shebang line that are executable:N)rWr�stat�st_mode�
startswithrIr:rS)r;�files_with_shebang�files_without_shebangr+rHrV�
executable�has_shebangrrr�test_shebang_lines�s*
�
�

��zTestSource.test_shebang_linesN)�__name__�
__module__�__qualname__rArFrIrSrWrZr\r`rirrrrr/Ns!-

r/)�__doc__r"r%rr5r'�samba.testsrrr.r/rrrr�<module>s