Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 87 |
| 88 # Directories we don't scan through. | 88 # Directories we don't scan through. |
| 89 PRUNE_DIRS = ('.svn', '.git', # VCS metadata | 89 PRUNE_DIRS = ('.svn', '.git', # VCS metadata |
| 90 'out', 'Debug', 'Release', # build files | 90 'out', 'Debug', 'Release', # build files |
| 91 'layout_tests') # lots of subdirs | 91 'layout_tests') # lots of subdirs |
| 92 | 92 |
| 93 ADDITIONAL_PATHS = ( | 93 ADDITIONAL_PATHS = ( |
| 94 # The directory with the word list for Chinese and Japanese segmentation | 94 # The directory with the word list for Chinese and Japanese segmentation |
| 95 # with different license terms than ICU. | 95 # with different license terms than ICU. |
| 96 os.path.join('third_party','icu','source','data','brkitr'), | 96 os.path.join('third_party','icu','source','data','brkitr'), |
| 97 # Fake directory so we can include the strongtalk license. | |
| 98 os.path.join('v8', 'strongtalk'), | |
| 97 ) | 99 ) |
| 98 | 100 |
| 99 | 101 |
| 100 # Directories where we check out directly from upstream, and therefore | 102 # Directories where we check out directly from upstream, and therefore |
| 101 # can't provide a README.chromium. Please prefer a README.chromium | 103 # can't provide a README.chromium. Please prefer a README.chromium |
| 102 # wherever possible. | 104 # wherever possible. |
| 103 SPECIAL_CASES = { | 105 SPECIAL_CASES = { |
| 104 os.path.join('third_party', 'angle'): { | 106 os.path.join('third_party', 'angle'): { |
| 105 "Name": "Almost Native Graphics Layer Engine", | 107 "Name": "Almost Native Graphics Layer Engine", |
| 106 "URL": "http://code.google.com/p/angleproject/", | 108 "URL": "http://code.google.com/p/angleproject/", |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 130 os.path.join('third_party', 'GTM'): { | 132 os.path.join('third_party', 'GTM'): { |
| 131 "Name": "Google Toolbox for Mac", | 133 "Name": "Google Toolbox for Mac", |
| 132 "URL": "http://code.google.com/p/google-toolbox-for-mac/", | 134 "URL": "http://code.google.com/p/google-toolbox-for-mac/", |
| 133 "License File": "COPYING", | 135 "License File": "COPYING", |
| 134 }, | 136 }, |
| 135 os.path.join('third_party', 'pdfsqueeze'): { | 137 os.path.join('third_party', 'pdfsqueeze'): { |
| 136 "Name": "pdfsqueeze", | 138 "Name": "pdfsqueeze", |
| 137 "URL": "http://code.google.com/p/pdfsqueeze/", | 139 "URL": "http://code.google.com/p/pdfsqueeze/", |
| 138 "License File": "COPYING", | 140 "License File": "COPYING", |
| 139 }, | 141 }, |
| 142 os.path.join('v8', 'strongtalk'): { | |
| 143 "Name": "Strongtalk", | |
| 144 "URL": "http://www.strongtalk.org/", | |
| 145 "License File": "/v8/LICENSE.strongtalk", | |
| 146 } | |
|
Evan Martin
2012/01/30 21:37:17
trailing comma here, I think
| |
| 140 } | 147 } |
| 141 | 148 |
| 142 class LicenseError(Exception): | 149 class LicenseError(Exception): |
| 143 """We raise this exception when a directory's licensing info isn't | 150 """We raise this exception when a directory's licensing info isn't |
| 144 fully filled out.""" | 151 fully filled out.""" |
| 145 pass | 152 pass |
| 146 | 153 |
| 147 | 154 |
| 148 def ParseDir(path): | 155 def ParseDir(path): |
| 149 """Examine a third_party/foo component and extract its metadata.""" | 156 """Examine a third_party/foo component and extract its metadata.""" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 175 | 182 |
| 176 # Check that all expected metadata is present. | 183 # Check that all expected metadata is present. |
| 177 for key, value in metadata.iteritems(): | 184 for key, value in metadata.iteritems(): |
| 178 if not value: | 185 if not value: |
| 179 raise LicenseError("couldn't find '" + key + "' line " | 186 raise LicenseError("couldn't find '" + key + "' line " |
| 180 "in README.chromium or licences.py " | 187 "in README.chromium or licences.py " |
| 181 "SPECIAL_CASES") | 188 "SPECIAL_CASES") |
| 182 | 189 |
| 183 # Check that the license file exists. | 190 # Check that the license file exists. |
| 184 for filename in (metadata["License File"], "COPYING"): | 191 for filename in (metadata["License File"], "COPYING"): |
| 192 #convert Windows-style paths to Unix-paths (work everywhere) | |
| 193 filename = filename.replace("\\","/") | |
|
Evan Martin
2012/01/30 21:37:17
Why do this?
| |
| 185 if filename.startswith('/'): | 194 if filename.startswith('/'): |
| 186 # Absolute-looking paths are relative to the source root | 195 # Absolute-looking paths are relative to the source root |
| 187 # (which is the directory we're run from). | 196 # (which is the directory we're run from). |
| 188 license_path = os.path.join(os.getcwd(), filename[1:]) | 197 license_path = os.path.join(os.getcwd(), filename[1:]) |
| 189 else: | 198 else: |
| 190 license_path = os.path.join(path, filename) | 199 license_path = os.path.join(path, filename) |
| 191 if os.path.exists(license_path): | 200 if os.path.exists(license_path): |
| 192 metadata["License File"] = license_path | 201 metadata["License File"] = license_path |
| 193 break | 202 break |
| 194 license_path = None | 203 license_path = None |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 elif command == 'credits': | 313 elif command == 'credits': |
| 305 if not GenerateCredits(): | 314 if not GenerateCredits(): |
| 306 return 1 | 315 return 1 |
| 307 else: | 316 else: |
| 308 print __doc__ | 317 print __doc__ |
| 309 return 1 | 318 return 1 |
| 310 | 319 |
| 311 | 320 |
| 312 if __name__ == '__main__': | 321 if __name__ == '__main__': |
| 313 sys.exit(main()) | 322 sys.exit(main()) |
| OLD | NEW |