(check_files)
| 74 | |
| 75 | # Check the files for the presence of a valid year in the header |
| 76 | def check_files(check_files): |
| 77 | queries, failures = query_files(check_files) |
| 78 | |
| 79 | current_year = datetime.datetime.now().year |
| 80 | |
| 81 | missing = [] |
| 82 | outdated = {} |
| 83 | |
| 84 | for filename, tokens in queries.items(): |
| 85 | if not tokens: |
| 86 | missing.append(filename) |
| 87 | continue |
| 88 | |
| 89 | outdated[filename] = None |
| 90 | |
| 91 | for token in tokens: |
| 92 | copyright_years = re.findall(YEAR_PATTERN, token) |
| 93 | |
| 94 | most_recent_year = int(copyright_years[-1]) if copyright_years else 0 |
| 95 | |
| 96 | if most_recent_year != current_year: |
| 97 | if not outdated[filename]: |
| 98 | outdated[filename] = [] |
| 99 | outdated[filename].append(token) |
| 100 | |
| 101 | outdated = {k: v for k, v in outdated.items() if v is not None} |
| 102 | return missing, outdated, failures |
| 103 | |
| 104 | def fix(file): |
| 105 | queries, failures = query_files([file]) |
no test coverage detected