Ejemplo n.º 1
0
def mkdir_if_not_exists(fs: s3fs.S3FileSystem, path: str) -> None:
    """
    Create a directory if not exists.

    :param fs: Files-system
    :param path: Directory path
    :return: None
    """
    if fs._isfilestore() and not fs.exists(path):
        try:
            fs.mkdir(path)
        except OSError:
            assert fs.exists(path)
Ejemplo n.º 2
0
def prep_and_check_s3(full_zarr_filename: str, s3: s3fs.S3FileSystem):
    if s3.exists(full_zarr_filename):
        raise FileExistsError(
            'Destination already exists: {}'.format(full_zarr_filename))

    zarr_path, _ = os.path.split(full_zarr_filename)
    s3.makedirs(path=zarr_path)
Ejemplo n.º 3
0
 def exists(self, path):
     return S3FileSystem.exists(self, get_key(path))
Ejemplo n.º 4
0
def get_contents(path: str, client: S3FileSystem) -> Optional[str]:
    if not client.exists(path):
        return None

    with client.open(path, "r") as fp:
        return fp.read()