move StageHelper class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Apr 2019 02:53:34 +0000 (03:53 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 29 Apr 2019 02:53:34 +0000 (03:53 +0100)
src/add/iocontrol.py

index d68f6da77c11c35c3e697c61681216270fed3044..6c78cee1d80fd7b59144260eca18e5834e9a0e4a 100644 (file)
@@ -356,37 +356,6 @@ class Stage(metaclass=ABCMeta):
     #def process(i): pass
 
 
-class StageHelper:
-    """ a convenience wrapper around something that is Stage-API-compliant.
-        (that "something" may be a static class, for example).
-    """
-    def __init__(self, stage):
-        self.stage = stage
-
-    def ospec(self, name):
-        assert self.stage is not None
-        return _spec(self.stage.ospec, name)
-
-    def ispec(self, name):
-        assert self.stage is not None
-        return _spec(self.stage.ispec, name)
-
-    def process(self, i):
-        if self.stage and hasattr(self.stage, "process"):
-            return self.stage.process(i)
-        return i
-
-    def setup(self, m, i):
-        if self.stage is not None and hasattr(self.stage, "setup"):
-            self.stage.setup(m, i)
-
-    def _postprocess(self, i): # XXX DISABLED
-        return i # RETURNS INPUT
-        if hasattr(self.stage, "postprocess"):
-            return self.stage.postprocess(i)
-        return i
-
-
 class StageChain(StageCls):
     """ pass in a list of stages, and they will automatically be
         chained together via their input and output specs into a
@@ -473,6 +442,37 @@ class StageChain(StageCls):
         return self.o # conform to Stage API: return last-loop output
 
 
+class StageHelper:
+    """ a convenience wrapper around something that is Stage-API-compliant.
+        (that "something" may be a static class, for example).
+    """
+    def __init__(self, stage):
+        self.stage = stage
+
+    def ospec(self, name):
+        assert self.stage is not None
+        return _spec(self.stage.ospec, name)
+
+    def ispec(self, name):
+        assert self.stage is not None
+        return _spec(self.stage.ispec, name)
+
+    def process(self, i):
+        if self.stage and hasattr(self.stage, "process"):
+            return self.stage.process(i)
+        return i
+
+    def setup(self, m, i):
+        if self.stage is not None and hasattr(self.stage, "setup"):
+            self.stage.setup(m, i)
+
+    def _postprocess(self, i): # XXX DISABLED
+        return i # RETURNS INPUT
+        if hasattr(self.stage, "postprocess"):
+            return self.stage.postprocess(i)
+        return i
+
+
 class ControlBase(StageHelper, Elaboratable):
     """ Common functions for Pipeline API.  Note: a "pipeline stage" only
         exists (conceptually) when a ControlBase derivative is handed