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

Side by Side Diff: tools/licenses.py

Issue 114723009: Fixes duplicate listing of third party libraries in credits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a set to avoid duplicate paths. Created 7 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 328
329 def FilterDirsWithFiles(dirs_list, root): 329 def FilterDirsWithFiles(dirs_list, root):
330 # If a directory contains no files, assume it's a DEPS directory for a 330 # If a directory contains no files, assume it's a DEPS directory for a
331 # project not used by our current configuration and skip it. 331 # project not used by our current configuration and skip it.
332 return [x for x in dirs_list if ContainsFiles(x, root)] 332 return [x for x in dirs_list if ContainsFiles(x, root)]
333 333
334 334
335 def FindThirdPartyDirs(prune_paths, root): 335 def FindThirdPartyDirs(prune_paths, root):
336 """Find all third_party directories underneath the source root.""" 336 """Find all third_party directories underneath the source root."""
337 third_party_dirs = [] 337 third_party_dirs = set()
338 for path, dirs, files in os.walk(root): 338 for path, dirs, files in os.walk(root):
339 path = path[len(root)+1:] # Pretty up the path. 339 path = path[len(root)+1:] # Pretty up the path.
340 340
341 if path in prune_paths: 341 if path in prune_paths:
342 dirs[:] = [] 342 dirs[:] = []
343 continue 343 continue
344 344
345 # Prune out directories we want to skip. 345 # Prune out directories we want to skip.
346 # (Note that we loop over PRUNE_DIRS so we're not iterating over a 346 # (Note that we loop over PRUNE_DIRS so we're not iterating over a
347 # list that we're simultaneously mutating.) 347 # list that we're simultaneously mutating.)
348 for skip in PRUNE_DIRS: 348 for skip in PRUNE_DIRS:
349 if skip in dirs: 349 if skip in dirs:
350 dirs.remove(skip) 350 dirs.remove(skip)
351 351
352 if os.path.basename(path) == 'third_party': 352 if os.path.basename(path) == 'third_party':
353 # Add all subdirectories that are not marked for skipping. 353 # Add all subdirectories that are not marked for skipping.
354 for dir in dirs: 354 for dir in dirs:
355 dirpath = os.path.join(path, dir) 355 dirpath = os.path.join(path, dir)
356 if dirpath not in prune_paths: 356 if dirpath not in prune_paths:
357 third_party_dirs.append(dirpath) 357 third_party_dirs.add(dirpath)
358 358
359 # Don't recurse into any subdirs from here. 359 # Don't recurse into any subdirs from here.
360 dirs[:] = [] 360 dirs[:] = []
361 continue 361 continue
362 362
363 # Don't recurse into paths in ADDITIONAL_PATHS, like we do with regular 363 # Don't recurse into paths in ADDITIONAL_PATHS, like we do with regular
364 # third_party/foo paths. 364 # third_party/foo paths.
365 if path in ADDITIONAL_PATHS: 365 if path in ADDITIONAL_PATHS:
366 dirs[:] = [] 366 dirs[:] = []
367 367
368 for dir in ADDITIONAL_PATHS: 368 for dir in ADDITIONAL_PATHS:
369 if dir not in prune_paths: 369 if dir not in prune_paths:
370 third_party_dirs.append(dir) 370 third_party_dirs.add(dir)
371 371
372 return third_party_dirs 372 return third_party_dirs
373 373
374 374
375 def ScanThirdPartyDirs(root=None): 375 def ScanThirdPartyDirs(root=None):
376 """Scan a list of directories and report on any problems we find.""" 376 """Scan a list of directories and report on any problems we find."""
377 if root is None: 377 if root is None:
378 root = os.getcwd() 378 root = os.getcwd()
379 third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root) 379 third_party_dirs = FindThirdPartyDirs(PRUNE_PATHS, root)
380 third_party_dirs = FilterDirsWithFiles(third_party_dirs, root) 380 third_party_dirs = FilterDirsWithFiles(third_party_dirs, root)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 elif command == 'credits': 461 elif command == 'credits':
462 if not GenerateCredits(): 462 if not GenerateCredits():
463 return 1 463 return 1
464 else: 464 else:
465 print __doc__ 465 print __doc__
466 return 1 466 return 1
467 467
468 468
469 if __name__ == '__main__': 469 if __name__ == '__main__':
470 sys.exit(main()) 470 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698