make a named magic, that calls %%script with a particular program
(self, name)
| 127 | cell_magics[name] = self._make_script_magic(name) |
| 128 | |
| 129 | def _make_script_magic(self, name): |
| 130 | """make a named magic, that calls %%script with a particular program""" |
| 131 | # expand to explicit path if necessary: |
| 132 | script = self.script_paths.get(name, name) |
| 133 | |
| 134 | @magic_arguments.magic_arguments() |
| 135 | @script_args |
| 136 | def named_script_magic(line, cell): |
| 137 | # if line, add it as cl-flags |
| 138 | if line: |
| 139 | line = "%s %s" % (script, line) |
| 140 | else: |
| 141 | line = script |
| 142 | return self.shebang(line, cell) |
| 143 | |
| 144 | # write a basic docstring: |
| 145 | named_script_magic.__doc__ = \ |
| 146 | """%%{name} script magic |
| 147 | |
| 148 | Run cells with {script} in a subprocess. |
| 149 | |
| 150 | This is a shortcut for `%%script {script}` |
| 151 | """.format(**locals()) |
| 152 | |
| 153 | return named_script_magic |
| 154 | |
| 155 | @magic_arguments.magic_arguments() |
| 156 | @script_args |
no test coverage detected