Spaces:
Running
Running
File size: 1,052 Bytes
f3270e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
"""Test for python files copyright headers."""
from datetime import datetime
from pathlib import Path
def test_copyright_header():
copyright_header = "".join([
f"# Copyright (C) {2021}-{datetime.now().year}, Mindee.\n\n",
"# This program is licensed under the Apache License 2.0.\n",
"# See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.\n",
])
excluded_files = ["__init__.py", "version.py"]
invalid_files = []
locations = [".github", "api/app", "demo", "docs", "doctr", "references", "scripts"]
for location in locations:
for source_path in Path(__file__).parent.parent.parent.joinpath(location).rglob("*.py"):
if source_path.name not in excluded_files:
source_path_content = source_path.read_text()
if copyright_header not in source_path_content:
invalid_files.append(source_path)
assert len(invalid_files) == 0, f"Invalid copyright header in the following files: {invalid_files}"
|