當前位置: 首頁>>代碼示例>>Python>>正文


Python cookiecutter.main方法代碼示例

本文整理匯總了Python中cookiecutter.main.cookiecutter.main方法的典型用法代碼示例。如果您正苦於以下問題:Python cookiecutter.main方法的具體用法?Python cookiecutter.main怎麽用?Python cookiecutter.main使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cookiecutter.main.cookiecutter的用法示例。


在下文中一共展示了cookiecutter.main方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
def main(watch):
    # Regenerate at least once.
    regenerate()

    if watch:
        observer = Observer()

        # Observe both the template directory and cookiecutter.json.
        observer.schedule(RegenerateSugardoughHandler(), TEMPLATEDIR, recursive=True)
        cookiecutter_json_handler = RegenerateSugardoughHandler(patterns=[
            os.path.join(BASEDIR, 'cookiecutter.json')
        ])
        observer.schedule(cookiecutter_json_handler, BASEDIR)

        print('Watching for changes...')
        observer.start()
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            observer.stop()
        observer.join() 
開發者ID:mozilla,項目名稱:sugardough,代碼行數:24,代碼來源:regenerate.py

示例2: example_instance

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
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 
開發者ID:jupyter-widgets,項目名稱:widget-ts-cookiecutter,代碼行數:21,代碼來源:test_instantiate.py

示例3: main

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
def main() -> int:
    """ Execute the test.
    
    """
    # TODO: Convert to f-strings when Python 3.5 support is dropped.
    template = Path(__file__).resolve().parents[1]
    defaults = loads(template.joinpath("cookiecutter.json").read_text())
    with TemporaryDirectory() as tmpdir:
        cookiecutter(str(template), no_input=True, output_dir=tmpdir)
        cwd = Path(tmpdir) / defaults["project_slug"]
        create(str(cwd / "venv"), with_pip=True)
        bin = str(cwd / "venv" / "bin")  # TODO: Python 3.5 workaround
        pip = which("pip", path=bin) or "pip"  # Travis CI workaround
        install = "{:s} install .".format(pip)
        for req in cwd.glob("**/requirements.txt"):
            install = " ".join((install, "--requirement={!s}".format(req)))
        cwd = str(cwd)  # TODO: Python 3.5 workaround
        check_call(split(install), cwd=cwd)
        pytest = which("pytest", path=bin) or "pytest"  # Travis CI workaround
        check_call(split("{:s} --verbose test".format(pytest)), cwd=cwd)
    return 0
    
    
# Make the script executable. 
開發者ID:mdklatt,項目名稱:cookiecutter-python-app,代碼行數:26,代碼來源:test_template.py

示例4: main

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
def main():
    args = parse_arguments()
    template_path = str(parent / "template")

    kwargs = {}

    if args.get("name"):
        kwargs = {
            "no_input": True,
            "extra_context": {
                "project_name": args.get("name"),
                "use_postgres": "n" if args.get("without_postgres") else "y",
                "use_redis": "y" if args.get("redis") else "n",
                "use_uvloop": "y" if args.get("uvloop") else "n",
            },
        }

    try:
        result = cookiecutter(template_path, **kwargs)
    except (FailedHookException, OutputDirExistsException) as exc:
        if isinstance(exc, OutputDirExistsException):
            echo(
                click.style(
                    "\n\nDirectory with such name already exists!\n", fg="red")
            )
        return

    folder = Path(result).name

    echo(click.style("\n\nSuccessfully generated!\n", fg="bright_green",))
    echo("cd " + click.style(f"{folder}/", fg="bright_blue"))
    show_commands(folder) 
開發者ID:aio-libs,項目名稱:create-aio-app,代碼行數:34,代碼來源:main.py

示例5: main

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
def main():
    args = parse_args()
    paasta_fsm(args) 
開發者ID:Yelp,項目名稱:paasta,代碼行數:5,代碼來源:fsm_cmd.py

示例6: main

# 需要導入模塊: from cookiecutter.main import cookiecutter [as 別名]
# 或者: from cookiecutter.main.cookiecutter import main [as 別名]
def main():
    cmds() 
開發者ID:bottlepy,項目名稱:bottle-boilerplate,代碼行數:4,代碼來源:bottle_boilerplate.py


注:本文中的cookiecutter.main.cookiecutter.main方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。