|
|
|
|
|
|
new_file_name = os.path.join(tempdir, os.path.basename(filename)) |
|
|
|
with open(new_file_name, "w+") as new_file: |
|
|
|
# default to match everything if there is nothing in the ALLOW_LIST |
|
|
|
allow_list_pattern = ALLOW_LIST.get(filename, MATCH_ANY) |
|
|
|
allow_list_pattern = ALLOW_LIST.get(filename, None) |
|
|
|
keep_line |= allow_list_pattern.search(line) is not None |
|
|
|
keep_line |= ( |
|
|
|
allow_list_pattern is not None |
|
|
|
and allow_list_pattern.search(line) is not None |
|
|
|
) |
|
|
|
|
|
|
|
if keep_line: |
|
|
|
new_file.write(line) |
|
|
|