# Path: ricloud/conf.py
# DEFAULT_CONF_NAME = "ricloud.ini"
# def get_config(config_name=DEFAULT_CONF_NAME):
# def get_user_root_config_path(config_name=DEFAULT_CONF_NAME):
# def get(setting_section, setting_name):
# def getint(setting_section, setting_name):
# def getboolean(setting_section, setting_name):
# 
# Path: ricloud/storage.py
# def download_result(url, to_filename=None):
# def download_result_from_gs(bucket_name, blob_name, to_filename=None):
# def download_result_from_s3(bucket_name, blob_name, to_filename=None):
# def download_result_from_local(blob_name, to_filename=None):
# 
# Path: ricloud/utils.py
# def log_debug(message, *args, **kwargs):
# def log_info(message, *args, **kwargs):
# def generate_timestamp():
# def _encode(data):
# def encode(data):
# def expanded_encode(data):
#     def default(self, data):
# def pretty_print(data):
# def encode_json(data, indent=None):
# def decode_json(data):
# def encode_b64(data):
# def decode_b64(data):
# def transform_csv_file_to_json(file_object):
# def join_url(base, url, allow_fragments=True):
# def get_url_path(url):
# def escape(string):
# def get_md5_hash(data, hex_encode=True):
# def get_path_extension(path):
# def get_directory_from_path(path):
# def ensure_directory_exists(directory):
# def ensure_path_exists(path):
# def get_filename(*args):
# class DataEncoder(json.JSONEncoder):
# class ExpandedDataEncoder(DataEncoder):
# 
# Path: ricloud/samples/utils.py
# def info(message):
#     click.secho(message, fg="yellow")
# 
# def warn(message):
#     click.secho(message, fg="red")
# 
# def success(message):
#     click.secho(message, fg="green")
# 
# def await_response(resource, timeout=60):
#     """Poll the API until processing resolves or the timeout is reached."""
#     timeout_time = time.time() + timeout
#     while resource.state in ("pending", "processing") and time.time() < timeout_time:
# 
#         time.sleep(1)
# 
#         resource.refresh()


import click
import ricloud
from ricloud import conf
from ricloud import storage
from ricloud import utils
from .utils import info, warn, success, await_response
            payload = {"files": file_ids}

            cascade_poll = create_poll(
                payload, session=poll["session"], source=poll["source"]
            )

            _, cascade_files = download_results(cascade_poll.results, poll=poll)

            files.update(cascade_files)

    return result_data, files


def download_result(result, to_filename=None, poll=None):
    success("Downloading result {}:".format(result["id"]))
    success(" - identifier {}".format(result["identifier"]))
    success(" - stored at {}".format(result["url"]))

    if not to_filename:
        to_filename = utils.escape(result["identifier"])
        poll_id = poll["id"] if poll else result["poll"]
        to_filename = utils.get_filename(poll_id, to_filename)

    storage.download_result(result["url"], to_filename=to_filename)

    is_json = result["type"] == "json"

    if is_json:
        with open(to_filename, "rb") as f:
            raw_result_data = f.read()

# Path: ricloud/conf.py
# DEFAULT_CONF_NAME = "ricloud.ini"
# def get_config(config_name=DEFAULT_CONF_NAME):
# def get_user_root_config_path(config_name=DEFAULT_CONF_NAME):
# def get(setting_section, setting_name):
# def getint(setting_section, setting_name):
# def getboolean(setting_section, setting_name):
# 
# Path: ricloud/storage.py
# def download_result(url, to_filename=None):
# def download_result_from_gs(bucket_name, blob_name, to_filename=None):
# def download_result_from_s3(bucket_name, blob_name, to_filename=None):
# def download_result_from_local(blob_name, to_filename=None):
# 
# Path: ricloud/utils.py
# def log_debug(message, *args, **kwargs):
# def log_info(message, *args, **kwargs):
# def generate_timestamp():
# def _encode(data):
# def encode(data):
# def expanded_encode(data):
#     def default(self, data):
# def pretty_print(data):
# def encode_json(data, indent=None):
# def decode_json(data):
# def encode_b64(data):
# def decode_b64(data):
# def transform_csv_file_to_json(file_object):
# def join_url(base, url, allow_fragments=True):
# def get_url_path(url):
# def escape(string):
# def get_md5_hash(data, hex_encode=True):
# def get_path_extension(path):
# def get_directory_from_path(path):
# def ensure_directory_exists(directory):
# def ensure_path_exists(path):
# def get_filename(*args):
# class DataEncoder(json.JSONEncoder):
# class ExpandedDataEncoder(DataEncoder):
# 
# Path: ricloud/samples/utils.py
# def info(message):
#     click.secho(message, fg="yellow")
# 
# def warn(message):
#     click.secho(message, fg="red")
# 
# def success(message):
#     click.secho(message, fg="green")
# 
# def await_response(resource, timeout=60):
#     """Poll the API until processing resolves or the timeout is reached."""
#     timeout_time = time.time() + timeout
#     while resource.state in ("pending", "processing") and time.time() < timeout_time:
# 
#         time.sleep(1)
# 
#         resource.refresh()


# Path: ricloud/samples/helpers.py
import click
import ricloud
from ricloud import conf
from ricloud import storage
from ricloud import utils
from .utils import info, warn, success, await_response

            payload = {"files": file_ids}

            cascade_poll = create_poll(
                payload, session=poll["session"], source=poll["source"]
            )

            _, cascade_files = download_results(cascade_poll.results, poll=poll)

            files.update(cascade_files)

    return result_data, files


def download_result(result, to_filename=None, poll=None):
    success("Downloading result {}:".format(result["id"]))
    success(" - identifier {}".format(result["identifier"]))
    success(" - stored at {}".format(result["url"]))

    if not to_filename:
        to_filename = utils.escape(result["identifier"])
        poll_id = poll["id"] if poll else result["poll"]
        to_filename = utils.get_filename(poll_id, to_filename)

    storage.download_result(result["url"], to_filename=to_filename)

    is_json = result["type"] == "json"

    if is_json:
        with open(to_filename, "rb") as f:
            raw_result_data = f.read()

        result_data = utils.decode_json(raw_result_data)