Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 6, 2024
1 parent 929585f commit 99eef72
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pre_commit_hooks/check_spdx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""This script checks for the presence of an SPDX-License-Identifier in the comments of source files."""
from __future__ import annotations

Expand All @@ -9,17 +8,17 @@

def _load_file(file_path: str) -> str:
try:
with open(file_path, 'r', encoding='utf-8') as f:
with open(file_path, encoding='utf-8') as f:
return f.read()
except Exception as e:
print(f"Error loading file content of {file_path}: {e}")
print(f"Error loading file content of {file_path}: {e}")


def _check_spdx(file_content: str) -> bool:
for line in file_content:
stripped_line = line.strip()
if stripped_line.startswith("#") or stripped_line.startswith("//") or re.match(r"^\s*/\*", stripped_line):
if "SPDX-License-Identifier:" in stripped_line:
if stripped_line.startswith('#') or stripped_line.startswith('//') or re.match(r'^\s*/\*', stripped_line):
if 'SPDX-License-Identifier:' in stripped_line:
return True
else:
break
Expand Down

0 comments on commit 99eef72

Please sign in to comment.