本文整理汇总了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()
示例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
示例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.
示例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)
示例5: main
# 需要导入模块: from cookiecutter.main import cookiecutter [as 别名]
# 或者: from cookiecutter.main.cookiecutter import main [as 别名]
def main():
args = parse_args()
paasta_fsm(args)
示例6: main
# 需要导入模块: from cookiecutter.main import cookiecutter [as 别名]
# 或者: from cookiecutter.main.cookiecutter import main [as 别名]
def main():
cmds()