MCPcopy Create free account
hub / github.com/ipython/ipython / _make_script_magic

Method _make_script_magic

IPython/core/magics/script.py:129–153  ·  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

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

Callers 1

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected