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

Side by Side Diff: recipe_engine/loader.py

Issue 1921943002: doc: General improvements. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Rebase license. Created 4 years, 6 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 | « recipe_engine/doc.py ('k') | recipe_engine/recipe_api.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 2013 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 contextlib 6 import contextlib
7 import imp 7 import imp
8 import inspect 8 import inspect
9 import os 9 import os
10 import sys 10 import sys
11 11
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 for path in self.package.recipe_dirs: 252 for path in self.package.recipe_dirs:
253 for recipe in scan_directory( 253 for recipe in scan_directory(
254 path, lambda f: f.endswith('.py') and f[0] != '_'): 254 path, lambda f: f.endswith('.py') and f[0] != '_'):
255 yield recipe, recipe[len(path)+1:-len('.py')] 255 yield recipe, recipe[len(path)+1:-len('.py')]
256 for path in self.package.module_dirs: 256 for path in self.package.module_dirs:
257 for recipe in scan_directory( 257 for recipe in scan_directory(
258 path, lambda f: f.endswith('example.py')): 258 path, lambda f: f.endswith('example.py')):
259 module_name = os.path.dirname(recipe)[len(path)+1:] 259 module_name = os.path.dirname(recipe)[len(path)+1:]
260 yield recipe, '%s:example' % module_name 260 yield recipe, '%s:example' % module_name
261 261
262 def loop_over_recipe_modules(self):
263 """Yields the paths to all the modules that this view can see."""
264 for path in self.package.module_dirs:
265 if os.path.isdir(path):
266 for item in os.listdir(path):
267 subpath = os.path.join(path, item)
268 if _is_recipe_module_dir(subpath):
269 yield os.path.basename(subpath)
270
262 271
263 def _amend_exception(e, amendment): 272 def _amend_exception(e, amendment):
264 """Re-raise an exception e, appending amendment to the end of the message.""" 273 """Re-raise an exception e, appending amendment to the end of the message."""
265 raise type(e), type(e)(e.message + '\n' + amendment), sys.exc_info()[2] 274 raise type(e), type(e)(e.message + '\n' + amendment), sys.exc_info()[2]
266 275
267 276
268 def _is_recipe_module_dir(path): 277 def _is_recipe_module_dir(path):
269 return (os.path.isdir(path) and 278 return (os.path.isdir(path) and
270 os.path.isfile(os.path.join(path, '__init__.py'))) 279 os.path.isfile(os.path.join(path, '__init__.py')))
271 280
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod) 553 modapi = (getattr(mod, 'TEST_API', None) or RecipeTestApi)(module=mod)
545 for k,v in deps.iteritems(): 554 for k,v in deps.iteritems():
546 setattr(modapi.m, k, v) 555 setattr(modapi.m, k, v)
547 return modapi 556 return modapi
548 557
549 mapper = DependencyMapper(instantiator) 558 mapper = DependencyMapper(instantiator)
550 api = RecipeTestApi(module=None) 559 api = RecipeTestApi(module=None)
551 for k,v in toplevel_deps.iteritems(): 560 for k,v in toplevel_deps.iteritems():
552 setattr(api, k, mapper.instantiate(v)) 561 setattr(api, k, mapper.instantiate(v))
553 return api 562 return api
OLDNEW
« no previous file with comments | « recipe_engine/doc.py ('k') | recipe_engine/recipe_api.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698