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

Unified Diff: scripts/tools/show_me_the_modules.py

Issue 1347263002: Revert of Cross-repo recipe package system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: scripts/tools/show_me_the_modules.py
diff --git a/scripts/tools/show_me_the_modules.py b/scripts/tools/show_me_the_modules.py
new file mode 100755
index 0000000000000000000000000000000000000000..2c726ac2e796203acefd51771bdbecde5bbdcf9c
--- /dev/null
+++ b/scripts/tools/show_me_the_modules.py
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from __future__ import print_function
+
+import collections
+import inspect
+import os
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
+sys.path.append(os.path.join(os.path.dirname(__file__),
+ '..', '..', 'third_party'))
+
+from recipe_engine import main as recipe_main
+from recipe_engine import recipe_api
+from recipe_engine import loader
+
+from slave import recipe_universe
+
+def trim_doc(docstring):
+ """From PEP 257"""
+ if not docstring:
+ return ''
+ # Convert tabs to spaces (following the normal Python rules)
+ # and split into a list of lines:
+ lines = docstring.expandtabs().splitlines()
+ # Determine minimum indentation (first line doesn't count):
+ indent = sys.maxint
+ for line in lines[1:]:
+ stripped = line.lstrip()
+ if stripped:
+ indent = min(indent, len(line) - len(stripped))
+ # Remove indentation (first line is special):
+ trimmed = [lines[0].strip()]
+ if indent < sys.maxint:
+ for line in lines[1:]:
+ trimmed.append(line[indent:].rstrip())
+ # Strip off trailing and leading blank lines:
+ while trimmed and not trimmed[-1]:
+ trimmed.pop()
+ while trimmed and not trimmed[0]:
+ trimmed.pop(0)
+ return trimmed
+
+def member_iter(obj):
+ for name in sorted(dir(obj)):
+ if name[0] == '_' and name != '__call__':
+ continue
+ # Check class first to avoid calling property functions.
+ if hasattr(obj.__class__, name):
+ val = getattr(obj.__class__, name)
+ if callable(val) or isinstance(val, property):
+ yield name, val
+ else:
+ val = getattr(obj, name)
+ if callable(val) or inspect.ismodule(val):
+ yield name, val
+
+def map_to_cool_name(typ):
+ if typ is collections.Mapping:
+ return 'Mapping'
+ return typ
+
+def p(indent_lvl, *args, **kwargs):
+ sys.stdout.write(' '*indent_lvl)
+ print(*args, **kwargs)
+
+def pmethod(indent_lvl, name, obj):
+ if isinstance(obj, property):
+ name = '@'+name
+ if obj.fset:
+ name += '(r/w)'
+ p(indent_lvl, name, '', end='')
+ if obj.__doc__:
+ lines = trim_doc(obj.__doc__)
+ p(0, '--', lines[0])
+ else:
+ p(0)
+
+def main():
+ common_methods = set(k for k, v in member_iter(recipe_api.RecipeApi))
+ p(0, 'Common Methods -- %s' % os.path.splitext(recipe_api.__file__)[0])
+ for method in sorted(common_methods):
+ pmethod(1, method, getattr(recipe_api.RecipeApi, method))
+
+ universe = recipe_universe.get_universe()
+ deps = universe.deps_from_paths(
+ { modpath: modpath
+ for modpath in universe.loop_over_recipe_modules() },
+ base_path=None)
+
+ inst = loader.create_recipe_api(
+ deps, recipe_main.RecipeEngine(None, {}, None))
+
+ for mod_name, mod in deps.iteritems():
+ p(0)
+ p(0, "(%s) -- %s" % (mod_name, mod.__path__[0]))
+ if mod.LOADED_DEPS:
+ p(1, 'DEPS:', list(mod.LOADED_DEPS))
+
+ subinst = getattr(inst, mod_name)
+ bases = set(subinst.__class__.__bases__)
+ base_fns = set()
+ for base in bases:
+ for name, _ in inspect.getmembers(base):
+ base_fns.add(name)
+ for cool_base in bases - set((recipe_api.RecipeApi,)):
+ p(1, 'behaves like %s' % map_to_cool_name(cool_base))
+
+ if mod.API.__doc__:
+ for line in trim_doc(mod.API.__doc__):
+ p(2, '"', line)
+
+ for fn_name, obj in member_iter(subinst):
+ if fn_name in base_fns:
+ continue
+ pmethod(1, fn_name, obj)
+
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « scripts/slave/unittests/recipe_simulation_test.py ('k') | scripts/tools/unittests/show_me_the_modules_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698