dev@glassfish.java.net

Re: Copyrights, ugh

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Mon, 7 Jun 2010 21:11:31 -0400

> Any chance of getting a list of those files?
[...]

Here's a very simple script to check. Unless you're on Windows, you
already have Python installed. Just edit the location at the top and
run 'python foo.py'. If on Windows, you may need to download it, or
you could just install the Python module for NB and it comes with
Jython. (In that case, though, I may need to add explicit calls to
close the file handles since they aren't garbage collected -- and thus
closed -- immediately).

--- begin foo.py ---
# Very simple, dumb, 'Copyright' text checker.

# edit these
startingdir = '/Users/bobby/work/ws/v3'
dirstoskip = ['.svn', 'target']
filetypes = ['.java', '.xml']
# end edits

import os.path

for (dirname, dirs, files) in os.walk(startingdir):
   for d in dirstoskip:
     if d in dirs:
       dirs.remove(d)
   for file in files:
     for ft in filetypes:
       if file.endswith(ft):
         fullpath = os.path.join(dirname, file)
         wholefileasstring = open(fullpath).read()
         if 'Copyright' not in wholefileasstring:
           print fullpath
--- end ---

For what it's worth, I catch >400 files without the word 'Copyright'
in them. Must be some false negatives, but that's still a lot. 52 of
those are pom.xml files.

Again, it's an agonizingly simple script. But it's free.

Cheers,
Bobby