Skip to content

Commit 2f69e59

Browse files
authored
Update update_lisences.py (camel-ai#379)
1 parent 2431c4e commit 2f69e59

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

licenses/update_license.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import os
1515
import re
1616
import sys
17+
from pathlib import Path
1718
from typing import List
1819

1920

@@ -86,19 +87,20 @@ def update_license_in_directory(
8687
raise FileNotFoundError(f'{license_template_path} not found')
8788

8889
file_count = 0
89-
for root, _, files in os.walk(directory_path):
90-
for file_name in files:
91-
if file_name.endswith('.py'):
92-
file_path = os.path.join(root, file_name)
93-
if update_license_in_file(
94-
file_path,
95-
license_template_path,
96-
start_line_start_with,
97-
end_line_start_with,
98-
):
99-
file_count += 1
90+
for py_files in Path(directory_path).rglob("*.py"):
91+
if py_files.name.startswith('.'):
92+
continue
93+
if any(part.startswith('.') for part in py_files.parts):
94+
continue
95+
if update_license_in_file(
96+
py_files,
97+
license_template_path,
98+
start_line_start_with,
99+
end_line_start_with,
100+
):
101+
file_count += 1
100102

101-
print(f'Licensed update in {file_count} files')
103+
print(f'License updated in {file_count} files')
102104

103105

104106
if __name__ == '__main__':

0 commit comments

Comments
 (0)