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

Side by Side Diff: recipe_engine/loader.py

Issue 2802693003: include Package proto into Result proto (Closed)
Patch Set: rebased and addressed comments Created 3 years, 7 months 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 | recipe_engine/package.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
175 def _dep_from_name(self, name): 176 def _dep_from_name(self, name):
176 if '/' in name: 177 if '/' in name:
177 package, module = name.split('/') 178 package, module = name.split('/')
178 return self.package.find_dep(package), module 179 return self.package.find_dep(package), module
179 else: 180 else:
180 # In current package 181 # In current package
181 return self.package, name 182 return self.package, name
182 183
183 def normalize_deps_spec(self, spec): 184 def normalize_deps_spec(self, spec):
184 """Takes a deps spec in either list or dict form, and converts it to 185 """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
225 { 226 {
226 'chromium': 'build/chromium', 227 'chromium': 'build/chromium',
227 'chromiuminternal': 'build_internal/chromium', 228 'chromiuminternal': 'build_internal/chromium',
228 } 229 }
229 """ 230 """
230 return { 231 return {
231 local_name: self.universe.load(pkg, name) 232 local_name: self.universe.load(pkg, name)
232 for local_name, (pkg, name) in self.normalize_deps_spec(spec).iteritems() 233 for local_name, (pkg, name) in self.normalize_deps_spec(spec).iteritems()
233 } 234 }
234 235
235
236 def find_recipe(self, recipe): 236 def find_recipe(self, recipe):
237 if ':' in recipe: 237 if ':' in recipe:
238 module_name, recipe_name = recipe.split(':') 238 module_name, recipe_name = recipe.split(':')
239 module_dir = os.path.join(self.package.module_dir, module_name) 239 module_dir = os.path.join(self.package.module_dir, module_name)
240 if _is_recipe_module_dir(module_dir): 240 if _is_recipe_module_dir(module_dir):
241 if recipe_name.endswith('example'): 241 if recipe_name.endswith('example'):
242 # TODO(martinis) change to example == 'example' ? Technically a bug... 242 # TODO(martinis) change to example == 'example' ? Technically a bug...
243 recipe_path = os.path.join(module_dir, 'example.py') 243 recipe_path = os.path.join(module_dir, 'example.py')
244 elif recipe_name.startswith('tests/'): 244 elif recipe_name.startswith('tests/'):
245 recipe_path = os.path.join( 245 recipe_path = os.path.join(
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 for k,v in toplevel_deps.iteritems(): 670 for k,v in toplevel_deps.iteritems():
671 setattr(api, k, mapper.instantiate(v)) 671 setattr(api, k, mapper.instantiate(v))
672 return api 672 return api
673 673
674 674
675 def _resolve_requirement(req, engine): 675 def _resolve_requirement(req, engine):
676 if req._typ == 'client': 676 if req._typ == 'client':
677 return engine._get_client(req._name) 677 return engine._get_client(req._name)
678 else: 678 else:
679 raise ValueError('Unknown requirement type [%s]' % (req._typ,)) 679 raise ValueError('Unknown requirement type [%s]' % (req._typ,))
OLDNEW
« no previous file with comments | « no previous file | recipe_engine/package.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698