Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Generic FileSystem class to be used by the Content Manager
"""
from s3contents.ipycompat import HasTraits
class GenericFS(HasTraits):
def ls(self, path=""):
raise NotImplementedError(
"Should be implemented by the file system abstraction"
)
def isfile(self, path):
raise NotImplementedError(
"Should be implemented by the file system abstraction"
)
def isdir(self, path):
raise NotImplementedError(
"Should be implemented by the file system abstraction"
)
def mv(self, old_path, new_path):
"""
Utilities to make S3 look like a regular file system
"""
import six
import boto3
from botocore.client import Config
from s3contents.ipycompat import HasTraits, Unicode
class S3FS(HasTraits):
access_key_id = Unicode(
help="S3/AWS access key ID", allow_none=True, default_value=None).tag(
config=True, env="JPYNB_S3_ACCESS_KEY_ID")
secret_access_key = Unicode(
help="S3/AWS secret access key", allow_none=True, default_value=None).tag(
config=True, env="JPYNB_S3_SECRET_ACCESS_KEY")
endpoint_url = Unicode(
"s3.amazonaws.com", help="S3 endpoint URL").tag(
config=True, env="JPYNB_S3_ENDPOINT_URL")
region_name = Unicode(
"us-east-1", help="Region Name").tag(
config=True, env="JPYNB_S3_REGION_NAME")
bucket_name = Unicode(
"notebooks", help="Bucket name to store notebooks").tag(