Beispiel #1
0
 def __new__(cls, path, *args, **kwargs):
     if cls is DRPath:
         if get_fs(path, rtype="class").is_remote:
             cls = RemotePath
         else:
             cls = LocalPath
     obj = cls(path, *args, **kwargs)
     return obj
Beispiel #2
0
def glob(path, opts=None):
    """Filesystem-agnostic glob."""
    return get_fs(path, opts=opts).glob(path)
Beispiel #3
0
def rmdir(path, opts=None):
    """Filesystem-agnostic rmdir."""
    return get_fs(path, opts=opts).rmdir(path)
Beispiel #4
0
def makedirs(path, *args, opts=None, **kwargs):
    """Filesystem-agnostic makedirs."""
    return get_fs(path, opts=opts).makedirs(path, *args, **kwargs)
Beispiel #5
0
def mv(src, dst, opts=None):
    """Filesystem-agnostic mv."""
    return get_fs(src, opts=opts).mv(src, dst)
Beispiel #6
0
def open(path, mode, opts=None):
    """Filesystem-agnostic open."""
    return get_fs(path, opts=opts).open(path, mode)
Beispiel #7
0
def exists(path, opts=None):
    """Filesystem-agnostic exists."""
    return get_fs(path, opts=opts).exists(path)
Beispiel #8
0
def test_get_fs(path, fs):
    assert isinstance(get_fs(path), fs)
Beispiel #9
0
def test_glob_files(s3_data_dir):
    fs = get_fs("s3://s3-test-bucket/", rtype="instance")

    res = fs.glob("s3://s3-test-bucket/dump/*.csv")
    assert all([str(p).startswith("s3://s3-") for p in res])
    assert len(res) == 10
Beispiel #10
0
def _get_path_class(path):
    if get_fs(path).is_remote:
        return RemotePath
    else:
        return Path
Beispiel #11
0
def test_get_fs_no_side_effect():
    expected = config["fs_opts"]["s3"].get(dict).copy()

    get_fs("s3://bucket", opts=dict(config_kwargs={'read_timeout': 600}))

    assert config["fs_opts"]["s3"].get(dict) == expected
Beispiel #12
0
def test_config_get_fs(s3_opts_config):
    res = {}

    fs = get_fs("s3://bucket", res)

    assert fs.fs.key == "test_config"
Beispiel #13
0
 def fs(self):
     return get_fs(self.path, opts=self.storage_options, rtype="instance")