# Path: cellpy/exceptions.py
# class ConfigFileNotWritten(Error):
#     """Raised when the configuration file cannot be written"""
# 
#     pass
# 
# Path: cellpy/parameters/prmreader.py
# DEFAULT_FILENAME_START = ".cellpy_prms_"
# DEFAULT_FILENAME_END = ".conf"
# USE_MY_DOCUMENTS = False
# DEFAULT_FILENAME = DEFAULT_FILENAME_START + "default" + DEFAULT_FILENAME_END
# def get_user_name():
# def create_custom_init_filename(user_name=None):
# def get_user_dir_and_dst(init_filename=None):
# def get_user_dir():
# def _write_prm_file(file_name=None):
# def _update_prms(config_dict):
# def _convert_instruments_to_dict(x):
# def _convert_to_dict(x):
# def _pack_prms():
# def _read_prm_file(prm_filename):
# def _read_prm_file_without_updating(prm_filename):
# def __look_at(file_name):
# def _get_prm_file(file_name=None, search_order=None):
# def _save_current_prms_to_user_dir():
# def info():
# def main():


import base64
import getpass
import logging
import os
import pathlib
import re
import subprocess
import sys
import urllib
import click
import pkg_resources
import cellpy._version
        import cellpy
    import platform
            import adodbapi as dbloader
                import pyodbc as dbloader
                import pypyodbc as dbloader
                import editor
        import papermill as pm
    import platform
    import urllib.request
        import cookiecutter.exceptions
        import cookiecutter.main
        import cookiecutter.prompt
            import papermill as pm
    import pathlib
    import sys
from pathlib import Path
from github import Github
from cellpy.exceptions import ConfigFileNotWritten
from cellpy.parameters import prmreader
        from cellpy import log
        from cellpy.readers import cellreader
    from cellpy.parameters import prms
        from subprocess import PIPE, run
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.parameters import prms
    from cellpy.parameters import prms
    from click.testing import CliRunner
    from pprint import pprint

    if os.path.isfile(dst_file):
        click.echo("[cellpy] (setup) File already exists!")
        click.echo("[cellpy] (setup) Keeping most of the old configuration parameters")
    try:
        if dry_run:
            click.echo(
                f"*** dry-run: skipping actual saving of {dst_file} ***", color="red"
            )
        else:
            click.echo(f"[cellpy] (setup) Saving file ({dst_file})")
            save_prm_file(dst_file)

    except ConfigFileNotWritten:
        click.echo("[cellpy] (setup) Something went wrong! Could not write the file")
        click.echo(
            "[cellpy] (setup) Trying to write a file"
            + f"called {prmreader.DEFAULT_FILENAME} instead"
        )

        try:
            userdir, dst_file = prmreader.get_user_dir_and_dst(init_filename)
            if dry_run:
                click.echo(
                    f"*** dry-run: skipping actual saving of {dst_file} ***",
                    color="red",
                )
            else:
                save_prm_file(dst_file)


# Path: cellpy/exceptions.py
# class ConfigFileNotWritten(Error):
#     """Raised when the configuration file cannot be written"""
# 
#     pass
# 
# Path: cellpy/parameters/prmreader.py
# DEFAULT_FILENAME_START = ".cellpy_prms_"
# DEFAULT_FILENAME_END = ".conf"
# USE_MY_DOCUMENTS = False
# DEFAULT_FILENAME = DEFAULT_FILENAME_START + "default" + DEFAULT_FILENAME_END
# def get_user_name():
# def create_custom_init_filename(user_name=None):
# def get_user_dir_and_dst(init_filename=None):
# def get_user_dir():
# def _write_prm_file(file_name=None):
# def _update_prms(config_dict):
# def _convert_instruments_to_dict(x):
# def _convert_to_dict(x):
# def _pack_prms():
# def _read_prm_file(prm_filename):
# def _read_prm_file_without_updating(prm_filename):
# def __look_at(file_name):
# def _get_prm_file(file_name=None, search_order=None):
# def _save_current_prms_to_user_dir():
# def info():
# def main():


# Path: cellpy/cli.py
import base64
import getpass
import logging
import os
import pathlib
import re
import subprocess
import sys
import urllib
import click
import pkg_resources
import cellpy._version
        import cellpy
    import platform
            import adodbapi as dbloader
                import pyodbc as dbloader
                import pypyodbc as dbloader
                import editor
        import papermill as pm
    import platform
    import urllib.request
        import cookiecutter.exceptions
        import cookiecutter.main
        import cookiecutter.prompt
            import papermill as pm
    import pathlib
    import sys
from pathlib import Path
from github import Github
from cellpy.exceptions import ConfigFileNotWritten
from cellpy.parameters import prmreader
        from cellpy import log
        from cellpy.readers import cellreader
    from cellpy.parameters import prms
        from subprocess import PIPE, run
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.utils import batch
    from cellpy import prms
    from cellpy.parameters import prms
    from cellpy.parameters import prms
    from click.testing import CliRunner
    from pprint import pprint


    if os.path.isfile(dst_file):
        click.echo("[cellpy] (setup) File already exists!")
        click.echo("[cellpy] (setup) Keeping most of the old configuration parameters")
    try:
        if dry_run:
            click.echo(
                f"*** dry-run: skipping actual saving of {dst_file} ***", color="red"
            )
        else:
            click.echo(f"[cellpy] (setup) Saving file ({dst_file})")
            save_prm_file(dst_file)

    except ConfigFileNotWritten:
        click.echo("[cellpy] (setup) Something went wrong! Could not write the file")
        click.echo(
            "[cellpy] (setup) Trying to write a file"
            + f"called {prmreader.DEFAULT_FILENAME} instead"
        )

        try:
            userdir, dst_file = prmreader.get_user_dir_and_dst(init_filename)
            if dry_run:
                click.echo(
                    f"*** dry-run: skipping actual saving of {dst_file} ***",
                    color="red",
                )
            else:
                save_prm_file(dst_file)


        except ConfigFileNotWritten: