Example #1
0
    def _setup(self, config, temp):
        for key in ("IN_ALIGNMENT", "IN_PARTITION"):
            source = self._kwargs[key]
            destination = os.path.join(temp, self._kwargs["TEMP_" + key])

            fileutils.copy_file(source, destination)

        CommandNode._setup(self, config, temp)
Example #2
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")
Example #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")
Example #4
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")
Example #5
0
    def _setup(self, config, temp):
        for key in ("IN_ALIGNMENT", "IN_PARTITION"):
            source      = self._kwargs[key]
            destination = os.path.join(temp, self._kwargs["TEMP_" + key])

            fileutils.copy_file(source, destination)

        CommandNode._setup(self, config, temp)
Example #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")
Example #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")
Example #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")
Example #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")
Example #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")
Example #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")
Example #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")
Example #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)
Example #14
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)
Example #15
0
 def _run(self, _config, _temp):
     for (src_file, dst_file) in self._files:
         copy_file(src_file, dst_file)
Example #16
0
 def _run(self, _config, _temp):
     for (src_file, dst_file) in self._files:
         copy_file(src_file, dst_file)