当前位置: 首页>>代码示例>>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;未经允许,请勿转载。