Created
August 10, 2021 17:18
-
-
Save siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc to your computer and use it in GitHub Desktop.
Filter out files to feed into several regular expressions to remove "Contributed by", "Written by", etc. notices.
This file contains hidden or 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
from glibc_shared_code import get_glibc_shared_code | |
import os | |
import stat | |
import re | |
shared_code = ['./' + f for f in | |
sum(get_glibc_shared_code('SHARED-FILES').values(), [])] | |
exclude_patterns = [ | |
r'.*ChangeLog.*', | |
r'.*/tst-regex.input', | |
r'.*\.git/.*', | |
r'.*/NEWS', | |
r'.*\.data', | |
r'.*configure.ac', | |
r'.*benchtests.*', | |
r'.*CONTRIBUTED-BY', | |
r'.*po\/.*\.po', | |
r'.*build/.*'] | |
exclude_re = [re.compile(r) for r in exclude_patterns] | |
def doesnt_match(f): | |
global exclude_re | |
for r in exclude_re: | |
if r.match(f): | |
return False | |
return True | |
PATH='.' | |
result = [os.path.join(dp, f) for dp, dn, filenames in os.walk(PATH) for f in | |
filenames if stat.S_ISREG(os.stat(os.path.join(dp, f)).st_mode) and | |
not stat.S_ISLNK(os.stat(os.path.join(dp, f)).st_mode) and | |
doesnt_match(os.path.join(dp, f)) and os.path.join(dp, f) not in | |
shared_code] | |
for r in result: | |
print(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment