License checker: quiet false positive for blender_theme_as_c.py
This commit is contained in:
parent
1b508de749
commit
d1e63f89bb
@ -232,6 +232,18 @@ def check_contents(filepath: str, text: str) -> None:
|
||||
"""
|
||||
text_header = text[:EXPECT_SPDX_IN_FIRST_CHARS]
|
||||
|
||||
# Use the license to limit the copyright search,
|
||||
# so code-generation that includes copyright headers don't cause false alarms.
|
||||
license_id = " SPDX-License-Identifier: "
|
||||
license_id_beg = text_header.find(license_id)
|
||||
if license_id_beg == -1:
|
||||
# Allow completely empty files (sometimes `__init__.py`).
|
||||
if not text.rstrip():
|
||||
return
|
||||
# Empty file already accounted for.
|
||||
print("Missing {:s}{:s}".format(license_id, filepath))
|
||||
return
|
||||
|
||||
# Check copyright text, reading multiple (potentially multi-line indented) blocks.
|
||||
copyright_id = " SPDX-FileCopyrightText: "
|
||||
|
||||
@ -242,7 +254,7 @@ def check_contents(filepath: str, text: str) -> None:
|
||||
text_header,
|
||||
copyright_id,
|
||||
copyright_id_step,
|
||||
EXPECT_SPDX_IN_FIRST_CHARS,
|
||||
license_id_beg,
|
||||
)) != (-1, -1)):
|
||||
if copyright_id_end == -1:
|
||||
# Set once.
|
||||
@ -262,9 +274,6 @@ def check_contents(filepath: str, text: str) -> None:
|
||||
del copyright_id_item, copyright_id_step
|
||||
|
||||
if copyright_id_beg == -1:
|
||||
# Allow completely empty files (sometimes `__init__.py`).
|
||||
if not text.rstrip():
|
||||
return
|
||||
print("Missing {:s}{:s}".format(copyright_id, filepath))
|
||||
|
||||
# Maintain statistics.
|
||||
@ -279,13 +288,6 @@ def check_contents(filepath: str, text: str) -> None:
|
||||
if blank_lines > 0:
|
||||
print("SPDX \"{:s}\" not on first line: {:s}".format(copyright_id, filepath))
|
||||
|
||||
license_id = " SPDX-License-Identifier: "
|
||||
license_id_beg = text_header.find(license_id, copyright_id_end)
|
||||
if license_id_beg == -1:
|
||||
# Empty file already accounted for.
|
||||
print("Missing {:s}{:s}".format(license_id, filepath))
|
||||
return
|
||||
|
||||
# Leading char.
|
||||
leading_char = text_header[txt_prev_bol(text_header, license_id_beg, 0):license_id_beg].strip()
|
||||
text_blank_line = text_header[copyright_id_end:license_id_beg]
|
||||
|
Loading…
Reference in New Issue
Block a user