o
    }oi"                     @   s`   d Z ddlZddlZddlZddlmZ ddlmZ dgZdd Zdd	 Z	e
d
kr.e	  dS dS )z/A script to check that copyright headers exists    N)datetime)Pathzscripts/get_commonvoice_data.pyc                 C   sb   g }t | D ]\}}|dv rq|dr|| qd|v r  nqg }|D ]	}|| |  q%|S )N) 
r   z
#import)	enumerate
startswithappend)_datalines_to_extractilinecomments r   P/home/ubuntu/.local/lib/python3.10/site-packages/tests/check_copyright_header.pyget_top_comments   s   
r   c               	   C   s  t jdd} | jdddtd |  }tt j}d}d}t	|d	d
d}|
 d}t|}W d    n1 s;w   Y  g }t|jdD ]}	t|	tv rSqJt	t|	d	d
d}| }
W d    n1 skw   Y  t|
}
t|
|k rt|	 d ||	 qJd}t|
D ]\}}ttdtj|rd}d}t||d D ]-}|d j|d}||
| v rd} n|d}|d d |d  }||
| v rd} nq|s||	 t|	 d  n=d|
| v r|d7 }d|
| v std|D ]!}|| |
|| d  vr||	 t|	 d||    nq|r" nq|s2t|	 d ||	 qJt|dkrOtd |D ]}t| q@td d S d S )Nz+Usage for copyright header insertion script)descriptionz--dirzTPath to source files to add copyright header to. Will recurse through subdirectoriesT)helprequiredtypei  ztests/py_cprheader.txtrzutf-8)encodingr   z*.pyz2 has less header lines than the copyright templateFzCopyright.*NVIDIA.*   r   )CURRENT_YEAR.z & AFFILIATES.z had an error with the yearopyrightz missed the line: z/ did not match the regex: `Copyright.*NVIDIA.*`z\check_copyright_headers.py found the following files that might not have a copyright header:)argparseArgumentParseradd_argumentstr
parse_argsintr   todayyearopenreadsplitlenr   dirrglob
EXCLUSIONS	readlinesr   printr   r	   researchcompile
IGNORECASErangeformatsysexit)parserargscurrent_yearstarting_yearpython_header_pathoriginalpyheaderpyheader_linesproblematic_filesfilenamedatafoundr   r   	year_goodr%   	year_lineyear_line_affj_filer   r   r   main/   s   






rH   __main__)__doc__r   r/   r5   r   pathlibr   r,   r   rH   __name__r   r   r   r   <module>   s   H
