Skip to content

Instantly share code, notes, and snippets.

@kotcrab
Created August 25, 2014 21:53
Show Gist options
  • Save kotcrab/f4829cebf2545f05a4f1 to your computer and use it in GitHub Desktop.
Save kotcrab/f4829cebf2545f05a4f1 to your computer and use it in GitHub Desktop.
Tool for checking missing license headers
import fnmatch
import os
#config
main_dir = os.path.dirname(os.getcwd())
src_dir = os.path.join(main_dir, 'src', 'pl', 'kotcrab', 'arget')
header = os.path.join(main_dir, 'src', 'data', 'header.txt')
def contains(small, big):
if(len(small) > len(big)):
return False
for i in xrange(len(small) - 1):
if not small[i] == big[i]:
return False
return True
def process_file(file_path):
file = open(file_path)
source = file.readlines()
file.close()
if not contains(header_lines, source):
print 'WARNING: Missing header: ' + file_path
f = open(header)
header_lines = f.readlines()
f.close()
for root, dirnames, filenames in os.walk(main_dir):
for filename in fnmatch.filter(filenames, '*.java'):
process_file(os.path.join(root, filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment