def jobctrl_prefilter_f(self, line): if line.startswith('&'): pre, fn, rest = self.split_user_input(line[1:]) line = ip.expand_aliases(fn, rest) if not _jobq: return 'get_ipython().startjob(%s)' % genutils.make_quoted_expr( line) return 'get_ipython().jobq(%s)' % genutils.make_quoted_expr(line) raise TryNext
def handle(self, line_info): """Execute magic functions.""" ifun = line_info.ifun the_rest = line_info.the_rest cmd = '%sget_ipython().magic(%s)' % ( line_info.pre_whitespace, make_quoted_expr(ifun + " " + the_rest)) self.shell.log(line_info.line, cmd, line_info.continue_prompt) return cmd
def slash_prefilter_f(self,line): """ ./foo, ~/foo and /bin/foo now run foo as system command Removes the need for doing !./foo, !~/foo or !/bin/foo """ from IPython.utils import genutils if re.match('(?:[.~]|/[a-zA-Z_0-9]+)/', line): return "get_ipython().system(" + genutils.make_quoted_expr(line)+")" raise TryNext
def slash_prefilter_f(self, line): """ ./foo, ~/foo and /bin/foo now run foo as system command Removes the need for doing !./foo, !~/foo or !/bin/foo """ from IPython.utils import genutils if re.match('(?:[.~]|/[a-zA-Z_0-9]+)/', line): return "get_ipython().system(" + genutils.make_quoted_expr(line) + ")" raise TryNext
def transform(self, line, continue_prompt): m = _assign_magic_re.match(line) if m is not None: cmd = m.group('cmd') lhs = m.group('lhs') expr = make_quoted_expr(cmd) new_line = '%s = get_ipython().magic(%s)' % (lhs, expr) return new_line return line
def handle(self, line_info): """Handle alias input lines. """ transformed = self.alias_manager.expand_aliases( line_info.ifun, line_info.the_rest) # pre is needed, because it carries the leading whitespace. Otherwise # aliases won't work in indented sections. line_out = '%sget_ipython().system(%s)' % ( line_info.pre_whitespace, make_quoted_expr(transformed)) self.shell.log(line_info.line, line_out, line_info.continue_prompt) return line_out
def handle(self, line_info): """Execute the line in a shell, empty return value""" magic_handler = self.prefilter_manager.get_handler_by_name('magic') line = line_info.line if line.lstrip().startswith(ESC_SH_CAP): # rewrite LineInfo's line, ifun and the_rest to properly hold the # call to %sx and the actual command to be executed, so # handle_magic can work correctly. Note that this works even if # the line is indented, so it handles multi_line_specials # properly. new_rest = line.lstrip()[2:] line_info.line = '%ssx %s' % (ESC_MAGIC, new_rest) line_info.ifun = 'sx' line_info.the_rest = new_rest return magic_handler.handle(line_info) else: cmd = line.lstrip().lstrip(ESC_SHELL) line_out = '%sget_ipython().system(%s)' % ( line_info.pre_whitespace, make_quoted_expr(cmd)) # update cache/log and return self.shell.log(line, line_out, line_info.continue_prompt) return line_out