Last active
October 11, 2016 17:30
-
-
Save mundry/2f2d4ed6cb29b510708a to your computer and use it in GitHub Desktop.
Utility script to help find missing or obsolete source files listed in libbrotli's Makefile.am.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
# -*- coding: utf-8 -*- | |
# Utility script to help find missing or obsolete source files listed in | |
# libbrotli's Makefile.am. | |
# | |
# Usage: | |
# $ cd libbrotli | |
# $ ./libfiles.py | |
from glob import glob | |
from re import findall, MULTILINE, search | |
def diff_valuelist(varname, fpattern, content): | |
reflist = set(glob(fpattern)) | |
# Extract the list of values for the given variable from the content | |
# string. | |
m = search(r"{} = ([a-zA-Z0-9/\\_\.\s\t\n-]+)\n".format(varname), content, MULTILINE) | |
if m is None: | |
print "No values found for", varname | |
return | |
values = set(findall(r'([a-zA-Z0-9_/\.-]+)[\s\n\\]+', m.group(1), MULTILINE)) | |
missing = reflist - values | |
if len(missing) > 0: | |
print "\nMissing values in", varname | |
print "\n".join(missing) | |
obsolete = values - reflist | |
if len(obsolete) > 0: | |
print "\nObsolete values in", varname | |
print "\n".join(obsolete) | |
if __name__ == "__main__": | |
with open('Makefile.am') as fin: | |
content = fin.read() | |
diff_valuelist("DECODE", "brotli/dec/*.c", content) | |
diff_valuelist("ENCODE", "brotli/enc/*.c*", content) | |
diff_valuelist("DECODEHEADERS", 'brotli/dec/*.h', content) | |
diff_valuelist("ENCODEHEADERS", 'brotli/enc/*.h', content) | |
diff_valuelist("COMMON", 'brotli/common/*.c', content) | |
diff_valuelist("COMMONHEADERS", 'brotli/include/brotli/*.h', content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment