| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import ast | 5 import ast |
| 6 import collections | 6 import collections |
| 7 import contextlib | 7 import contextlib |
| 8 import copy | 8 import copy |
| 9 import functools | 9 import functools |
| 10 import itertools | 10 import itertools |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 return False | 348 return False |
| 349 return self._proto_file == other._proto_file | 349 return self._proto_file == other._proto_file |
| 350 | 350 |
| 351 | 351 |
| 352 class Package(object): | 352 class Package(object): |
| 353 """Package represents a loaded package, and contains path and dependency | 353 """Package represents a loaded package, and contains path and dependency |
| 354 information. | 354 information. |
| 355 | 355 |
| 356 This is accessed by loader.py through RecipeDeps.get_package. | 356 This is accessed by loader.py through RecipeDeps.get_package. |
| 357 """ | 357 """ |
| 358 def __init__(self, name, repo_spec, deps, recipes_dir): | 358 def __init__(self, name, repo_spec, deps, repo_root, recipes_dir): |
| 359 self.name = name | 359 self.name = name |
| 360 self.repo_spec = repo_spec | 360 self.repo_spec = repo_spec |
| 361 self.deps = deps | 361 self.deps = deps |
| 362 self.repo_root = repo_root |
| 362 self.recipes_dir = recipes_dir | 363 self.recipes_dir = recipes_dir |
| 363 | 364 |
| 364 def __repr__(self): | 365 def __repr__(self): |
| 365 return '<Package(name=%r,repo_spec=%r,deps=%r,recipes_dir=%r)>' % ( | 366 return '<Package(name=%r,repo_spec=%r,deps=%r,recipes_dir=%r)>' % ( |
| 366 self.name, self.repo_spec, self.deps, self.recipes_dir) | 367 self.name, self.repo_spec, self.deps, self.recipes_dir) |
| 367 | 368 |
| 368 @property | 369 @property |
| 369 def recipe_dirs(self): | 370 def recipe_dirs(self): |
| 370 return [os.path.join(self.recipes_dir, 'recipes')] | 371 return [os.path.join(self.recipes_dir, 'recipes')] |
| 371 | 372 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 'Package specs do not match: %s vs %s' % | 624 'Package specs do not match: %s vs %s' % |
| 624 (repo_spec, self._packages[project_id].repo_spec)) | 625 (repo_spec, self._packages[project_id].repo_spec)) |
| 625 self._packages[project_id] = None | 626 self._packages[project_id] = None |
| 626 | 627 |
| 627 deps = {} | 628 deps = {} |
| 628 for dep, dep_repo in sorted(package_spec.deps.items()): | 629 for dep, dep_repo in sorted(package_spec.deps.items()): |
| 629 deps[dep] = self._create_package(dep_repo, allow_fetch) | 630 deps[dep] = self._create_package(dep_repo, allow_fetch) |
| 630 | 631 |
| 631 package = Package( | 632 package = Package( |
| 632 project_id, repo_spec, deps, | 633 project_id, repo_spec, deps, |
| 634 repo_spec.repo_root(self._context), |
| 633 os.path.join(repo_spec.repo_root(self._context), | 635 os.path.join(repo_spec.repo_root(self._context), |
| 634 package_spec.recipes_path)) | 636 package_spec.recipes_path)) |
| 635 | 637 |
| 636 self._packages[project_id] = package | 638 self._packages[project_id] = package |
| 637 return package | 639 return package |
| 638 | 640 |
| 639 # TODO(luqui): Remove this, so all accesses to packages are done | 641 # TODO(luqui): Remove this, so all accesses to packages are done |
| 640 # via other packages with properly scoped deps. | 642 # via other packages with properly scoped deps. |
| 641 def get_package(self, package_id): | 643 def get_package(self, package_id): |
| 642 return self._packages[package_id] | 644 return self._packages[package_id] |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 >>> d = { 'x': 1, 'y': 2 } | 727 >>> d = { 'x': 1, 'y': 2 } |
| 726 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) | 728 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) |
| 727 [('x', 1), ('y', 3), ('z', 4)] | 729 [('x', 1), ('y', 3), ('z', 4)] |
| 728 >>> sorted(d.items()) | 730 >>> sorted(d.items()) |
| 729 [('x', 1), ('y', 2)] | 731 [('x', 1), ('y', 2)] |
| 730 """ | 732 """ |
| 731 | 733 |
| 732 d = copy.copy(d) | 734 d = copy.copy(d) |
| 733 d.update(updates) | 735 d.update(updates) |
| 734 return d | 736 return d |
| OLD | NEW |