MCPcopy Index your code
hub / github.com/ipython/ipython / _make_script_magic

Method _make_script_magic

IPython/core/magics/script.py:147–171  ·  view source on GitHub ↗

make a named magic, that calls %%script with a particular program

(self, name)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 2

getMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected