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

Unified Diff: tools/telemetry/telemetry/core/discover.py

Issue 23602015: [Telemetry] discover.DiscoverClasses() does not add inherited classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable pylint error Created 7 years, 4 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
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/discover_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/discover.py
diff --git a/tools/telemetry/telemetry/core/discover.py b/tools/telemetry/telemetry/core/discover.py
index 10cc73139b3e67b4f915d5e7338651b9ad5bdb86..28a1767b30e44c497bcc0cb0575b1563e3b03eff 100644
--- a/tools/telemetry/telemetry/core/discover.py
+++ b/tools/telemetry/telemetry/core/discover.py
@@ -50,6 +50,8 @@ def DiscoverClasses(start_dir, top_level_dir, base_class, pattern='*',
index_by_class_name=False):
"""Discover all classes in |start_dir| which subclass |base_class|.
+ Base classes that contain subclasses are ignored by default.
+
Args:
start_dir: The directory to recursively search.
top_level_dir: The top level of the package, for importing.
@@ -66,7 +68,8 @@ def DiscoverClasses(start_dir, top_level_dir, base_class, pattern='*',
for module in modules:
for _, obj in inspect.getmembers(module):
if (inspect.isclass(obj) and obj is not base_class and
- issubclass(obj, base_class)):
+ issubclass(obj, base_class) and obj.__module__ == module.__name__
+ and len(obj.__subclasses__()) == 0):
if index_by_class_name:
key_name = camel_case.ToUnderscore(obj.__name__)
else:
« no previous file with comments | « no previous file | tools/telemetry/telemetry/core/discover_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698