--- a/build/buildutils/checkcopyrights.py Mon Oct 04 11:29:25 2010 +0300
+++ b/build/buildutils/checkcopyrights.py Fri Oct 15 12:29:39 2010 +0300
@@ -24,9 +24,39 @@
import sys, os, re
+
# Specify here the file types to be checked
checkedFileTypes = [".cpp", ".h", ".java", ".py", ".mk"]
+# Specify here the directories to be ignored relative to the root
+ignoredRootDirs = [
+ "javaextensions/bluetooth/bluecove", # Bluecove
+ "javacommons/jvms/j9/s60/inc", # IBM J9
+ "javauis/eswt_akn", # eSWT checked separately
+ "javauis/eswt_qt", # eSWT checked separately
+ "javauis/tsrc/fute/eswt", # eSWT checked separately
+ "javaextensions/webservices", # Webservices not delivered
+ "tools" # Tools not delivered
+ ]
+
+# Specify here the directories to be ignored everywhere
+ignoredAnyDirs = [
+ ".svn", # SVN directories
+ "internal" # Internal directories not delivered
+ ]
+
+# Specify here any individual files to be ignored relative to the root
+ignoredFiles = [
+ "javacommons/jvms/cldc_1.1.1/javasrc/java/util/Timer.java", # Apache
+ "javacommons/jvms/cldc_1.1.1/javasrc/java/util/TimerTask.java", # Apache
+ "javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTaskTest.java", # Apache
+ "javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTest.java", # Apache
+ "javacommons/utils/inc/convertutf.h", # Unicode Inc.
+ "javacommons/utils/src/convertutf.cpp", # Unicode Inc.
+ "javaextensions/ccapi/ccapiext/javasrc/com/innovision/rf/JewelTagConnection.java", # Innovision
+ "javaextensions/ccapi/ccapiext/javasrc/com/sony/felica/Type3TagConnection.java" # Sony
+]
+
# The copyright texts to be searched for
copyrightText1 = "Nokia Corporation and/or its subsidiary(-ies)"
@@ -35,72 +65,37 @@
def main():
- root = sys.argv[1]
- if root[-1] != '\\':
- root = root + '\\'
+ root = os.path.abspath(sys.argv[1])
+ rootlen = len(root) + 1
- # Include here the directories to be ignored
- ignoredDirectories = [
- root + "javaextensions\\bluetooth\\bluecove", # Bluecove
- root + "javacommons\\jvms\\j9\\s60\\inc", # IBM J9
- root + "javauis\\eswt_akn", # eSWT checked separately
- root + "javauis\\eswt_qt", # eSWT checked separately
- root + "javauis\\tsrc\\fute\\eswt\\", # eSWT checked separately
- root + "javaextensions\\webservices", # Webservices not delivered
- root + "tools", # Tools not delivered
- "\\internal" # Internal directories not delivered
- ]
-
- # Include here any individual files to be ignored
- ignoredFiles = [
- root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\Timer.java", # Apache license
- root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\TimerTask.java", # Apache license
- root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTaskTest.java", # Apache license
- root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTest.java", # Apache license
- root + "javacommons\\utils\\inc\\convertutf.h", # Unicode Inc.
- root + "javacommons\\utils\\src\\convertutf.cpp" # Unicode Inc.
- ]
+ # Preprocess the ignore lists to speed up the actual checking
+ rootDirsToIgnore = map(os.path.normpath, ignoredRootDirs)
+ filesToIgnore = map(os.path.normpath, ignoredFiles)
-
def visitFun(arg, dirname, names):
- # Skip SVN directories
- if dirname.find("\\.svn") != -1:
- return
-
- # Skip all the directories to be ignored
- for dir in ignoredDirectories:
- if dirname.find(dir) != -1:
+ # Skip the ignored directories
+ if os.path.split(dirname)[1] in ignoredAnyDirs or \
+ dirname[rootlen:] in rootDirsToIgnore:
names[:] = []
- # print "Ignoring directory", dirname
return
# Check then the files
for f in names:
- fname = dirname + "\\" + f
+ fname = os.path.join(dirname, f)
- # Skip directories
- if os.path.isdir(fname):
+ # Skip directories and ignored files
+ if os.path.isdir(fname) or fname[rootlen:] in filesToIgnore:
continue
-
- # Skip ignored files
- found = False
- for file in ignoredFiles:
- if fname.find(file) != -1:
- # print "Ignoring file", fname
- found = True
- break
- if found:
- continue
-
+
# Skip non-wanted file types
lastDot = f.rfind(".")
if lastDot == -1 or not f[lastDot:] in checkedFileTypes:
- # print "Ignoring file", f
continue
-
+
# Check if the file contains the copyright texts
+ found = False
try:
file = open(fname)