def execute(self): if not self._verified: self.verify() assert not context.dry_run try: self._execute(tuple(concat(interleave(itervalues(self.prefix_action_groups))))) finally: rm_rf(self.transaction_context['temp_dir'])
def write_results(results, results_descriptor): """Output the given results to terminal and to file.""" output_path = results_descriptor.output_path keys = results_descriptor.keys value_vectors = (results[key] for key in keys) rows = chunked(interleave(value_vectors), len(keys)) string_rows = map(lambda v: ' '.join(str(x) for x in v), rows) all_string_rows = '\n'.join(string_row for string_row in string_rows) keys_string = ' '.join(key for key in keys) output_stdout(keys_string + '\n' + all_string_rows, output_path) output_file(all_string_rows, output_path)
def test_interleave(): assert ''.join(interleave(('ABC', '123'))) == 'A1B2C3' assert ''.join(interleave(('ABC', '1'))) == 'A1BC'
def execute(self): if not self._verified: self.verify() assert not context.dry_run self._execute( tuple(concat(interleave(itervalues(self.prefix_action_groups)))))
def test_interleave(): assert "".join(interleave(("ABC", "123"))) == "A1B2C3" assert "".join(interleave(("ABC", "1"))) == "A1BC"