|
5 | 5 |
|
6 | 6 | import os |
7 | 7 | import logging |
| 8 | +import re |
8 | 9 | import fosslight_util.constant as constant |
9 | 10 |
|
10 | 11 | logger = logging.getLogger(constant.LOGGER_NAME) |
11 | 12 | replace_word = ["-only", "-old-style", "-or-later", "licenseref-scancode-", "licenseref-"] |
| 13 | +_notice_filename = ['licen[cs]e[s]?', 'notice[s]?', 'legal', 'copyright[s]?', 'copying*', 'patent[s]?', 'unlicen[cs]e', 'eula', |
| 14 | + '[a,l]?gpl[-]?[1-3]?[.,-,_]?[0-1]?', 'mit', 'bsd[-]?[0-4]?', 'bsd[-]?[0-4][-]?clause[s]?', |
| 15 | + 'apache[-,_]?[1-2]?[.,-,_]?[0-2]?'] |
12 | 16 | _exclude_filename = ["changelog", "config.guess", "config.sub", "changes", "ltmain.sh", |
13 | 17 | "configure", "configure.ac", "depcomp", "compile", "missing", "makefile"] |
14 | 18 | _exclude_extension = [".m4", ".in", ".po"] |
@@ -119,3 +123,10 @@ def is_exclude_file(file_path, prev_dir=None, prev_dir_exclude_value=None): |
119 | 123 | else: # running SCANOSS |
120 | 124 | return is_exclude_dir(dir_path) |
121 | 125 | return False |
| 126 | + |
| 127 | + |
| 128 | +def is_notice_file(file_path): |
| 129 | + pattern = r"({})(?<!w)".format("|".join(_notice_filename)) |
| 130 | + file_path = file_path.lower() |
| 131 | + filename = os.path.basename(file_path) |
| 132 | + return bool(re.match(pattern, filename)) |
0 commit comments