예제 #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
예제 #2
0
def glob(path, opts=None):
    """Filesystem-agnostic glob."""
    return get_fs(path, opts=opts).glob(path)
예제 #3
0
def rmdir(path, opts=None):
    """Filesystem-agnostic rmdir."""
    return get_fs(path, opts=opts).rmdir(path)
예제 #4
0
def makedirs(path, *args, opts=None, **kwargs):
    """Filesystem-agnostic makedirs."""
    return get_fs(path, opts=opts).makedirs(path, *args, **kwargs)
예제 #5
0
def mv(src, dst, opts=None):
    """Filesystem-agnostic mv."""
    return get_fs(src, opts=opts).mv(src, dst)
예제 #6
0
def open(path, mode, opts=None):
    """Filesystem-agnostic open."""
    return get_fs(path, opts=opts).open(path, mode)
예제 #7
0
def exists(path, opts=None):
    """Filesystem-agnostic exists."""
    return get_fs(path, opts=opts).exists(path)
예제 #8
0
def test_get_fs(path, fs):
    assert isinstance(get_fs(path), fs)
예제 #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
예제 #10
0
def _get_path_class(path):
    if get_fs(path).is_remote:
        return RemotePath
    else:
        return Path
예제 #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
예제 #12
0
def test_config_get_fs(s3_opts_config):
    res = {}

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

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