
    h                          S SK r S SKrS SKrS SKJr  S\R                  " 5       R
                   S3rS rS rS r	\
S:X  a  \	" 5         gg)	    N)datetimez# Copyright 2020-aN   The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
c                  H    [         R                  " SS/[         R                  SSS9n U R                  R	                  5       nU Vs/ s H  o"R                  S5      (       d  M  UPM     nnU$ s  snf ! [         R                   a  n[        SU 35        / s SnA$ SnAff = f)z1Get a list of all tracked Python files using git.gitzls-filesT)stdouttextcheckz.pyzError fetching tracked files: N)
subprocessrunPIPEr   
splitlinesendswithCalledProcessErrorprint)resultfilesfpy_fileses        P/home/james-whalen/.local/lib/python3.13/site-packages/scripts/add_copyrights.pyget_tracked_python_filesr   %   s    

 3JOORV^bc((*$:u!

5(9Au: ;(( .qc23	s6   AA3 A.$A.*A3 .A3 3B!BB!B!c                    [         R                  R                  U 5      (       d  [        SU  S35        g[	        U SS9 nUR                  5       nSSS5        SR                  W5      R                  [        5      (       a  g[        SU  S	35        [	        U S
SS9 nUR                  [        S-   SR                  U5      -   5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zECheck if the file contains a copyright notice, and add it if missing.z[SKIP] z does not exist.Nzutf-8)encoding Tz[MODIFY] Adding copyright to .w
F)
ospathisfiler   open	readlinesjoin
startswithCOPYRIGHT_HEADERwrite)	file_pathr   contents      r   check_and_add_copyrightr(   4   s    77>>)$$	{"234	i'	*a++- 
+ 
www""#344 
))A
67	iw	/1	 4'"'''*::; 
0  
+	* 
0	/ s   C+C!
C!
C/c                  T   [        5       n U (       d  [        S5        g[        S[        U 5       S35        U  Vs/ s H  n[        U5      PM     nn[	        U5      (       d"  [        S5        [
        R                  " S5        g[        S5        [
        R                  " S5        gs  snf )	zFMain function to check and add copyright for all tracked Python files.z.No Python files are tracked in the repository.Nz	Checking z% Python files for copyright notice...uI   ❌ Some files were missing the required copyright and have been updated.   u*   ✅ All files have the required copyright.r   )r   r   lenr(   allsysexit)r   r&   have_copyrights      r   mainr0   I   s    ')H>?	Ic(m_$I
JKJRS(Y-i8(NS~YZ:; Ts   B%__main__)r   r	   r-   r   nowyearr$   r   r(   r0   __name__     r   <module>r7      sY    
  
  ))<)<(= >   *$ zF r6   