OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 """Utility for checking and processing licensing information in third_party | 6 """Utility for checking and processing licensing information in third_party |
7 directories. | 7 directories. |
8 | 8 |
9 Usage: licenses.py <command> | 9 Usage: licenses.py <command> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 os.path.join('third_party', 'psutils'), | 64 os.path.join('third_party', 'psutils'), |
65 os.path.join('third_party', 'sawbuck'), | 65 os.path.join('third_party', 'sawbuck'), |
66 | 66 |
67 # Redistribution does not require attribution in documentation. | 67 # Redistribution does not require attribution in documentation. |
68 os.path.join('third_party','directxsdk'), | 68 os.path.join('third_party','directxsdk'), |
69 os.path.join('third_party','platformsdk_win2008_6_1'), | 69 os.path.join('third_party','platformsdk_win2008_6_1'), |
70 os.path.join('third_party','platformsdk_win7'), | 70 os.path.join('third_party','platformsdk_win7'), |
71 ]) | 71 ]) |
72 | 72 |
73 # Directories we don't scan through. | 73 # Directories we don't scan through. |
74 PRUNE_DIRS = ('.svn', '.git', # VCS metadata | 74 VCS_METADATA_DIRS = ('.svn', '.git') |
75 'out', 'Debug', 'Release', # build files | 75 PRUNE_DIRS = (VCS_METADATA_DIRS + |
76 'layout_tests') # lots of subdirs | 76 ('out', 'Debug', 'Release', # build files |
77 'layout_tests')) # lots of subdirs | |
77 | 78 |
78 ADDITIONAL_PATHS = ( | 79 ADDITIONAL_PATHS = ( |
79 os.path.join('breakpad'), | 80 os.path.join('breakpad'), |
80 os.path.join('chrome', 'common', 'extensions', 'docs', 'examples'), | 81 os.path.join('chrome', 'common', 'extensions', 'docs', 'examples'), |
81 os.path.join('chrome', 'test', 'chromeos', 'autotest'), | 82 os.path.join('chrome', 'test', 'chromeos', 'autotest'), |
82 os.path.join('chrome', 'test', 'data'), | 83 os.path.join('chrome', 'test', 'data'), |
83 os.path.join('googleurl'), | 84 os.path.join('googleurl'), |
84 os.path.join('native_client'), | 85 os.path.join('native_client'), |
85 os.path.join('native_client_sdk'), | 86 os.path.join('native_client_sdk'), |
86 os.path.join('net', 'tools', 'spdyshark'), | 87 os.path.join('net', 'tools', 'spdyshark'), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 metadata["Required Text"] = required_path | 322 metadata["Required Text"] = required_path |
322 else: | 323 else: |
323 raise LicenseError("Required text file listed but not found.") | 324 raise LicenseError("Required text file listed but not found.") |
324 | 325 |
325 return metadata | 326 return metadata |
326 | 327 |
327 | 328 |
328 def ContainsFiles(path, root): | 329 def ContainsFiles(path, root): |
329 """Determines whether any files exist in a directory or in any of its | 330 """Determines whether any files exist in a directory or in any of its |
330 subdirectories.""" | 331 subdirectories.""" |
331 for _, _, files in os.walk(os.path.join(root, path)): | 332 for _, dirs, files in os.walk(os.path.join(root, path)): |
332 if files: | 333 if files: |
333 return True | 334 return True |
335 for vcs_metadata in VCS_METADATA_DIRS: | |
336 if vcs_metadata in dirs: | |
337 dirs.remove(vcs_metadata) | |
Nico
2013/05/14 03:06:15
Huh, I didn't know this works!
(I checked the doc
| |
334 return False | 338 return False |
335 | 339 |
336 | 340 |
337 def FilterDirsWithFiles(dirs_list, root): | 341 def FilterDirsWithFiles(dirs_list, root): |
338 # If a directory contains no files, assume it's a DEPS directory for a | 342 # If a directory contains no files, assume it's a DEPS directory for a |
339 # project not used by our current configuration and skip it. | 343 # project not used by our current configuration and skip it. |
340 return [x for x in dirs_list if ContainsFiles(x, root)] | 344 return [x for x in dirs_list if ContainsFiles(x, root)] |
341 | 345 |
342 | 346 |
343 def FindThirdPartyDirs(prune_paths, root): | 347 def FindThirdPartyDirs(prune_paths, root): |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 elif command == 'credits': | 473 elif command == 'credits': |
470 if not GenerateCredits(): | 474 if not GenerateCredits(): |
471 return 1 | 475 return 1 |
472 else: | 476 else: |
473 print __doc__ | 477 print __doc__ |
474 return 1 | 478 return 1 |
475 | 479 |
476 | 480 |
477 if __name__ == '__main__': | 481 if __name__ == '__main__': |
478 sys.exit(main()) | 482 sys.exit(main()) |
OLD | NEW |