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 from __future__ import print_function | 5 from __future__ import print_function |
6 | 6 |
7 from . import loader | 7 from . import loader |
8 | 8 |
9 | 9 |
10 def main(universe, own_package, modules, transitive): | 10 def add_subparser(parser): |
11 refs_p = parser.add_parser( | |
12 'refs', | |
13 description='List places referencing given recipe module(s).') | |
14 refs_p.add_argument('modules', nargs='+', help='Module(s) to query for') | |
15 refs_p.add_argument('--transitive', action='store_true', | |
16 help='Compute transitive closure of the references') | |
17 | |
18 refs_p.set_defaults(command='refs', func=main) | |
19 | |
20 | |
21 def main(package_deps, args): | |
22 universe = loader.RecipeUniverse(package_deps, args.package) | |
23 own_package = package_deps.root_package | |
24 modules = args.modules | |
dnj
2017/04/27 16:40:40
nit: in other CLs, you would have used "args.modul
| |
25 transitive = args.transitive | |
26 | |
11 result_modules = set() | 27 result_modules = set() |
12 result_recipes = set() | 28 result_recipes = set() |
13 | 29 |
14 module_dependencies = {} | 30 module_dependencies = {} |
15 | 31 |
16 for package, module_name in universe.loop_over_recipe_modules(): | 32 for package, module_name in universe.loop_over_recipe_modules(): |
17 mod = universe.load(package, module_name) | 33 mod = universe.load(package, module_name) |
18 module_dependencies[mod.NAME] = mod.LOADED_DEPS | 34 module_dependencies[mod.NAME] = mod.LOADED_DEPS |
19 | 35 |
20 for module in modules: | 36 for module in modules: |
(...skipping 22 matching lines...) Expand all Loading... | |
43 | 59 |
44 if result_modules: | 60 if result_modules: |
45 print('Modules:') | 61 print('Modules:') |
46 for module in sorted(result_modules): | 62 for module in sorted(result_modules): |
47 print(' %s' % module) | 63 print(' %s' % module) |
48 | 64 |
49 if result_recipes: | 65 if result_recipes: |
50 print('Recipes:') | 66 print('Recipes:') |
51 for recipe in sorted(result_recipes): | 67 for recipe in sorted(result_recipes): |
52 print(' %s' % recipe) | 68 print(' %s' % recipe) |
OLD | NEW |