self.line_num = 0\r
self.state = START\r
self.new_bin = []\r
- self.LicenseCheck(self.lines, self.count)\r
while self.line_num < self.count and self.format_ok:\r
line_num = self.line_num\r
self.run()\r
assert(self.line_num > line_num)\r
self.report_message_result()\r
\r
- def LicenseCheck(self, lines, count):\r
- self.ok = True\r
- self.startcheck = False\r
- self.license = True\r
- line_index = 0\r
- for line in lines:\r
- if line.startswith('--- /dev/null'):\r
- nextline = lines[line_index + 1]\r
- added_file = self.Readdedfileformat.search(nextline).group(1)\r
- added_file_extension = os.path.splitext(added_file)[1]\r
- if added_file_extension in self.file_extension_list:\r
- self.startcheck = True\r
- self.license = False\r
- if self.startcheck and self.license_format_preflix in line:\r
- if self.bsd2_patent in line or self.bsd3_patent in line:\r
- self.license = True\r
- else:\r
- for optional_license in self.license_optional_list:\r
- if optional_license in line:\r
- self.license = True\r
- self.warning(added_file)\r
- if line_index + 1 == count or lines[line_index + 1].startswith('diff --') and self.startcheck:\r
- if not self.license:\r
- error_message = "Invalid License in: " + added_file\r
- self.error(error_message)\r
- self.startcheck = False\r
- self.license = True\r
- line_index = line_index + 1\r
-\r
- def warning(self, *err):\r
- count = 0\r
- for line in err:\r
- warning_format = 'Warning: License accepted but not BSD plus patent license in'\r
- print(warning_format, line)\r
- count += 1\r
-\r
def report_message_result(self):\r
if Verbose.level < Verbose.NORMAL:\r
return\r
print(prefix, line)\r
count += 1\r
\r
- license_format_preflix = 'SPDX-License-Identifier'\r
-\r
- bsd2_patent = 'BSD-2-Clause-Patent'\r
-\r
- bsd3_patent = 'BSD-3-Clause-Patent'\r
-\r
- license_optional_list = ['BSD-2-Clause', 'BSD-3-Clause', 'MIT', 'Python-2.0', 'Zlib']\r
-\r
- Readdedfileformat = re.compile(r'\+\+\+ b\/(.*)\n')\r
-\r
- file_extension_list = [".c", ".h", ".inf", ".dsc", ".dec", ".py", ".bat", ".sh", ".uni", ".yaml", ".fdf", ".inc", "yml", ".asm", \\r
- ".asm16", ".asl", ".vfr", ".s", ".S", ".aslc", ".nasm", ".nasmb", ".idf", ".Vfr", ".H"]\r
-\r
class CheckOnePatch:\r
"""Checks the contents of a git email formatted patch.\r
\r