Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: android_webview/tools/webview_licenses.py

Issue 10829355: Make checking the existence of the license file optional in the license tool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused print_warnings Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/licenses.py » ('j') | tools/licenses.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Checks third-party licenses for the purposes of the Android WebView build. 6 """Checks third-party licenses for the purposes of the Android WebView build.
7 7
8 The Android tree includes a snapshot of Chromium in order to power the system 8 The Android tree includes a snapshot of Chromium in order to power the system
9 WebView. This tool checks that all code uses open-source licenses compatible 9 WebView. This tool checks that all code uses open-source licenses compatible
10 with Android, and that we meet the requirements of those licenses. It can also 10 with Android, and that we meet the requirements of those licenses. It can also
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1', 46 'MPL 1\.1 ?/ ?GPL 2(\.0)? ?/ ?LGPL 2\.1',
47 'Microsoft Limited Public License', 47 'Microsoft Limited Public License',
48 'Microsoft Permissive License', 48 'Microsoft Permissive License',
49 'Public Domain', 49 'Public Domain',
50 'SGI Free Software License B', 50 'SGI Free Software License B',
51 'X11', 51 'X11',
52 ] 52 ]
53 regex = '^(%s)$' % '|'.join(whitelist) 53 regex = '^(%s)$' % '|'.join(whitelist)
54 result = [] 54 result = []
55 for directory in _FindThirdPartyDirs(): 55 for directory in _FindThirdPartyDirs():
56 metadata = licenses.ParseDir(directory) 56 metadata = licenses.ParseDir(directory, require_license_file=False)
57 if metadata.get('License Android Compatible', 'no') == 'yes': 57 if metadata.get('License Android Compatible', 'no') == 'yes':
58 continue 58 continue
59 license = re.split(' [Ll]icenses?$', metadata['License'])[0] 59 license = re.split(' [Ll]icenses?$', metadata['License'])[0]
60 tokens = [x.strip() for x in re.split(' and |,', license) if len(x) > 0] 60 tokens = [x.strip() for x in re.split(' and |,', license) if len(x) > 0]
61 for token in tokens: 61 for token in tokens:
62 if not re.match(regex, token, re.IGNORECASE): 62 if not re.match(regex, token, re.IGNORECASE):
63 result.append(directory) 63 result.append(directory)
64 break 64 break
65 return result 65 return result
66 66
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 'third_party_files_whitelist.txt')) 186 'third_party_files_whitelist.txt'))
187 whitelisted_files = [] 187 whitelisted_files = []
188 for line in files_data.splitlines(): 188 for line in files_data.splitlines():
189 match = re.match(r'([^#\s]+)', line) 189 match = re.match(r'([^#\s]+)', line)
190 if match: 190 if match:
191 whitelisted_files.append(match.group(1)) 191 whitelisted_files.append(match.group(1))
192 return _CheckLicenseHeaders(third_party_dirs, whitelisted_files) \ 192 return _CheckLicenseHeaders(third_party_dirs, whitelisted_files) \
193 and all_licenses_valid 193 and all_licenses_valid
194 194
195 195
196 def _GenerateNoticeFile(print_warnings): 196 def GenerateNoticeFile():
197 """Generates the contents of an Android NOTICE file for the third-party code. 197 """Generates the contents of an Android NOTICE file for the third-party code.
198 Args: 198 This is used by the snapshot tool.
199 print_warnings: Whether to print warnings.
200 Returns: 199 Returns:
201 The contents of the NOTICE file. 200 The contents of the NOTICE file.
202 """ 201 """
203 202
204 third_party_dirs = _FindThirdPartyDirs() 203 third_party_dirs = _FindThirdPartyDirs()
205 204
206 # Don't forget Chromium's LICENSE file 205 # Don't forget Chromium's LICENSE file
207 content = [_ReadFile('LICENSE')] 206 content = [_ReadFile('LICENSE')]
208 207
209 # We provide attribution for all third-party directories. 208 # We provide attribution for all third-party directories.
210 # TODO(steveblock): Limit this to only code used by the WebView binary. 209 # TODO(steveblock): Limit this to only code used by the WebView binary.
211 for directory in third_party_dirs: 210 for directory in third_party_dirs:
212 license_file = licenses.ParseDir(directory)['License File'] 211 metadata = licenses.ParseDir(directory, require_license_file=False)
213 if license_file != licenses.NOT_SHIPPED: 212 license_file = metadata['License File']
213 if license_file and license_file != licenses.NOT_SHIPPED:
214 content.append(_ReadFile(license_file)) 214 content.append(_ReadFile(license_file))
215 215
216 return '\n'.join(content) 216 return '\n'.join(content)
217 217
218 218
219 def main(): 219 def main():
220 class FormatterWithNewLines(optparse.IndentedHelpFormatter): 220 class FormatterWithNewLines(optparse.IndentedHelpFormatter):
221 def format_description(self, description): 221 def format_description(self, description):
222 paras = description.split('\n') 222 paras = description.split('\n')
223 formatted_paras = [textwrap.fill(para, self.width) for para in paras] 223 formatted_paras = [textwrap.fill(para, self.width) for para in paras]
(...skipping 14 matching lines...) Expand all
238 print "This tool can only be run from the repository root." 238 print "This tool can only be run from the repository root."
239 return 1 239 return 1
240 240
241 if args[0] == 'scan': 241 if args[0] == 'scan':
242 if _Scan(): 242 if _Scan():
243 print 'OK!' 243 print 'OK!'
244 return 0 244 return 0
245 else: 245 else:
246 return 1 246 return 1
247 elif args[0] == 'notice': 247 elif args[0] == 'notice':
248 print _GenerateNoticeFile(print_warnings=False) 248 print GenerateNoticeFile()
249 return 0 249 return 0
250 250
251 parser.print_help() 251 parser.print_help()
252 return 1 252 return 1
253 253
254 if __name__ == '__main__': 254 if __name__ == '__main__':
255 sys.exit(main()) 255 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/licenses.py » ('j') | tools/licenses.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698