def test_copy_file__overwrite(temp_folder): with SetWorkingDirectory(temp_folder): set_file_contents("file_1", "4") set_file_contents("file_2", "5") copy_file("file_1", "file_2") assert_equal(set(os.listdir(".")), set(["file_1", "file_2"])) assert_equal(get_file_contents("file_1"), "4") assert_equal(get_file_contents("file_2"), "4")
def _teardown(self, config, temp): fileutils.make_dirs(self._root) fileutils.move_file(os.path.join(temp, "summary.html"), os.path.join(self._root, "summary.html")) css_path = paleomix.resources.report("zonkey", "report.css") fileutils.copy_file(css_path, os.path.join(self._root, "summary.css"))
def test_copy_file__overwrite(temp_folder): with SetWorkingDirectory(temp_folder): set_file_contents("file_1", "4") set_file_contents("file_2", "5") copy_file("file_1", "file_2") assert_equal(set(os.listdir(".")), set(["file_1", "file_2"])) assert_equal(get_file_contents("file_1"), "4") assert_equal(get_file_contents("file_2"), "4")
def test_copy_file__copy_to_different_folder(temp_folder): with SetWorkingDirectory(temp_folder): set_file_contents("file_1", "3") copy_file("file_1", "dst/file_1") assert_equal(set(os.listdir(".")), set(["file_1", "dst"])) assert_equal(os.listdir("dst"), ["file_1"]) assert_equal(get_file_contents("file_1"), "3") assert_equal(get_file_contents("dst/file_1"), "3")
def _teardown(self, config, temp): fileutils.make_dirs(self._root) fileutils.move_file(os.path.join(temp, "report.html"), os.path.join(self._root, "report.html")) css_path = paleomix.resources.report("zonkey", "report.css") fileutils.copy_file(css_path, os.path.join(self._root, "report.css"))
def test_copy_file__copy_to_different_folder(temp_folder): with SetWorkingDirectory(temp_folder): set_file_contents("file_1", "3") copy_file("file_1", "dst/file_1") assert_equal(set(os.listdir(".")), set(["file_1", "dst"])) assert_equal(os.listdir("dst"), ["file_1"]) assert_equal(get_file_contents("file_1"), "3") assert_equal(get_file_contents("dst/file_1"), "3")
def test_copy_file__simple_copy_in_cwd(temp_folder): with SetWorkingDirectory(temp_folder): assert_equal(os.listdir("."), []) set_file_contents("file_1", "1") assert_equal(os.listdir("."), ["file_1"]) copy_file("file_1", "file_2") assert_equal(set(os.listdir(".")), set(["file_1", "file_2"])) assert_equal(get_file_contents("file_1"), "1") assert_equal(get_file_contents("file_2"), "1")
def test_copy_file__simple_copy_in_cwd(temp_folder): with SetWorkingDirectory(temp_folder): assert_equal(os.listdir("."), []) set_file_contents("file_1", "1") assert_equal(os.listdir("."), ["file_1"]) copy_file("file_1", "file_2") assert_equal(set(os.listdir(".")), set(["file_1", "file_2"])) assert_equal(get_file_contents("file_1"), "1") assert_equal(get_file_contents("file_2"), "1")
def test_copy_file__copy_to_new_folder(temp_folder): assert make_dirs(os.path.join(temp_folder, "src")) file_1 = os.path.join(temp_folder, "src", "file_1") file_2 = os.path.join(temp_folder, "dst", "file_2") set_file_contents(file_1, "2") copy_file(file_1, file_2) assert_equal(os.listdir(os.path.dirname(file_1)), ["file_1"]) assert_equal(os.listdir(os.path.dirname(file_2)), ["file_2"]) assert_equal(get_file_contents(file_1), "2") assert_equal(get_file_contents(file_2), "2")
def test_copy_file__simple_copy(temp_folder): file_1 = os.path.join(temp_folder, "file_1") file_2 = os.path.join(temp_folder, "file_2") assert_equal(os.listdir(temp_folder), []) set_file_contents(file_1, "1") assert_equal(os.listdir(temp_folder), ["file_1"]) copy_file(file_1, file_2) assert_equal(set(os.listdir(temp_folder)), set(["file_1", "file_2"])) assert_equal(get_file_contents(file_1), "1") assert_equal(get_file_contents(file_2), "1")
def test_copy_file__copy_to_new_folder(temp_folder): assert make_dirs(os.path.join(temp_folder, "src")) file_1 = os.path.join(temp_folder, "src", "file_1") file_2 = os.path.join(temp_folder, "dst", "file_2") set_file_contents(file_1, "2") copy_file(file_1, file_2) assert_equal(os.listdir(os.path.dirname(file_1)), ["file_1"]) assert_equal(os.listdir(os.path.dirname(file_2)), ["file_2"]) assert_equal(get_file_contents(file_1), "2") assert_equal(get_file_contents(file_2), "2")
def test_copy_file__simple_copy(temp_folder): file_1 = os.path.join(temp_folder, "file_1") file_2 = os.path.join(temp_folder, "file_2") assert_equal(os.listdir(temp_folder), []) set_file_contents(file_1, "1") assert_equal(os.listdir(temp_folder), ["file_1"]) copy_file(file_1, file_2) assert_equal(set(os.listdir(temp_folder)), set(["file_1", "file_2"])) assert_equal(get_file_contents(file_1), "1") assert_equal(get_file_contents(file_2), "1")
def _teardown(self, config, temp): for postfix in ("ALIGNMENT", "PARTITION"): filenames = [self._kwargs["TEMP_IN_" + postfix], self._kwargs["TEMP_IN_" + postfix] + ".reduced", self._kwargs["OUT_" + postfix]] for (source, destination) in zip(filenames, filenames[1:]): source = fileutils.reroot_path(temp, source) destination = fileutils.reroot_path(temp, destination) if not os.path.exists(destination): fileutils.copy_file(source, destination) os.remove(source) CommandNode._teardown(self, config, temp)
def _run(self, config, temp): likelihoods = [] for fileset in self._files: for filename in fileset: if filename.endswith(".log"): likelihoods.append( (self._read_admixture_log(filename), fileset)) break else: raise NodeError("No log-file found in list of admixture " "output-files: %r" % (fileset, )) _, fileset = max(likelihoods) for src_filename in fileset: dst_filename = fileutils.reroot_path(self._output_root, src_filename) fileutils.copy_file(src_filename, dst_filename)
def _run(self, config, temp): likelihoods = [] for fileset in self._files: for filename in fileset: if filename.endswith(".log"): likelihoods.append((self._read_admixture_log(filename), fileset)) break else: raise NodeError("No log-file found in list of admixture " "output-files: %r" % (fileset,)) _, fileset = max(likelihoods) for src_filename in fileset: dst_filename = fileutils.reroot_path(self._output_root, src_filename) fileutils.copy_file(src_filename, dst_filename)
def _run(self, _config, _temp): for (src_file, dst_file) in self._files: copy_file(src_file, dst_file)
def _run(self, _config, _temp): for (src_file, dst_file) in self._files: copy_file(src_file, dst_file)