Mercurial > piecrust2
comparison piecrust/commands/builtin/scaffolding.py @ 774:2bb3c1a04e98
prepare: Add ablity to run an editor program after creating the page file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 Jul 2016 16:44:18 -0700 |
parents | 87f1e79d3fbe |
children | 4850f8c21b6e |
comparison
equal
deleted
inserted
replaced
773:87f1e79d3fbe | 774:2bb3c1a04e98 |
---|---|
112 os.makedirs(os.path.dirname(path), 0o755) | 112 os.makedirs(os.path.dirname(path), 0o755) |
113 | 113 |
114 with open(path, 'w') as f: | 114 with open(path, 'w') as f: |
115 f.write(tpl_text) | 115 f.write(tpl_text) |
116 | 116 |
117 editor = ctx.app.config.get('prepare/editor') | |
118 editor_type = ctx.app.config.get('prepare/editor_type', 'exe') | |
119 if editor: | |
120 import shlex | |
121 shell = False | |
122 args = '%s "%s"' % (editor, path) | |
123 if '%path%' in editor: | |
124 args = editor.replace('%path%', path) | |
125 | |
126 if editor_type.lower() == 'shell': | |
127 shell = True | |
128 else: | |
129 args = shlex.split(args) | |
130 | |
131 import subprocess | |
132 logger.info("Running: %s" % args) | |
133 subprocess.Popen(args, shell=shell) | |
134 | |
117 | 135 |
118 class DefaultPrepareTemplatesCommandExtension(ChefCommandExtension): | 136 class DefaultPrepareTemplatesCommandExtension(ChefCommandExtension): |
119 """ Provides the default scaffolding templates to the `prepare` | 137 """ Provides the default scaffolding templates to the `prepare` |
120 command. | 138 command. |
121 """ | 139 """ |