From 088b555ae0915a5c8b21a9697c68741125bb413a Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Tue, 31 Dec 2019 20:17:09 -0500 Subject: [PATCH] Cleanup EventHandler.process() method and use AssertionError --- .../tracetools_analysis/processor/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tracetools_analysis/tracetools_analysis/processor/__init__.py b/tracetools_analysis/tracetools_analysis/processor/__init__.py index c55e8e1..63dcfbb 100644 --- a/tracetools_analysis/tracetools_analysis/processor/__init__.py +++ b/tracetools_analysis/tracetools_analysis/processor/__init__.py @@ -165,14 +165,19 @@ class EventHandler(Dependant): return f'0x{addr:X}' @classmethod - def process(cls, events: List[DictEvent], **kwargs) -> 'EventHandler': + def process( + cls, + events: List[DictEvent], + **kwargs, + ) -> 'EventHandler': """ Create a `Processor` and process an instance of the class. :param events: the list of events :return: the processor object after processing """ - assert cls != EventHandler, 'only call process() from inheriting classes' + if cls == EventHandler: + raise AssertionError('only call EventHandler.process() from inheriting classes') handler_object = cls(**kwargs) # pylint: disable=all processor = Processor(handler_object, **kwargs) processor.process(events)