|
@@ -191,7 +191,7 @@ def run_file(files, parameters, mode, handle_output):
|
|
|
|
|
|
def run_file_to_completion(files, parameters, mode):
|
|
|
"""Compiles the given sequence of files, feeds them the given input in the given mode,
|
|
|
- then collects and returns their output."""
|
|
|
+ and then collects and returns output."""
|
|
|
results = []
|
|
|
def handle_output(output):
|
|
|
"""Appends the given output to the list of results."""
|
|
@@ -202,3 +202,27 @@ def run_file_to_completion(files, parameters, mode):
|
|
|
run_file(files, parameters, mode, handle_output)
|
|
|
except ModelverseTerminated:
|
|
|
return results
|
|
|
+
|
|
|
+def run_file_fixed_output_count(files, parameters, mode, output_count):
|
|
|
+ """Compiles the given sequence of files, feeds them the given input in the given mode,
|
|
|
+ and then collects and returns a fixed number of outputs."""
|
|
|
+ results = []
|
|
|
+ def handle_output(output):
|
|
|
+ """Appends the given output to the list of results."""
|
|
|
+ if len(results) < output_count:
|
|
|
+ results.append(output)
|
|
|
+ return True
|
|
|
+ else:
|
|
|
+ return False
|
|
|
+
|
|
|
+ run_file(files, parameters, mode, handle_output)
|
|
|
+ return results
|
|
|
+
|
|
|
+def run_file_single_output(files, parameters, mode):
|
|
|
+ """Compiles the given sequence of files, feeds them the given input in the given mode,
|
|
|
+ and then collects and returns a single output."""
|
|
|
+ return run_file_fixed_output_count(files, parameters, mode, 1)[0]
|
|
|
+
|
|
|
+def format_output(output):
|
|
|
+ """Formats the output of `run_file_to_completion` as a string."""
|
|
|
+ return '\n'.join(output)
|