| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from __future__ import print_function | 6 from __future__ import print_function |
| 7 | 7 |
| 8 import collections | 8 import collections |
| 9 import inspect | 9 import inspect |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 13 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 14 sys.path.append(os.path.join(os.path.dirname(__file__), | 14 sys.path.append(os.path.join(os.path.dirname(__file__), |
| 15 '..', '..', 'third_party')) | 15 '..', '..', 'third_party')) |
| 16 | 16 |
| 17 from slave import annotated_run | 17 from recipe_engine import main as recipe_main |
| 18 from slave import recipe_api | 18 from recipe_engine import recipe_api |
| 19 from slave import recipe_loader | 19 from recipe_engine import loader |
| 20 from slave import recipe_util | 20 |
| 21 from slave import recipe_universe |
| 21 | 22 |
| 22 def trim_doc(docstring): | 23 def trim_doc(docstring): |
| 23 """From PEP 257""" | 24 """From PEP 257""" |
| 24 if not docstring: | 25 if not docstring: |
| 25 return '' | 26 return '' |
| 26 # Convert tabs to spaces (following the normal Python rules) | 27 # Convert tabs to spaces (following the normal Python rules) |
| 27 # and split into a list of lines: | 28 # and split into a list of lines: |
| 28 lines = docstring.expandtabs().splitlines() | 29 lines = docstring.expandtabs().splitlines() |
| 29 # Determine minimum indentation (first line doesn't count): | 30 # Determine minimum indentation (first line doesn't count): |
| 30 indent = sys.maxint | 31 indent = sys.maxint |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 p(0, '--', lines[0]) | 79 p(0, '--', lines[0]) |
| 79 else: | 80 else: |
| 80 p(0) | 81 p(0) |
| 81 | 82 |
| 82 def main(): | 83 def main(): |
| 83 common_methods = set(k for k, v in member_iter(recipe_api.RecipeApi)) | 84 common_methods = set(k for k, v in member_iter(recipe_api.RecipeApi)) |
| 84 p(0, 'Common Methods -- %s' % os.path.splitext(recipe_api.__file__)[0]) | 85 p(0, 'Common Methods -- %s' % os.path.splitext(recipe_api.__file__)[0]) |
| 85 for method in sorted(common_methods): | 86 for method in sorted(common_methods): |
| 86 pmethod(1, method, getattr(recipe_api.RecipeApi, method)) | 87 pmethod(1, method, getattr(recipe_api.RecipeApi, method)) |
| 87 | 88 |
| 88 universe = recipe_loader.RecipeUniverse() | 89 universe = recipe_universe.get_universe() |
| 89 deps = universe.deps_from_paths( | 90 deps = universe.deps_from_paths( |
| 90 { modpath: modpath | 91 { modpath: modpath |
| 91 for modpath in recipe_loader.loop_over_recipe_modules() }, | 92 for modpath in universe.loop_over_recipe_modules() }, |
| 92 base_path=None) | 93 base_path=None) |
| 93 | 94 |
| 94 inst = recipe_loader.create_recipe_api( | 95 inst = loader.create_recipe_api( |
| 95 deps, annotated_run.SequentialRecipeEngine(None, {}, None)) | 96 deps, recipe_main.SequentialRecipeEngine(None, {}, None)) |
| 96 | 97 |
| 97 for mod_name, mod in deps.iteritems(): | 98 for mod_name, mod in deps.iteritems(): |
| 98 p(0) | 99 p(0) |
| 99 p(0, "(%s) -- %s" % (mod_name, mod.__path__[0])) | 100 p(0, "(%s) -- %s" % (mod_name, mod.__path__[0])) |
| 100 if mod.LOADED_DEPS: | 101 if mod.LOADED_DEPS: |
| 101 p(1, 'DEPS:', list(mod.LOADED_DEPS)) | 102 p(1, 'DEPS:', list(mod.LOADED_DEPS)) |
| 102 | 103 |
| 103 subinst = getattr(inst, mod_name) | 104 subinst = getattr(inst, mod_name) |
| 104 bases = set(subinst.__class__.__bases__) | 105 bases = set(subinst.__class__.__bases__) |
| 105 base_fns = set() | 106 base_fns = set() |
| 106 for base in bases: | 107 for base in bases: |
| 107 for name, _ in inspect.getmembers(base): | 108 for name, _ in inspect.getmembers(base): |
| 108 base_fns.add(name) | 109 base_fns.add(name) |
| 109 for cool_base in bases - set((recipe_api.RecipeApi,)): | 110 for cool_base in bases - set((recipe_api.RecipeApi,)): |
| 110 p(1, 'behaves like %s' % map_to_cool_name(cool_base)) | 111 p(1, 'behaves like %s' % map_to_cool_name(cool_base)) |
| 111 | 112 |
| 112 if mod.API.__doc__: | 113 if mod.API.__doc__: |
| 113 for line in trim_doc(mod.API.__doc__): | 114 for line in trim_doc(mod.API.__doc__): |
| 114 p(2, '"', line) | 115 p(2, '"', line) |
| 115 | 116 |
| 116 for fn_name, obj in member_iter(subinst): | 117 for fn_name, obj in member_iter(subinst): |
| 117 if fn_name in base_fns: | 118 if fn_name in base_fns: |
| 118 continue | 119 continue |
| 119 pmethod(1, fn_name, obj) | 120 pmethod(1, fn_name, obj) |
| 120 | 121 |
| 121 | 122 |
| 122 if __name__ == '__main__': | 123 if __name__ == '__main__': |
| 123 main() | 124 main() |
| OLD | NEW |