Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ianj-als/pypeline.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Johnson <ianj@wgrids.com>2012-09-06 14:07:48 +0400
committerIan Johnson <ianj@wgrids.com>2012-09-06 14:07:48 +0400
commita40a0b823e65eb25a3759f62dae70d558c25e6ba (patch)
tree558713e845c005d72099829aec907fca64e42b89
parentd9dd00966662c61fee49b690d2d7fbf20448133a (diff)
Added the output function to the batch sub-process component constructor function.
-rw-r--r--src/pypeline/helpers/helpers.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pypeline/helpers/helpers.py b/src/pypeline/helpers/helpers.py
index f910fbf..848e804 100644
--- a/src/pypeline/helpers/helpers.py
+++ b/src/pypeline/helpers/helpers.py
@@ -67,6 +67,7 @@ def cons_subprocess_component(process_pipe,
def cons_batch_subprocess_component(process_pipe,
input_feed_function,
+ output_function,
state_mutator = None):
"""Construct a pipeline component using a Popen object. Batch subprocesses shall accept a single line on stdin. An input feed function shall be provided that yields objects, that once "stringyfied", are presented to the subprocess' stdin. This function takes tow arguments: the value and the state objects. It is the responsibility of the feed function implementer to yield an EOF if necessary. The returned object shall be a Kleisli arrow representing this pipeline component."""
if not isinstance(process_pipe, subprocess.Popen):
@@ -93,11 +94,14 @@ def cons_batch_subprocess_component(process_pipe,
print >> process_pipe.stdin, str(transformed_a).strip()
process_pipe.stdin.flush()
+ # Get the new a
+ new_a = output_function(s)
+
# Mutate the state
next_s = state_mutator(s) if state_mutator else s
# New value/state pair
- return (transformed_new_a, next_s)
+ return (new_a, next_s)
return State(state_function)
return KleisliArrow(return_, bind_function)