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

Unified Diff: tools/telemetry/telemetry/decorators.py

Issue 1428133005: [Telemetry] Allows concatenating multiple Disabled & Enabled decorators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix benchmark_smoke_unittest Created 5 years, 1 month 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: tools/telemetry/telemetry/decorators.py
diff --git a/tools/telemetry/telemetry/decorators.py b/tools/telemetry/telemetry/decorators.py
index 8865408108e21391ee9da919532dd84601b5f989..1dac96425d0205d63e2bd6cf6a40559ee440168c 100644
--- a/tools/telemetry/telemetry/decorators.py
+++ b/tools/telemetry/telemetry/decorators.py
@@ -111,15 +111,19 @@ def Disabled(*args):
"""
def _Disabled(func):
if not isinstance(func, types.FunctionType):
- func._disabled_strings = disabled_strings
+ if not hasattr(func, '_disabled_strings'):
+ func._disabled_strings = set()
+ func._disabled_strings.update(disabled_strings)
return func
@functools.wraps(func)
def wrapper(*args, **kwargs):
func(*args, **kwargs)
- wrapper._disabled_strings = disabled_strings
+ if not hasattr(wrapper, '_disabled_strings'):
+ wrapper._disabled_strings = set()
+ wrapper._disabled_strings.update(disabled_strings)
return wrapper
if len(args) == 1 and callable(args[0]):
- disabled_strings = []
+ disabled_strings = set()
return _Disabled(args[0])
disabled_strings = list(args)
for disabled_string in disabled_strings:
@@ -140,12 +144,16 @@ def Enabled(*args):
"""
def _Enabled(func):
if not isinstance(func, types.FunctionType):
- func._enabled_strings = enabled_strings
+ if not hasattr(func, '_enabled_strings'):
+ func._enabled_strings = set()
+ func._enabled_strings.update(enabled_strings)
return func
@functools.wraps(func)
def wrapper(*args, **kwargs):
func(*args, **kwargs)
- wrapper._enabled_strings = enabled_strings
+ if not hasattr(wrapper, '_enabled_strings'):
+ wrapper._enabled_strings = set()
+ wrapper._enabled_strings.update(enabled_strings)
return wrapper
assert args and not callable(args[0]), '@Enabled requires arguments'
enabled_strings = list(args)

Powered by Google App Engine
This is Rietveld 408576698