22 # The excluded directories should be checked every now and then |
22 # The excluded directories should be checked every now and then |
23 # so that there won't be other problems (like files without any header). |
23 # so that there won't be other problems (like files without any header). |
24 |
24 |
25 import sys, os, re |
25 import sys, os, re |
26 |
26 |
|
27 |
27 # Specify here the file types to be checked |
28 # Specify here the file types to be checked |
28 checkedFileTypes = [".cpp", ".h", ".java", ".py", ".mk"] |
29 checkedFileTypes = [".cpp", ".h", ".java", ".py", ".mk"] |
|
30 |
|
31 # Specify here the directories to be ignored relative to the root |
|
32 ignoredRootDirs = [ |
|
33 "javaextensions/bluetooth/bluecove", # Bluecove |
|
34 "javacommons/jvms/j9/s60/inc", # IBM J9 |
|
35 "javauis/eswt_akn", # eSWT checked separately |
|
36 "javauis/eswt_qt", # eSWT checked separately |
|
37 "javauis/tsrc/fute/eswt", # eSWT checked separately |
|
38 "javaextensions/webservices", # Webservices not delivered |
|
39 "tools" # Tools not delivered |
|
40 ] |
|
41 |
|
42 # Specify here the directories to be ignored everywhere |
|
43 ignoredAnyDirs = [ |
|
44 ".svn", # SVN directories |
|
45 "internal" # Internal directories not delivered |
|
46 ] |
|
47 |
|
48 # Specify here any individual files to be ignored relative to the root |
|
49 ignoredFiles = [ |
|
50 "javacommons/jvms/cldc_1.1.1/javasrc/java/util/Timer.java", # Apache |
|
51 "javacommons/jvms/cldc_1.1.1/javasrc/java/util/TimerTask.java", # Apache |
|
52 "javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTaskTest.java", # Apache |
|
53 "javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTest.java", # Apache |
|
54 "javacommons/utils/inc/convertutf.h", # Unicode Inc. |
|
55 "javacommons/utils/src/convertutf.cpp", # Unicode Inc. |
|
56 "javaextensions/ccapi/ccapiext/javasrc/com/innovision/rf/JewelTagConnection.java", # Innovision |
|
57 "javaextensions/ccapi/ccapiext/javasrc/com/sony/felica/Type3TagConnection.java" # Sony |
|
58 ] |
29 |
59 |
30 |
60 |
31 # The copyright texts to be searched for |
61 # The copyright texts to be searched for |
32 copyrightText1 = "Nokia Corporation and/or its subsidiary(-ies)" |
62 copyrightText1 = "Nokia Corporation and/or its subsidiary(-ies)" |
33 copyrightText2 = "Eclipse Public License v1.0" |
63 copyrightText2 = "Eclipse Public License v1.0" |
34 |
64 |
35 |
65 |
36 def main(): |
66 def main(): |
37 |
67 |
38 root = sys.argv[1] |
68 root = os.path.abspath(sys.argv[1]) |
39 if root[-1] != '\\': |
69 rootlen = len(root) + 1 |
40 root = root + '\\' |
|
41 |
70 |
42 # Include here the directories to be ignored |
71 # Preprocess the ignore lists to speed up the actual checking |
43 ignoredDirectories = [ |
72 rootDirsToIgnore = map(os.path.normpath, ignoredRootDirs) |
44 root + "javaextensions\\bluetooth\\bluecove", # Bluecove |
73 filesToIgnore = map(os.path.normpath, ignoredFiles) |
45 root + "javacommons\\jvms\\j9\\s60\\inc", # IBM J9 |
|
46 root + "javauis\\eswt_akn", # eSWT checked separately |
|
47 root + "javauis\\eswt_qt", # eSWT checked separately |
|
48 root + "javauis\\tsrc\\fute\\eswt\\", # eSWT checked separately |
|
49 root + "javaextensions\\webservices", # Webservices not delivered |
|
50 root + "tools", # Tools not delivered |
|
51 "\\internal" # Internal directories not delivered |
|
52 ] |
|
53 |
|
54 # Include here any individual files to be ignored |
|
55 ignoredFiles = [ |
|
56 root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\Timer.java", # Apache license |
|
57 root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\TimerTask.java", # Apache license |
|
58 root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTaskTest.java", # Apache license |
|
59 root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTest.java", # Apache license |
|
60 root + "javacommons\\utils\\inc\\convertutf.h", # Unicode Inc. |
|
61 root + "javacommons\\utils\\src\\convertutf.cpp" # Unicode Inc. |
|
62 ] |
|
63 |
74 |
64 |
|
65 def visitFun(arg, dirname, names): |
75 def visitFun(arg, dirname, names): |
66 |
76 |
67 # Skip SVN directories |
77 # Skip the ignored directories |
68 if dirname.find("\\.svn") != -1: |
78 if os.path.split(dirname)[1] in ignoredAnyDirs or \ |
69 return |
79 dirname[rootlen:] in rootDirsToIgnore: |
70 |
|
71 # Skip all the directories to be ignored |
|
72 for dir in ignoredDirectories: |
|
73 if dirname.find(dir) != -1: |
|
74 names[:] = [] |
80 names[:] = [] |
75 # print "Ignoring directory", dirname |
|
76 return |
81 return |
77 |
82 |
78 # Check then the files |
83 # Check then the files |
79 for f in names: |
84 for f in names: |
80 |
85 |
81 fname = dirname + "\\" + f |
86 fname = os.path.join(dirname, f) |
82 |
87 |
83 # Skip directories |
88 # Skip directories and ignored files |
84 if os.path.isdir(fname): |
89 if os.path.isdir(fname) or fname[rootlen:] in filesToIgnore: |
85 continue |
90 continue |
86 |
91 |
87 # Skip ignored files |
|
88 found = False |
|
89 for file in ignoredFiles: |
|
90 if fname.find(file) != -1: |
|
91 # print "Ignoring file", fname |
|
92 found = True |
|
93 break |
|
94 if found: |
|
95 continue |
|
96 |
|
97 # Skip non-wanted file types |
92 # Skip non-wanted file types |
98 lastDot = f.rfind(".") |
93 lastDot = f.rfind(".") |
99 if lastDot == -1 or not f[lastDot:] in checkedFileTypes: |
94 if lastDot == -1 or not f[lastDot:] in checkedFileTypes: |
100 # print "Ignoring file", f |
|
101 continue |
95 continue |
102 |
96 |
103 # Check if the file contains the copyright texts |
97 # Check if the file contains the copyright texts |
|
98 found = False |
104 try: |
99 try: |
105 file = open(fname) |
100 file = open(fname) |
106 |
101 |
107 # Search for the first text |
102 # Search for the first text |
108 found = False |
103 found = False |