[Synopsis-changes] Synopsis/Synopsis/Synopsis Processor.py,1.9,1.10
Stefan Seefeld stefan at synopsis.fresco.orgSat Nov 22 21:43:00 UTC 2003
- Previous message: [Synopsis-changes] Synopsis/Synopsis setup.py,1.10,1.11
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis process.py,1.3,1.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/Synopsis
In directory frida:/tmp/cvs-serv27752/Synopsis
Modified Files:
Processor.py
Log Message:
only pass 'input' and 'output' down in the Composite
Index: Processor.py
===================================================================
RCS file: /cvs/synopsis/Synopsis/Synopsis/Processor.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -p -d -r1.9 -r1.10
--- Processor.py 21 Nov 2003 21:16:55 -0000 1.9
+++ Processor.py 22 Nov 2003 21:42:58 -0000 1.10
@@ -122,41 +122,45 @@ class Composite(Processor):
to list the desired processors. If the named values contain 'processors',
they override the var list."""
if processors: self.processors = processors
- self.__dict__.update(kwds)
+ self.set_parameters(kwds)
def process(self, ast, **kwds):
"""apply a list of processors. The 'input' value is passed to the first
- processor only, the 'output' to the last."""
+ processor only, the 'output' to the last. All other keywords are ignored."""
if not self.processors:
return ast
- elif len(self.processors) == 1:
- return self.processors[0].process(ast, **kwds)
-
- # first_kwds is a copy of kwds, but without 'output' defined
- first_kwds = kwds.copy()
- if first_kwds.has_key('output'):
- del first_kwds['output']
- # last_kwds is a copy of kwds, but without 'input' defined
- last_kwds = kwds.copy()
- if last_kwds.has_key('input'):
- del last_kwds['input']
- # remove 'input' and 'output' from kwds for all other processors
- # in the pipeline
- if kwds.has_key('input'):
- del kwds['input']
- if kwds.has_key('output'):
- del kwds['output']
+ self.set_parameters(kwds)
- ast = self.processors[0].process(ast, **first_kwds)
+ if len(self.processors) == 1:
+ my_kwds = {}
+ if self.input: my_kwds['input'] = self.input
+ if self.output: my_kwds['output'] = self.output
+ return self.processors[0].process(ast, **my_kwds)
+
+ # more than one processors...
+
+ # call the first, passing the 'input' parameter, if present
+ if self.input:
+ ast = self.processors[0].process(ast, input = self.input)
+ else:
+ ast = self.processors[0].process(ast)
+ # deal with all between the first and the last;
+ # they don't get any params
if len(self.processors) > 2:
for p in self.processors[1:-1]:
- ast = p.process(ast, **kwds)
+ ast = p.process(ast)
- return self.processors[-1].process(ast, **last_kwds)
+ # call the last, passing the 'output' parameter, if present
+ if self.output:
+ ast = self.processors[-1].process(ast, output = self.output)
+ else:
+ ast = self.processors[-1].process(ast)
+ return ast
+
class Store(Processor):
"""Store is a convenience class useful to write out the intermediate
state of the ast within a pipeline such as represented by the 'Composite'"""
- Previous message: [Synopsis-changes] Synopsis/Synopsis setup.py,1.10,1.11
- Next message: [Synopsis-changes] Synopsis/Synopsis/Synopsis process.py,1.3,1.4
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list