From 37dd0cbbcbcb1aa00b7f3aa2e74a6775c6a7f2fb Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 7 Nov 2017 16:27:43 +0000 Subject: Create get_description and get_scenario_type for Scenario Created two new class functions for Scenario class: * "get_description" will return the first line of the docstring, if exists. * "get_scenario_type" will return the value of "__scenario_type__" variable. Change-Id: I8e3b47e33e0bae101b874c3975bb9c383397d188 Signed-off-by: Rodolfo Alonso Hernandez --- yardstick/benchmark/scenarios/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'yardstick/benchmark/scenarios/base.py') diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py index 3cb138dd8..7af85834c 100644 --- a/yardstick/benchmark/scenarios/base.py +++ b/yardstick/benchmark/scenarios/base.py @@ -64,6 +64,20 @@ class Scenario(object): raise RuntimeError("No such scenario type %s" % scenario_type) + @classmethod + def get_scenario_type(cls): + """Return a string with the scenario type, if defined""" + return str(getattr(cls, '__scenario_type__', None)) + + @classmethod + def get_description(cls): + """Return a single line string with the class description + + This function will retrieve the class docstring and return the first + line, or 'None' if it's empty. + """ + return cls.__doc__.splitlines()[0] if cls.__doc__ else str(None) + def _push_to_outputs(self, keys, values): return dict(zip(keys, values)) -- cgit 1.2.3-korg