def _merge_files(self, job): with osext.change_dir(job.workdir): out_glob = glob.glob(job.stdout + '_*') err_glob = glob.glob(job.stderr + '_*') self.log(f'merging job array output files: {", ".join(out_glob)}') osext.concat_files(job.stdout, *out_glob, overwrite=True) self.log(f'merging job array error files: {", ".join(err_glob)}') osext.concat_files(job.stderr, *err_glob, overwrite=True)
def test_concat_files(tmpdir): with osext.change_dir(tmpdir): file1 = 'in1.txt' file2 = 'in2.txt' concat_file = 'out.txt' with open(file1, 'w') as f1: f1.write('Hello1') with open(file2, 'w') as f2: f2.write('Hello2') osext.concat_files(concat_file, file1, file2, overwrite=True) with open(concat_file) as cf: out = cf.read() assert out == 'Hello1\nHello2\n'