Skip to content

Instantly share code, notes, and snippets.

@siddhesh
Created August 10, 2021 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc to your computer and use it in GitHub Desktop.
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.
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