Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-pipeline
csst_fs
Commits
a12a660d
Commit
a12a660d
authored
Aug 14, 2024
by
Matthias Weidenthaler
Browse files
Added isfile function for local and s3 file system
parent
ffdd0a96
Changes
4
Hide whitespace changes
Inline
Side-by-side
csst_fs/__init__.py
View file @
a12a660d
...
@@ -2,4 +2,5 @@ from .fits import fsspec_fits
...
@@ -2,4 +2,5 @@ from .fits import fsspec_fits
from
.fits
import
fsspec_header
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
\ No newline at end of file
from
.
import
fs
\ No newline at end of file
csst_fs/fs.py
0 → 100644
View file @
a12a660d
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
)
csst_fs/local_fs.py
0 → 100644
View file @
a12a660d
import
os
def
isfile
(
path
:
str
)
->
bool
:
return
os
.
path
.
isfile
(
path
)
\ No newline at end of file
csst_fs/s3_fs.py
View file @
a12a660d
...
@@ -15,4 +15,13 @@ def info(path, bucket=None, key=None, refresh=False, version_id=None, s3_options
...
@@ -15,4 +15,13 @@ def info(path, bucket=None, key=None, refresh=False, version_id=None, s3_options
return
s3_fs
.
info
(
path
,
bucket
,
key
,
refresh
,
version_id
)
return
s3_fs
.
info
(
path
,
bucket
,
key
,
refresh
,
version_id
)
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
)
\ No newline at end of file
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment