コード例 #1
0
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")
コード例 #2
0
    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"))
コード例 #3
0
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")
コード例 #4
0
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")
コード例 #5
0
ファイル: report.py プロジェクト: MikkelSchubert/paleomix
    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"))
コード例 #6
0
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")
コード例 #7
0
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")
コード例 #8
0
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")
コード例 #9
0
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")
コード例 #10
0
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")
コード例 #11
0
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")
コード例 #12
0
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")
コード例 #13
0
    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)
コード例 #14
0
    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)
コード例 #15
0
ファイル: nuclear.py プロジェクト: muslih14/paleomix
    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)
コード例 #16
0
 def _run(self, _config, _temp):
     for (src_file, dst_file) in self._files:
         copy_file(src_file, dst_file)
コード例 #17
0
ファイル: misc.py プロジェクト: muslih14/paleomix
 def _run(self, _config, _temp):
     for (src_file, dst_file) in self._files:
         copy_file(src_file, dst_file)