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

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

Issue 23455049: [telemetry] Make single-benchmark measurements protected and undiscoverable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update discover unit tests. Created 7 years, 2 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 | « tools/perf/measurements/dromaeo.py ('k') | 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 28a1767b30e44c497bcc0cb0575b1563e3b03eff..bfdd6e9b51027ba098fbeda2a89db6dff338be93 100644
--- a/tools/telemetry/telemetry/core/discover.py
+++ b/tools/telemetry/telemetry/core/discover.py
@@ -67,13 +67,27 @@ def DiscoverClasses(start_dir, top_level_dir, base_class, pattern='*',
classes = {}
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) and obj.__module__ == module.__name__
- and len(obj.__subclasses__()) == 0):
- if index_by_class_name:
- key_name = camel_case.ToUnderscore(obj.__name__)
- else:
- key_name = module.__name__.split('.')[-1]
- classes[key_name] = obj
+ # Ensure object is a class.
+ if not inspect.isclass(obj):
+ continue
+ # Include only subclasses of base_class.
+ if not issubclass(obj, base_class):
+ continue
+ # Exclude the base_class itself.
+ if obj is base_class:
+ continue
+ # Exclude protected or private classes.
+ if obj.__name__.startswith('_'):
+ continue
+ # Include only the module in which the class is defined.
+ # If a class is imported by another module, exclude those duplicates.
+ if obj.__module__ != module.__name__:
+ continue
+
+ if index_by_class_name:
+ key_name = camel_case.ToUnderscore(obj.__name__)
+ else:
+ key_name = module.__name__.split('.')[-1]
+ classes[key_name] = obj
return classes
« no previous file with comments | « tools/perf/measurements/dromaeo.py ('k') | tools/telemetry/telemetry/core/discover_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698