本文整理匯總了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()