# Path: studio/util/logs.py
# DEBUG = logging.DEBUG
# INFO = logging.INFO
# ERROR = logging.ERROR
# def get_logger(name):
# def debug(line):
# def error(line):
# def info(line):
# 
# Path: studio/util/util.py
# DAY = 86400
# HOUR = 3600
# MINUTE = 60
# def remove_backspaces(line):
# def report_fatal(msg: str, logger):
# def sha256_checksum(filename, block_size=65536):
# def filehash(filename, block_size=65536, hashobj=None):
# def rand_string(length):
# def _looks_like_url(name):
# def parse_s3_path(qualified: str):
# def retry(f,
#           no_retries=5, sleep_time=1,
#           exception_class=BaseException, logger=None):
# def compression_to_extension(compression):
# def compression_to_taropt(compression):
# def _compression_to_extension_taropt(compression):
# def timeit(method):
#     def timed(*args, **kw):
# def sixdecode(sval):
# def shquote(sval):
# def parse_duration(duration_str):
# def parse_verbosity(verbosity=None):
# def str2duration(sval):
# def get_temp_filename() -> str:
# def delete_local_path(local_path: str, root: str, shallow: bool):
# def delete_local_folders(local_folder_path: str, root: str):
# def rm_rf(path):
# def check_for_kb_interrupt():
# def add_packages(list1, list2):
# 
# Path: studio/storage/storage_setup.py
# DB_KEY = "database"
# STORE_KEY = "store"
# def setup_storage(db_provider, artifact_store):
# def get_storage_db_provider():
# def get_storage_artifact_store():
# def reset_storage():
# def get_storage_verbose_level():
# def set_storage_verbose_level(level: int):


import hashlib
from typing import Dict
from studio.util import logs, util
from studio.storage import storage_setup
AWS_SECRET_KEY = 'secret_access_key'
AWS_SESSION_TOKEN = 'session_token'
AWS_REGION = 'region'
AWS_PROFILE = 'profile'
KEY_CREDENTIALS = 'credentials'
AWS_TYPE = 'aws'

# Credentials encapsulates the logic
# of basic access credentials handling
# for different kinds of studioml storage providers (S3, http, local etc.)
class Credentials:
    def __init__(self, cred_dict):
        self.logger = logs.get_logger(self.__class__.__name__)
        self.logger.setLevel(storage_setup.get_storage_verbose_level())

        self.type = None
        self.key = None
        self.secret_key = None
        self.session_token = None
        self.region = None
        self.profile = None
        if cred_dict is None:
            return

        if isinstance(cred_dict, str) and cred_dict == 'none':
            return

        if not isinstance(cred_dict, dict):
            msg: str =\
                "NOT SUPPORTED credentials format {0}".format(repr(cred_dict))

# Path: studio/util/logs.py
# DEBUG = logging.DEBUG
# INFO = logging.INFO
# ERROR = logging.ERROR
# def get_logger(name):
# def debug(line):
# def error(line):
# def info(line):
# 
# Path: studio/util/util.py
# DAY = 86400
# HOUR = 3600
# MINUTE = 60
# def remove_backspaces(line):
# def report_fatal(msg: str, logger):
# def sha256_checksum(filename, block_size=65536):
# def filehash(filename, block_size=65536, hashobj=None):
# def rand_string(length):
# def _looks_like_url(name):
# def parse_s3_path(qualified: str):
# def retry(f,
#           no_retries=5, sleep_time=1,
#           exception_class=BaseException, logger=None):
# def compression_to_extension(compression):
# def compression_to_taropt(compression):
# def _compression_to_extension_taropt(compression):
# def timeit(method):
#     def timed(*args, **kw):
# def sixdecode(sval):
# def shquote(sval):
# def parse_duration(duration_str):
# def parse_verbosity(verbosity=None):
# def str2duration(sval):
# def get_temp_filename() -> str:
# def delete_local_path(local_path: str, root: str, shallow: bool):
# def delete_local_folders(local_folder_path: str, root: str):
# def rm_rf(path):
# def check_for_kb_interrupt():
# def add_packages(list1, list2):
# 
# Path: studio/storage/storage_setup.py
# DB_KEY = "database"
# STORE_KEY = "store"
# def setup_storage(db_provider, artifact_store):
# def get_storage_db_provider():
# def get_storage_artifact_store():
# def reset_storage():
# def get_storage_verbose_level():
# def set_storage_verbose_level(level: int):


# Path: studio/credentials/credentials.py
import hashlib
from typing import Dict
from studio.util import logs, util
from studio.storage import storage_setup

AWS_SECRET_KEY = 'secret_access_key'
AWS_SESSION_TOKEN = 'session_token'
AWS_REGION = 'region'
AWS_PROFILE = 'profile'
KEY_CREDENTIALS = 'credentials'
AWS_TYPE = 'aws'

# Credentials encapsulates the logic
# of basic access credentials handling
# for different kinds of studioml storage providers (S3, http, local etc.)
class Credentials:
    def __init__(self, cred_dict):
        self.logger = logs.get_logger(self.__class__.__name__)
        self.logger.setLevel(storage_setup.get_storage_verbose_level())

        self.type = None
        self.key = None
        self.secret_key = None
        self.session_token = None
        self.region = None
        self.profile = None
        if cred_dict is None:
            return

        if isinstance(cred_dict, str) and cred_dict == 'none':
            return

        if not isinstance(cred_dict, dict):
            msg: str =\
                "NOT SUPPORTED credentials format {0}".format(repr(cred_dict))

            util.report_fatal(msg, self.logger)