Commit a12a660d authored by Matthias Weidenthaler's avatar Matthias Weidenthaler
Browse files

Added isfile function for local and s3 file system

parent ffdd0a96
...@@ -3,3 +3,4 @@ from .fits import fsspec_header ...@@ -3,3 +3,4 @@ from .fits import fsspec_header
from .fits import fsspec_HDUList from .fits import fsspec_HDUList
from .table import fsspec_table from .table import fsspec_table
from . import s3_fs from . import s3_fs
from . import fs
\ No newline at end of file
from .s3_fs import is_s3_path
from .s3_fs import isfile as s3_isfile
from .local_fs import isfile as local_isfile
def isfile(path: str, *args, **kwargs) -> bool:
if is_s3_path(path):
return s3_isfile(path, *args, **kwargs)
else:
return local_isfile(path, *args, **kwargs)
import os
def isfile(path: str) -> bool:
return os.path.isfile(path)
\ No newline at end of file
...@@ -16,3 +16,12 @@ def info(path, bucket=None, key=None, refresh=False, version_id=None, s3_options ...@@ -16,3 +16,12 @@ def info(path, bucket=None, key=None, refresh=False, version_id=None, s3_options
def open(file: str, mode: str='r', s3_options=load_s3_options()): def open(file: str, mode: str='r', s3_options=load_s3_options()):
return open_fileobj(path=file, s3_options=s3_options, mode=mode) return open_fileobj(path=file, s3_options=s3_options, mode=mode)
def isfile(path: str, s3_options: dict=load_s3_options()) -> bool:
s3_fs = fsspec.filesystem('s3', **s3_options)
return s3_fs.isfile(path)
def is_s3_path(path: str):
if(path.startswith("s3")):
return True
return False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment