Skip to content

main

generate(no_input=False, offline=False, replay=False, overwrite=False, output_dir='.', config_file=None, skip_if_file_exists=False, default_config=False, password=None, directory=None, checkout=None)

Create Python Project, with CI/CD pipeline, from the project template.

Generate/Scaffold a new Python Project, including configuration enabling automations such as CI and Continuous Delivery of Docker and Python 'artifacts', and Continuous Documentation of the Python Project.

Source code in src/cookiecutter_python/backend/main.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def generate(
    # interactive=True,
    no_input=False,  # INTERACTIVE ON by Default
    offline=False,
    # extra_context=None,
    replay=False,
    overwrite=False,
    output_dir='.',
    config_file=None,
    skip_if_file_exists=False,
    # deprecated
    default_config=False,
    password=None,
    directory=None,
    checkout=None,
    ###
) -> str:
    """Create Python Project, with CI/CD pipeline, from the project template.

    Generate/Scaffold a new Python Project, including configuration enabling
    automations such as CI and Continuous Delivery of Docker and Python
    'artifacts', and Continuous Documentation of the Python Project.
    """
    print('Start Python Generator !')
    # Future HTTP requests to pypi.org and readthedocs.org web servers
    request = pre_main(
        Request(
            config_file=config_file,
            default_config=default_config,
            web_servers=WEB_SERVERS,
            no_input=no_input,
            extra_context=None,
            offline=offline,
        )
    )
    ## GENERATION from Template; delegate to Cookiecutter callable ##
    project_dir = generator(
        # COOKIECUTTER TEMPLATE (cookiecutter.json)
        os.path.abspath(os.path.join(my_dir, '..')),  # template dir path
        checkout=checkout,
        # no_input=no_input,
        no_input=True,
        extra_context=request.extra_context,
        replay=replay,
        overwrite_if_exists=overwrite,
        output_dir=output_dir,
        config_file=config_file,
        default_config=default_config,
        password=password,
        directory=directory,
        skip_if_file_exists=skip_if_file_exists,
    )
    ## POST GENERATION ##
    # Check if out-of-the-box Generated Project, coincidentally, requires slight modifications
    # for automatic and seemless "PyPI Upload" and "ReadTheDocs Build" process to
    # work. This can happen if the project name is already taken by another project
    # on PyPI or ReadTheDocs.
    post_main(request)

    print('Finished :)')
    return project_dir