How to use the cookiecutter.main.cookiecutter 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 jupyter-widgets / widget-ts-cookiecutter / tests / test_instantiate.py View on Github external
def example_instance(tmpdir_factory):
    from cookiecutter.main import cookiecutter
    import pip

    tmpdir = tmpdir_factory.mktemp('example_instance')

    with tmpdir.as_cwd():
        cookiecutter(PROJECT_ROOT, no_input=True, config_file=os.path.join(HERE, 'testconfig.yaml'))
        instance_path = tmpdir.join('jupyter-widget-testwidgets')
        with instance_path.as_cwd():
            print(str(instance_path))
            try:
                pip.main(['install', '-v', '-e', '.[test]'])
                yield instance_path
            finally:
                try:
                    pip.main(['uninstall', 'jupyter_widget_testwidgets', '-y'])
                except Exception:
                    pass
github cookiecutter / cookiecutter / tests / test_main.py View on Github external
def test_cookiecutter_local_with_input(self):
        if not PY3:
            sys.stdin = StringIO("\n\n\n\n\n\n\n\n\n\n\n\n")

        main.cookiecutter('tests/fake-repo-pre/', no_input=False)
        self.assertTrue(os.path.isdir('tests/fake-repo-pre/{{cookiecutter.repo_name}}'))
        self.assertFalse(os.path.isdir('tests/fake-repo-pre/fake-project'))
        self.assertTrue(os.path.isdir('fake-project'))
        self.assertTrue(os.path.isfile('fake-project/README.rst'))
        self.assertFalse(os.path.exists('fake-project/json/'))
github tetherless-world / whyis / whyis / commands / configure.py View on Github external
def run(self, extension_directory=None, extension_name=None):
        def rando():
            return b64encode(os.urandom(24)).decode('utf-8')

        # Create project from the cookiecutter-pypackage/ template
        extra_context = {'SECRET_KEY': rando(), 'SECURITY_PASSWORD_SALT': rando()}
        cookiecutter('config-template/', extra_context=extra_context)
github ansible / molecule / molecule / command / init.py View on Github external
Process templates as found in the named directory.

    :param template_dir: A string containing an absolute or relative path to a
     directory where the templates are located. If the provided directory is a
     relative path, it is resolved using a known location.
    :param extra_context: A dict of values that are used to override default
     or user specified values.
    :param output_dir: An string with an absolute path to a directory where the
     templates should be written to.
    :param overwrite: An optional bool whether or not to overwrite existing
     templates.
    :return: None
    """
    template_dir = _resolve_template_dir(template_dir)

    cookiecutter.main.cookiecutter(
        template_dir,
        extra_context=extra_context,
        output_dir=output_dir,
        overwrite_if_exists=overwrite,
        no_input=True, )
github plone / guillotina / guillotina / commands / create.py View on Github external
def run_cookie_cutter(self, arguments, tmpl_dir):
        try:
            from cookiecutter.main import cookiecutter
        except ImportError:
            sys.stderr.write(
                "You must have cookiecutter installed in order for the "
                "pcreate command to work.\n Use `pip install cookiecutter` "
                "to install cookiecutter.\n"
            )
            return 1
        cookiecutter(
            tmpl_dir,
            no_input=arguments.no_input,
            overwrite_if_exists=arguments.overwrite,
            output_dir=arguments.output,
        )
github mikeckennedy / cookiecutter-course / src / ch6_programatic_cookiecutter / src / game_maker.py View on Github external
def build_game(info):
    print("Building game {} of type {}, just a moment ...".format(
        info.project_name, info.game_type), flush=True)

    working_dir = os.path.abspath(os.path.dirname(__file__))
    template = os.path.join(working_dir, 'templates', 'cookiecutter-use-api')

    proj_dir = cookiecutter.main.cookiecutter(
        template,
        no_input=True,
        output_dir=info.working_dir,
        extra_context={
            'project_name': info.project_name,
            'full_name': info.full_name,
            'game_type': info.game_type
        }
    )

    return proj_dir
github datasnakes / OrthoEvolution / Manager / utils / mana.py View on Github external
is given to the class then it is given a name.  If not, cookiecutters
        takes input from the user.

        The base class will be the only class that allows cookiecutters parameter
        no_input to be False.
        """
        if self.repo:
            no_input = True
            e_c = {
                "repository_name": self.repo
            }
        else:
            no_input = False
            e_c = None
            # TODO-ROB change cookiecutter so that it can take pathlike objects
        cookiecutter(str(self.repo_cookie), no_input=no_input,
                     extra_context=e_c, output_dir=str(self.file_home))
        os.chmod(str(self.file_home / Path(self.repo)), mode=0o777)
github datasnakes / OrthoEvolution / Archive / mana.py View on Github external
def create_project(self):
        """
        :return: A new project inside the user's
        project directory.
        """
        if self.project:
            no_input = True
            e_c = {"project_name": self.project}
        else:
            no_input = False
            e_c = None
        cookiecutter(self.project_cookie, extra_context=e_c, no_input=no_input, output_dir=self.project_path)
github datasnakes / OrthoEvolution / OrthoEvol / Cookies / cookie_jar.py View on Github external
def bake_the_user(self, cookie_jar=None):
        self.cookielog.warn('Creating directories from the User Cookie template.')
        """
        This function uses the username given by our FLASK framework
        and creates a new directory system for the active user using
        our  new_user cookiecutter template.
        """
        if cookie_jar:
            self.cookie_jar = cookie_jar

        # This is used ONLY when the user registers in flask
        # TODO-ROB:  Create the cookiecutter.json file

        # extra_context overrides user and default configs
        cookiecutter(str(self.Recipes.user_cookie), no_input=True, extra_context={
            "user_name": self.user}, output_dir=str(self.cookie_jar))

        # Change user permissions with flask later (this is for testing
        # purposes
        os.chmod(str(self.cookie_jar / Path(self.user)), mode=0o777)
        self.cookielog.info('Directories have been created for the user, %s. ✔' % self.user)