General helper functions

check_git_dir[source]

check_git_dir()

Check whether there is a .git directory in your current folder

check_project_root[source]

check_project_root(func)

Check that the user is on the project root directory by checking if there is a .git folder before running func

read_credentials[source]

read_credentials(path)

Read credentials from path

if not check_git_dir():
    os.chdir("..")  # we need this if we test locally in the notebook itself
input_credentials = "user = SomeUser\npassword = SomePassword"
expected_credentials = {"user": "SomeUser", "password": "SomePassword"}
with tempfile.TemporaryDirectory() as tmp_dir:
    tmp_file = os.path.join(tmp_dir, "tmp")
    with open(tmp_file, "w") as f:
        f.write(input_credentials)
    credentials = read_credentials(tmp_file)
assert credentials == expected_credentials

get_config[source]

get_config()

Get config from settings.ini

get_template[source]

get_template(name)

Get template with filename name

update_gitignore[source]

update_gitignore()

Update .gitignore with stuff we do not want to track

write_settings_ini[source]

write_settings_ini(project_type)

Write settings.ini from template

write_setup_py[source]

write_setup_py()

Write setup.py from template

write_conda_build_scripts[source]

write_conda_build_scripts()

Write bld.bat and build.sh scripts for building conda packages

get_conda_env_packages[source]

get_conda_env_packages()

Get conda environment packages

get_anaconda_credentials[source]

get_anaconda_credentials()

Get anaconda credentials from .anaconda-credentials in your home or project root directory

get_pypi_credentials[source]

get_pypi_credentials()

Get pypi credentials from .pypi-credentials in your home or project root directory

write_init_version[source]

write_init_version()

Write version in init.py if it is a package

run_tests[source]

run_tests(func)

Run pytest or nbdev_test_nbs before calling function