Exemplo n.º 1
0
 def test_mv(self):
     system.echo("Hello, world!", "/tmp/labm8.tmp")
     self._test(["Hello, world!"], fs.read("/tmp/labm8.tmp"))
     # Cleanup any existing file.
     fs.rm("/tmp/labm8.tmp.copy")
     self._test(False, fs.exists("/tmp/labm8.tmp.copy"))
     fs.mv("/tmp/labm8.tmp", "/tmp/labm8.tmp.copy")
     self.assertEqual(["Hello, world!"], fs.read("/tmp/labm8.tmp.copy"))
     self._test(False, fs.exists("/tmp/labm8.tmp"))
Exemplo n.º 2
0
def test_mv():
    system.echo("Hello, world!", "/tmp/labm8.tmp")
    assert ["Hello, world!"] == fs.read("/tmp/labm8.tmp")
    # Cleanup any existing file.
    fs.rm("/tmp/labm8.tmp.copy")
    assert not fs.exists("/tmp/labm8.tmp.copy")
    fs.mv("/tmp/labm8.tmp", "/tmp/labm8.tmp.copy")
    assert ["Hello, world!"] == fs.read("/tmp/labm8.tmp.copy")
    assert not fs.exists("/tmp/labm8.tmp")
Exemplo n.º 3
0
    def __setitem__(self, key, value):
        """
    Emplace file in cache.

    Arguments:
        key: Key.
        value (str): Path of file to insert in cache.

    Raises:
        ValueError: If no "value" does nto exist.
    """
        if not fs.exists(value):
            raise ValueError(value)

        path = self.keypath(key)
        fs.mkdir(self.path)
        fs.mv(value, path)
Exemplo n.º 4
0
    def __setitem__(self, key, value):
        """
        Emplace file in cache.

        Arguments:
            key: Key.
            value (str): Path of file to insert in cache.

        Raises:
            ValueError: If no "value" does nto exist.
        """
        if not fs.exists(value):
            raise ValueError(value)

        path = self.keypath(key)
        fs.mkdir(self.path)
        fs.mv(value, path)
Exemplo n.º 5
0
        def _main() -> None:
            cache = clgen.cachepath()

            log.warning("Not Implemented: refresh corpuses")

            if fs.isdir(cache, "model"):
                cached_modeldirs = fs.ls(fs.path(cache, "model"), abspaths=True)
                for cached_modeldir in cached_modeldirs:
                    cached_model_id = fs.basename(cached_modeldir)
                    cached_meta = jsonutil.read_file(fs.path(cached_modeldir, "META"))

                    model = clgen.Model.from_json(cached_meta)

                    if cached_model_id != model.hash:
                        log.info(cached_model_id, '->', model.hash)

                        if fs.isdir(model.cache.path):
                            log.fatal("cache conflict", file=sys.stderr)

                        fs.mv(cached_modeldir, model.cache.path)

            log.warning("Not Implemented: refresh samplers")
Exemplo n.º 6
0
 def test_mv_no_dst(self):
     system.echo("Hello, world!", "/tmp/labm8.tmp")
     with self.assertRaises(IOError):
         fs.mv("/tmp/labm8.tmp", "/not/a/real/path")
     fs.rm("/tmp/labm8.tmp")
Exemplo n.º 7
0
 def test_mv_no_src(self):
     with self.assertRaises(fs.File404):
         fs.mv("/bad/path", "foo")
Exemplo n.º 8
0
def test_mv_no_dst():
    system.echo("Hello, world!", "/tmp/labm8.tmp")
    with pytest.raises(IOError):
        fs.mv("/tmp/labm8.tmp", "/not/a/real/path")
    fs.rm("/tmp/labm8.tmp")
Exemplo n.º 9
0
def test_mv_no_src():
    with pytest.raises(fs.File404):
        fs.mv("/bad/path", "foo")