|
@@ 39-55 (lines=17) @@
|
| 36 |
|
f.write("f = open('python_pre.txt', 'w')\n") |
| 37 |
|
f.write("f.close()\n") |
| 38 |
|
|
| 39 |
|
with open(os.path.join(hook_dir, 'pre_user_prompt.py'), 'w') as f: |
| 40 |
|
f.write("#!/usr/bin/env python\n") |
| 41 |
|
f.write("# -*- coding: utf-8 -*-\n") |
| 42 |
|
f.write("from __future__ import print_function\n") |
| 43 |
|
f.write("\n") |
| 44 |
|
f.write("print('pre user prompt hook')\n") |
| 45 |
|
f.write("f = open('python_pre_user_prompt.txt', 'w')\n") |
| 46 |
|
f.write("f.close()\n") |
| 47 |
|
|
| 48 |
|
if sys.platform.startswith('win'): |
| 49 |
|
post = 'post_gen_project.bat' |
| 50 |
|
with open(os.path.join(hook_dir, post), 'w') as f: |
| 51 |
|
f.write("@echo off\n") |
| 52 |
|
f.write("\n") |
| 53 |
|
f.write("echo post generation hook\n") |
| 54 |
|
f.write("echo. >shell_post.txt\n") |
| 55 |
|
else: |
| 56 |
|
post = 'post_gen_project.sh' |
| 57 |
|
filename = os.path.join(hook_dir, post) |
| 58 |
|
with open(filename, 'w') as f: |
|
@@ 132-146 (lines=15) @@
|
| 129 |
|
|
| 130 |
|
hook_path = os.path.join(self.hooks_path, 'post_gen_project.sh') |
| 131 |
|
|
| 132 |
|
if sys.platform.startswith('win'): |
| 133 |
|
post = 'post_gen_project.bat' |
| 134 |
|
with open(os.path.join(self.hooks_path, post), 'w') as f: |
| 135 |
|
f.write("@echo off\n") |
| 136 |
|
f.write("\n") |
| 137 |
|
f.write("echo post generation hook\n") |
| 138 |
|
f.write("echo. >{{cookiecutter.file}}\n") |
| 139 |
|
else: |
| 140 |
|
with open(hook_path, 'w') as fh: |
| 141 |
|
fh.write("#!/bin/bash\n") |
| 142 |
|
fh.write("\n") |
| 143 |
|
fh.write("echo 'post generation hook';\n") |
| 144 |
|
fh.write("touch 'shell_post.txt'\n") |
| 145 |
|
fh.write("touch '{{cookiecutter.file}}'\n") |
| 146 |
|
os.chmod(hook_path, os.stat(hook_path).st_mode | stat.S_IXUSR) |
| 147 |
|
|
| 148 |
|
hooks.run_script_with_context( |
| 149 |
|
os.path.join(self.hooks_path, self.post_hook), |