How to use the cookiecutter.utils.rmtree function in cookiecutter

To help you get started, we’ve selected a few cookiecutter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cookiecutter / cookiecutter / tests / test_cli.py View on Github external
def fin_remove_fake_project_dir():
        if os.path.isdir('fake-project'):
            utils.rmtree('fake-project')
    request.addfinalizer(fin_remove_fake_project_dir)
github cookiecutter / cookiecutter / tests / test_generate_files.py View on Github external
def fin_remove_additional_folders():
        if os.path.exists('inputpizzä'):
            utils.rmtree('inputpizzä')
        if os.path.exists('inputgreen'):
            utils.rmtree('inputgreen')
        if os.path.exists('inputbinary_files'):
            utils.rmtree('inputbinary_files')
        if os.path.exists('tests/custom_output_dir'):
            utils.rmtree('tests/custom_output_dir')
        if os.path.exists('inputpermissions'):
            utils.rmtree('inputpermissions')
    request.addfinalizer(fin_remove_additional_folders)
github cookiecutter / cookiecutter / tests / test_examples.py View on Github external
def tearDown(self):
        with utils.work_in(config.DEFAULT_CONFIG['cookiecutters_dir']):
            if os.path.isdir('cookiecutter-pypackage'):
                utils.rmtree('cookiecutter-pypackage')
        if os.path.isdir('boilerplate'):
            utils.rmtree('boilerplate')
        super(TestGitBranch, self).tearDown()
github davidemoro / cookiecutter-qa / tests / test_bake_project.py View on Github external
def bake_in_temp_dir(cookies, *args, **kwargs):
    """
    Delete the temporal directory that is created when executing the tests
    :param cookies: pytest_cookies.Cookies, cookie to be baked and its
                    temporalfiles will be removed
    """
    result = cookies.bake(*args, **kwargs)
    try:
        yield result
    finally:
        rmtree(str(result.project))
github cookiecutter / cookiecutter / tests / test_output_folder.py View on Github external
def finalizer_remove_output_folder():
        if os.path.exists('output_folder'):
            utils.rmtree('output_folder')
    request.addfinalizer(finalizer_remove_output_folder)
github cookiecutter / cookiecutter / tests / test_vcs_prompt.py View on Github external
def remove_cookiecutter_dirs():
        if os.path.isdir('cookiecutter-pypackage'):
            utils.rmtree('cookiecutter-pypackage')
        if os.path.isdir('cookiecutter-trytonmodule'):
            utils.rmtree('cookiecutter-trytonmodule')
    request.addfinalizer(remove_cookiecutter_dirs)
github cookiecutter / cookiecutter / tests / test_cookiecutter_local_no_input.py View on Github external
def fin_remove_additional_dirs():
        if os.path.isdir('fake-project'):
            utils.rmtree('fake-project')
        if os.path.isdir('fake-project-extra'):
            utils.rmtree('fake-project-extra')
        if os.path.isdir('fake-project-templated'):
            utils.rmtree('fake-project-templated')
        if os.path.isdir('fake-project-dict'):
            utils.rmtree('fake-project-dict')
        if os.path.isdir('fake-tmp'):
            utils.rmtree('fake-tmp')
    request.addfinalizer(fin_remove_additional_dirs)
github NathanUrwin / cookiecutter-git / tests / test_bake_project.py View on Github external
"""
    Delete the temporal directory that is created when executing the tests.

    https://github.com/audreyr/cookiecutter-pypackage/blob/master/tests/test_bake_project.py#L33

    :param cookies: pytest_cookies.Cookies, cookie to be baked and its temporal files will be removed
    """
    with git_disable_gpgsign():
        extra_context = kwargs.pop("extra_context", {})
        extra_context["_testing"] = True
        result = cookies.bake(*args, extra_context=extra_context, **kwargs)
        try:
            yield result
        finally:
            if result.project:
                rmtree(str(result.project))
github cookiecutter / cookiecutter / cookiecutter / generate.py View on Github external
delete_project_on_failure):
    """Run hook from repo directory, clean project directory if hook fails.

    :param repo_dir: Project template input directory.
    :param hook_name: The hook to execute.
    :param project_dir: The directory to execute the script from.
    :param context: Cookiecutter project context.
    :param delete_project_on_failure: Delete the project directory on hook
        failure?
    """
    with work_in(repo_dir):
        try:
            run_hook(hook_name, project_dir, context)
        except FailedHookException:
            if delete_project_on_failure:
                rmtree(project_dir)
            logger.error(
                "Stopping generation because {} hook "
                "script didn't exit successfully".format(hook_name)
            )
            raise