CVS update by matsl xemacs-builds/matsl/gplv3 ChangeLog README findgplv2

xemacs-cvs at xemacs.org xemacs-cvs at xemacs.org
Wed Jan 9 05:19:39 EST 2008


  User: matsl   
  Date: 08/01/09 11:19:39

  Added:       xemacs-builds/matsl/gplv3 ChangeLog README findgplv2
Log:
First version.

Revision  Changes    Path
1.1                  XEmacs/xemacs-builds/matsl/gplv3/ChangeLog

Index: ChangeLog
===================================================================
2008-01-09  Mats Lidell  <matsl at contactor.se>

	* findgplv2: Checked in for easier referens.





1.1                  XEmacs/xemacs-builds/matsl/gplv3/README

Index: README
===================================================================
Find files that are gplv2 or not ...



1.1                  XEmacs/xemacs-builds/matsl/gplv3/findgplv2

Index: findgplv2
===================================================================
#!/bin/env python

# Find files that are gplv2 or not ...

# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.

import sys
import os
import re

maxSearchLines = 200

# Don't recurse down these folders
ignoreDirNames = re.compile('\.|\.\.|CVS')

# Don't bother with these files at all.
ignoreFiles = re.compile('^.*\.(png|xbm|xpm)$')

gplv2 = re.compile('GNU General Public License as published by the Free Software Foundation; either version 2(| of the License), or \(at your option\) any later version\.')
lgplv2 = re.compile('GNU Library General Public License as published by the Free Software Foundation; either version 2(| of the License), or \(at your option\) any later version\.')

# Leading comment remover
leadingComment = re.compile('^\s*[*#;]+')

def removeLeadingComment(s):
    m = leadingComment.match(s)
    if m:
        return s[m.end(0):]
    else:
        return s

# Turn file into one long string
def fileToStr(f):
    ln = 0
    lines = []
    fp = open(f)
    for line in fp:
        l = removeLeadingComment(line[:-1])
        lines.append(l.strip())
        ln += 1
        if maxSearchLines < ln:
            break
    fp.close()
    return ' '.join(lines)

def checkGPLv2(f):
    print '"' + f + '"',
    fstr = fileToStr(f)
    if gplv2.search(fstr):
        print 'GPLv2'
    elif lgplv2.search(fstr):
        print 'LGPLv2'
    else:
        print '?'
        
def findFiles(p):
    for f in os.listdir(p):
        if ignoreFiles.match(f) or ignoreDirNames.match(f):
            continue

        fn = os.path.join(p, f)
        if os.path.isdir(fn):
            findFiles(fn)
            continue
        
        checkGPLv2(fn)
    
findFiles('.')





More information about the XEmacs-CVS mailing list