Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/30217 )

Change subject: ext: Avoid specifying empty interfaces and embrace duck typing
......................................................................

ext: Avoid specifying empty interfaces and embrace duck typing

It turns out no handler is implementing

prehandle()
posthandle()

JIRA: https://gem5.atlassian.net/projects/GEM5/issues/GEM5-533

Change-Id: Ie8d92027f29fc33192fcf0d495fd3c4f6e4075aa
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M ext/testlib/handlers.py
M ext/testlib/log.py
2 files changed, 6 insertions(+), 39 deletions(-)



diff --git a/ext/testlib/handlers.py b/ext/testlib/handlers.py
index 3005e01..38f50c4 100644
--- a/ext/testlib/handlers.py
+++ b/ext/testlib/handlers.py
@@ -87,7 +87,7 @@
         self.stdout.close()
         self.stderr.close()

-class ResultHandler(log.Handler):
+class ResultHandler(object):
     '''
     Log handler which listens for test results and output saving data as
     it is reported.
@@ -181,7 +181,7 @@

 #TODO Change from a handler to an internal post processor so it can be used
 # to reprint results
-class SummaryHandler(log.Handler):
+class SummaryHandler(object):
     '''
     A log handler which listens to the log for test results
     and reports the aggregate results when closed.
@@ -250,7 +250,7 @@
                 string,
                 color=self.colormap[most_severe_outcome] + self.color.Bold)

-class TerminalHandler(log.Handler):
+class TerminalHandler(object):
     color = terminal.get_termcap()
     verbosity_mapping = {
         log.LogLevel.Warn: color.Yellow,
@@ -330,22 +330,13 @@
             return
         self.mapping.get(record.type_id, lambda _:None)(record)

-    def set_verbosity(self, verbosity):
-        self.verbosity = verbosity
-
-
-class PrintHandler(log.Handler):
-    def __init__(self):
-        pass
-
-    def handle(self, record):
-        print(str(record).rstrip())
-
     def close(self):
         pass

+    def set_verbosity(self, verbosity):
+        self.verbosity = verbosity

-class MultiprocessingHandlerWrapper(log.Handler):
+class MultiprocessingHandlerWrapper(object):
     '''
     A handler class which forwards log records to subhandlers, enabling
     logging across multiprocessing python processes.
diff --git a/ext/testlib/log.py b/ext/testlib/log.py
index cddb921..451ee1d 100644
--- a/ext/testlib/log.py
+++ b/ext/testlib/log.py
@@ -130,10 +130,8 @@
             raise Exception('The log has been closed'
                 ' and is no longer available.')

-        map(lambda handler:handler.prehandle(), self.handlers)
         for handler in self.handlers:
             handler.handle(record)
-            handler.posthandle()

     def add_handler(self, handler):
         if self._opened:
@@ -144,28 +142,6 @@
         handler.close()
         self.handlers.remove(handler)

-
-class Handler(object):
-    '''
-    Empty implementation of the interface available to handlers which
-    is expected by the :class:`Log`.
-    '''
-    def __init__(self):
-        pass
-
-    def handle(self, record):
-        pass
-
-    def close(self):
-        pass
-
-    def prehandle(self):
-        pass
-
-    def posthandle(self):
-        pass
-
-
 class LogWrapper(object):
     _result_typemap = {
         wrappers.LoadedLibrary.__name__: LibraryResult,

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/30217
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ie8d92027f29fc33192fcf0d495fd3c4f6e4075aa
Gerrit-Change-Number: 30217
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to