7 with open('WHENCE', encoding='utf-8') as whence:
9 match = re.match(r'(?:File|Source):\s*"(.*)"', line)
13 match = re.match(r'(?:File|Source):\s*(\S*)', line)
17 match = re.match(r'Licen[cs]e: (?:.*\bSee (.*) for details\.?|(\S*))\n',
21 for name in re.split(r', | and ', match.group(1)):
25 # Just one word - may or may not be a filename
26 if not re.search(r'unknown|distributable', match.group(2),
32 with os.popen('git ls-files') as git_files:
33 for line in git_files:
34 yield line.rstrip('\n')
38 whence_list = list(list_whence())
39 known_files = set(name for name in whence_list if not name.endswith('/')) | \
40 set(['check_whence.py', 'configure', 'Makefile',
41 'README', 'copy-firmware.sh', 'WHENCE'])
42 known_prefixes = set(name for name in whence_list if name.endswith('/'))
43 git_files = set(list_git())
45 for name in sorted(list(known_files - git_files)):
46 sys.stderr.write('E: %s listed in WHENCE does not exist\n' % name)
49 for name in sorted(list(git_files - known_files)):
50 # Ignore subdirectory changelogs and GPG detached signatures
51 if (name.endswith('/ChangeLog') or
52 (name.endswith('.asc') and name[:-4] in known_files)):
55 # Ignore unknown files in known directories
56 for prefix in known_prefixes:
57 if name.startswith(prefix):
60 sys.stderr.write('E: %s not listed in WHENCE\n' % name)
64 if __name__ == '__main__':