From 73eba46c0583f55e8bfc4a95cff0082fdae747c9 Mon Sep 17 00:00:00 2001 From: Sean McLaughlin Date: Tue, 15 Jul 2025 10:17:10 -0700 Subject: [PATCH] chore: add license header script and update headers --- Main.lean | 16 ++- TensorLib.lean | 16 ++- TensorLib/Basic.lean | 16 ++- TensorLib/Broadcast.lean | 16 ++- TensorLib/ByteArray.lean | 16 ++- TensorLib/Bytes.lean | 16 ++- TensorLib/Common.lean | 16 ++- TensorLib/Dtype.lean | 17 ++- TensorLib/Float.lean | 16 ++- TensorLib/Index.lean | 16 ++- TensorLib/Iterator.lean | 16 ++- TensorLib/Mgrid.lean | 16 ++- TensorLib/Npy.lean | 16 ++- TensorLib/Shape.lean | 16 ++- TensorLib/Slice.lean | 16 ++- TensorLib/Tensor.lean | 16 ++- TensorLib/Test.lean | 16 ++- TensorLib/Ufunc.lean | 16 ++- bin/license-header.txt | 13 +++ bin/update-license-headers.py | 198 ++++++++++++++++++++++++++++++++++ lakefile.lean | 16 +++ 21 files changed, 462 insertions(+), 54 deletions(-) create mode 100644 bin/license-header.txt create mode 100755 bin/update-license-headers.py diff --git a/Main.lean b/Main.lean index 46e7be7..bb8f894 100644 --- a/Main.lean +++ b/Main.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Init.System.IO diff --git a/TensorLib.lean b/TensorLib.lean index c7255e8..896e011 100644 --- a/TensorLib.lean +++ b/TensorLib.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ -- This module serves as the root of the `TensorLib` library. diff --git a/TensorLib/Basic.lean b/TensorLib/Basic.lean index bb73b13..05d7470 100644 --- a/TensorLib/Basic.lean +++ b/TensorLib/Basic.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Broadcast diff --git a/TensorLib/Broadcast.lean b/TensorLib/Broadcast.lean index 47e7c0b..8bc5b7b 100644 --- a/TensorLib/Broadcast.lean +++ b/TensorLib/Broadcast.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Aesop diff --git a/TensorLib/ByteArray.lean b/TensorLib/ByteArray.lean index 4e86fe7..b786d9c 100644 --- a/TensorLib/ByteArray.lean +++ b/TensorLib/ByteArray.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Plausible diff --git a/TensorLib/Bytes.lean b/TensorLib/Bytes.lean index 98aa56f..9d57cf6 100644 --- a/TensorLib/Bytes.lean +++ b/TensorLib/Bytes.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Common diff --git a/TensorLib/Common.lean b/TensorLib/Common.lean index a6f8e0a..a1aea3f 100644 --- a/TensorLib/Common.lean +++ b/TensorLib/Common.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Plausible diff --git a/TensorLib/Dtype.lean b/TensorLib/Dtype.lean index 78fbc7b..6c4ddf2 100644 --- a/TensorLib/Dtype.lean +++ b/TensorLib/Dtype.lean @@ -1,8 +1,19 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ + import Plausible import TensorLib.ByteArray import TensorLib.Bytes diff --git a/TensorLib/Float.lean b/TensorLib/Float.lean index b599488..bf10f43 100644 --- a/TensorLib/Float.lean +++ b/TensorLib/Float.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Plausible diff --git a/TensorLib/Index.lean b/TensorLib/Index.lean index ed10ca8..f3ee6de 100644 --- a/TensorLib/Index.lean +++ b/TensorLib/Index.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Broadcast diff --git a/TensorLib/Iterator.lean b/TensorLib/Iterator.lean index 506ec28..a9ebb57 100644 --- a/TensorLib/Iterator.lean +++ b/TensorLib/Iterator.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Common diff --git a/TensorLib/Mgrid.lean b/TensorLib/Mgrid.lean index c830c0a..27c1ec2 100644 --- a/TensorLib/Mgrid.lean +++ b/TensorLib/Mgrid.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Common diff --git a/TensorLib/Npy.lean b/TensorLib/Npy.lean index bdd5473..5c6e03d 100644 --- a/TensorLib/Npy.lean +++ b/TensorLib/Npy.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Common diff --git a/TensorLib/Shape.lean b/TensorLib/Shape.lean index c57404d..460343a 100644 --- a/TensorLib/Shape.lean +++ b/TensorLib/Shape.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Common diff --git a/TensorLib/Slice.lean b/TensorLib/Slice.lean index 3a4d3c6..aa0ccb8 100644 --- a/TensorLib/Slice.lean +++ b/TensorLib/Slice.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Aesop diff --git a/TensorLib/Tensor.lean b/TensorLib/Tensor.lean index 91a37e9..ac90384 100644 --- a/TensorLib/Tensor.lean +++ b/TensorLib/Tensor.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Batteries.Data.List -- for `toChunks` diff --git a/TensorLib/Test.lean b/TensorLib/Test.lean index 0676d9f..d5b6e2f 100644 --- a/TensorLib/Test.lean +++ b/TensorLib/Test.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import Init.System.IO diff --git a/TensorLib/Ufunc.lean b/TensorLib/Ufunc.lean index a60462b..1c57e3f 100644 --- a/TensorLib/Ufunc.lean +++ b/TensorLib/Ufunc.lean @@ -1,7 +1,17 @@ /- -Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. -Released under Apache 2.0 license as described in the file LICENSE. -Authors: Jean-Baptiste Tristan, Paul Govereau, Sean McLaughlin +Copyright TensorLib Contributors + +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 + + https://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. -/ import TensorLib.Broadcast diff --git a/bin/license-header.txt b/bin/license-header.txt new file mode 100644 index 0000000..a9edec7 --- /dev/null +++ b/bin/license-header.txt @@ -0,0 +1,13 @@ +Copyright TensorLib Contributors + +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 + + https://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. diff --git a/bin/update-license-headers.py b/bin/update-license-headers.py new file mode 100755 index 0000000..d0327aa --- /dev/null +++ b/bin/update-license-headers.py @@ -0,0 +1,198 @@ +#!/usr/bin/env python3 +""" +Script to maintain license headers in .lean files. +Removes existing license headers and adds the new one from bin/license-header.txt. +Respects .gitignore patterns. +""" + +import fnmatch +import os +import re +import sys +from pathlib import Path + + +def read_license_header(license_file_path): + """Read the license header content from the specified file.""" + try: + with open(license_file_path, 'r', encoding='utf-8') as f: + content = f.read().strip() + return content + except FileNotFoundError: + print(f"Error: License header file not found: {license_file_path}") + sys.exit(1) + + +def format_license_header(license_content): + """Format the license content with /- -/ comment syntax.""" + lines = license_content.split('\n') + formatted_lines = ['/-'] + lines + ['-/'] + return '\n'.join(formatted_lines) + '\n\n' + + +def remove_existing_license_header(content): + """Remove existing license header from the beginning of the file.""" + # Pattern to match license header block at the start of file + # Matches from start of file, optional whitespace, /-, content, -/, optional whitespace + pattern = r'^\s*/-.*?-/\s*\n*' + + # Use DOTALL flag to make . match newlines + match = re.match(pattern, content, re.DOTALL) + + if match: + # Remove the matched license header + return content[match.end():] + + return content + + +def process_lean_file(file_path, new_license_header): + """Process a single .lean file to update its license header.""" + try: + # Read the current file content + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # Remove existing license header + content_without_header = remove_existing_license_header(content) + + # Add new license header + new_content = new_license_header + content_without_header + + # Write back to file + with open(file_path, 'w', encoding='utf-8') as f: + f.write(new_content) + + print(f"Updated: {file_path}") + return True + + except Exception as e: + print(f"Error processing {file_path}: {e}") + return False + + +def read_gitignore_patterns(gitignore_path): + """Read and parse .gitignore patterns.""" + patterns = [] + if os.path.exists(gitignore_path): + with open(gitignore_path, 'r', encoding='utf-8') as f: + for line in f: + line = line.strip() + if line and not line.startswith('#'): + patterns.append(line) + return patterns + + +def is_ignored(file_path, root_dir, gitignore_patterns): + """Check if a file should be ignored based on .gitignore patterns.""" + # Get relative path from project root + try: + rel_path = os.path.relpath(file_path, root_dir) + except ValueError: + return False + + # Normalize path separators for cross-platform compatibility + rel_path = rel_path.replace(os.sep, '/') + + # Check each gitignore pattern + for pattern in gitignore_patterns: + # Remove leading slash if present (anchored to root) + if pattern.startswith('/'): + pattern = pattern[1:] + + # Handle directory patterns (ending with /) + if pattern.endswith('/'): + dir_pattern = pattern[:-1] + # Check if the path starts with the directory pattern + if rel_path.startswith(dir_pattern + '/') or rel_path == dir_pattern: + return True + # For patterns like **/__pycache__/, check any directory level + if pattern.startswith('**/'): + dir_pattern = pattern[3:-1] # Remove **/ and / + path_parts = rel_path.split('/') + for part in path_parts[:-1]: # Exclude the filename + if fnmatch.fnmatch(part, dir_pattern): + return True + else: + # Handle file patterns + if fnmatch.fnmatch(rel_path, pattern) or fnmatch.fnmatch(os.path.basename(rel_path), pattern): + return True + + return False + + +def find_lean_files(root_dir): + """Find all .lean files in the directory tree, respecting .gitignore.""" + gitignore_path = os.path.join(root_dir, '.gitignore') + gitignore_patterns = read_gitignore_patterns(gitignore_path) + + lean_files = [] + for root, dirs, files in os.walk(root_dir): + # Filter out ignored directories early to avoid walking into them + dirs_to_remove = [] + for d in dirs: + dir_path = os.path.join(root, d) + if is_ignored(dir_path, root_dir, gitignore_patterns): + dirs_to_remove.append(d) + + for d in dirs_to_remove: + dirs.remove(d) + + # Check files in current directory + for file in files: + if file.endswith('.lean'): + file_path = os.path.join(root, file) + if not is_ignored(file_path, root_dir, gitignore_patterns): + lean_files.append(file_path) + + return lean_files + + +def main(): + # Get the script directory and project root + script_dir = Path(__file__).parent + project_root = script_dir.parent + + # Path to the license header file + license_header_file = script_dir / 'license-header.txt' + + print(f"Project root: {project_root}") + print(f"License header file: {license_header_file}") + + # Read the license header content + license_content = read_license_header(license_header_file) + formatted_header = format_license_header(license_content) + + print("License header to be applied:") + print("-" * 40) + print(formatted_header) + print("-" * 40) + + # Find all .lean files + lean_files = find_lean_files(project_root) + + if not lean_files: + print("No .lean files found.") + return + + print(f"Found {len(lean_files)} .lean files:") + for file in lean_files: + print(f" {file}") + + # Ask for confirmation + response = input(f"\nProceed to update license headers in {len(lean_files)} files? (y/N): ") + if response.lower() not in ['y', 'yes']: + print("Operation cancelled.") + return + + # Process each file + success_count = 0 + for file_path in lean_files: + if process_lean_file(file_path, formatted_header): + success_count += 1 + + print(f"\nCompleted: {success_count}/{len(lean_files)} files updated successfully.") + + +if __name__ == '__main__': + main() diff --git a/lakefile.lean b/lakefile.lean index 2dab89e..09587b4 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -1,3 +1,19 @@ +/- +Copyright TensorLib Contributors + +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 + + https://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. +-/ + import Lake open Lake DSL