Created
August 25, 2014 21:53
-
-
Save kotcrab/f4829cebf2545f05a4f1 to your computer and use it in GitHub Desktop.
Tool for checking missing license headers
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
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