make a named magic, that calls %%script with a particular program
(self, name)
| 145 | cell_magics[name] = self._make_script_magic(name) |
| 146 | |
| 147 | def _make_script_magic(self, name): |
| 148 | """make a named magic, that calls %%script with a particular program""" |
| 149 | # expand to explicit path if necessary: |
| 150 | script = self.script_paths.get(name, name) |
| 151 | |
| 152 | @magic_arguments.magic_arguments() |
| 153 | @script_args |
| 154 | def named_script_magic(line, cell): |
| 155 | # if line, add it as cl-flags |
| 156 | if line: |
| 157 | line = "%s %s" % (script, line) |
| 158 | else: |
| 159 | line = script |
| 160 | return self.shebang(line, cell) |
| 161 | |
| 162 | # write a basic docstring: |
| 163 | named_script_magic.__doc__ = \ |
| 164 | """%%{name} script magic |
| 165 | |
| 166 | Run cells with {script} in a subprocess. |
| 167 | |
| 168 | This is a shortcut for `%%script {script}` |
| 169 | """.format(**locals()) |
| 170 | |
| 171 | return named_script_magic |
| 172 | |
| 173 | @magic_arguments.magic_arguments() |
| 174 | @script_args |
no test coverage detected