Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import collections | 5 import collections |
| 6 import imp | 6 import imp |
| 7 import inspect | 7 import inspect |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 if _is_recipe_module_dir(subpath): | 165 if _is_recipe_module_dir(subpath): |
| 166 yield package, os.path.basename(subpath) | 166 yield package, os.path.basename(subpath) |
| 167 | 167 |
| 168 | 168 |
| 169 class UniverseView(collections.namedtuple('UniverseView', 'universe package')): | 169 class UniverseView(collections.namedtuple('UniverseView', 'universe package')): |
| 170 """A UniverseView is a way of viewing a RecipeUniverse, as seen by a package. | 170 """A UniverseView is a way of viewing a RecipeUniverse, as seen by a package. |
| 171 | 171 |
| 172 This is used mainly for dependency loading -- a package can only see modules | 172 This is used mainly for dependency loading -- a package can only see modules |
| 173 in itself and packages that it directly depends on. | 173 in itself and packages that it directly depends on. |
| 174 """ | 174 """ |
| 175 | |
| 176 @property | |
| 177 def config_file(self): | |
| 178 return self.universe.config_file | |
|
iannucci
2017/04/05 19:33:53
let's not add another undocumented property. just
| |
| 179 | |
| 175 def _dep_from_name(self, name): | 180 def _dep_from_name(self, name): |
| 176 if '/' in name: | 181 if '/' in name: |
| 177 package, module = name.split('/') | 182 package, module = name.split('/') |
| 178 return self.package.find_dep(package), module | 183 return self.package.find_dep(package), module |
| 179 else: | 184 else: |
| 180 # In current package | 185 # In current package |
| 181 return self.package, name | 186 return self.package, name |
| 182 | 187 |
| 183 def normalize_deps_spec(self, spec): | 188 def normalize_deps_spec(self, spec): |
| 184 """Takes a deps spec in either list or dict form, and converts it to | 189 """Takes a deps spec in either list or dict form, and converts it to |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 { | 230 { |
| 226 'chromium': 'build/chromium', | 231 'chromium': 'build/chromium', |
| 227 'chromiuminternal': 'build_internal/chromium', | 232 'chromiuminternal': 'build_internal/chromium', |
| 228 } | 233 } |
| 229 """ | 234 """ |
| 230 return { | 235 return { |
| 231 local_name: self.universe.load(pkg, name) | 236 local_name: self.universe.load(pkg, name) |
| 232 for local_name, (pkg, name) in self.normalize_deps_spec(spec).iteritems() | 237 for local_name, (pkg, name) in self.normalize_deps_spec(spec).iteritems() |
| 233 } | 238 } |
| 234 | 239 |
| 235 | |
| 236 def find_recipe(self, recipe): | 240 def find_recipe(self, recipe): |
| 237 if ':' in recipe: | 241 if ':' in recipe: |
| 238 module_name, example = recipe.split(':') | 242 module_name, example = recipe.split(':') |
| 239 #TODO(martinis) change to example == 'example' ? Technically a bug... | 243 #TODO(martinis) change to example == 'example' ? Technically a bug... |
| 240 assert example.endswith('example') | 244 assert example.endswith('example') |
| 241 subpath = os.path.join(self.package.module_dir, module_name) | 245 subpath = os.path.join(self.package.module_dir, module_name) |
| 242 if _is_recipe_module_dir(subpath): | 246 if _is_recipe_module_dir(subpath): |
| 243 recipe_path = os.path.join(subpath, 'example.py') | 247 recipe_path = os.path.join(subpath, 'example.py') |
| 244 else: | 248 else: |
| 245 recipe_path = os.path.join(self.package.recipe_dir, recipe)+".py" | 249 recipe_path = os.path.join(self.package.recipe_dir, recipe)+".py" |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 658 for k,v in toplevel_deps.iteritems(): | 662 for k,v in toplevel_deps.iteritems(): |
| 659 setattr(api, k, mapper.instantiate(v)) | 663 setattr(api, k, mapper.instantiate(v)) |
| 660 return api | 664 return api |
| 661 | 665 |
| 662 | 666 |
| 663 def _resolve_requirement(req, engine): | 667 def _resolve_requirement(req, engine): |
| 664 if req._typ == 'client': | 668 if req._typ == 'client': |
| 665 return engine._get_client(req._name) | 669 return engine._get_client(req._name) |
| 666 else: | 670 else: |
| 667 raise ValueError('Unknown requirement type [%s]' % (req._typ,)) | 671 raise ValueError('Unknown requirement type [%s]' % (req._typ,)) |
| OLD | NEW |