This commit is contained in:
Vitor Santos Costa 2018-10-15 10:32:33 +01:00
commit a03aa3c27c
2 changed files with 878 additions and 1093 deletions

File diff suppressed because it is too large Load Diff

View File

@ -116,7 +116,7 @@ class YAPInputSplitter(InputSplitter):
line = text.rstrip() line = text.rstrip()
self.errors = [] self.errors = []
engine.mgoal(errors(self, line),"user",True) engine.mgoal(errors(self, line),"user",True)
return self.errors != [] return self.errors == []
def reset(self): def reset(self):
@ -496,12 +496,13 @@ class YAPCompleter(Completer):
completions are coming from different sources this function does not completions are coming from different sources this function does not
ensure that each completion object will only be present once. ensure that each completion object will only be present once.
""" """
if text[0] == '%' and text.find('\n') > offset:
magic_res = self.magic_matches(text)
return text, magic_res
self.matches = [] self.matches = []
prolog_res = self.shell.yapeng.mgoal(completions(text, self), "user",True) prolog_res = self.shell.yapeng.mgoal(completions(text, self), "user",True)
if self.matches: return text, self.matches
return text, self.matches
magic_res = self.magic_matches(text)
return text, magic_res
@ -643,6 +644,7 @@ class YAPRun:
# variable names should match strings # variable names should match strings
# ask = True # ask = True
# launch the query # launch the query
cell = raw_cell # cell has to exist so it can be stored/logged
info = interactiveshell.ExecutionInfo( info = interactiveshell.ExecutionInfo(
@ -679,7 +681,6 @@ class YAPRun:
# cell = self.shell.input_transformer_manager.transform_cell(raw_cell) # cell = self.shell.input_transformer_manager.transform_cell(raw_cell)
# except SyntaxError: # except SyntaxError:
# preprocessing_exc_tuple = self.shell.syntax_error() # sys.exc_info() # preprocessing_exc_tuple = self.shell.syntax_error() # sys.exc_info()
cell = raw_cell # cell has to exist so it can be stored/logged
for i in self.errors: for i in self.errors:
try: try:
(_,lin,pos,text) = i (_,lin,pos,text) = i
@ -707,31 +708,23 @@ class YAPRun:
# compiler = self.shell.compile if shell_futures else CachingCompiler() # compiler = self.shell.compile if shell_futures else CachingCompiler()
self.cell_name = str( self.shell.execution_count) self.cell_name = str( self.shell.execution_count)
if cell[0] == '%': if cell[0] == '%':
txt0 = cell.split(maxsplit = 1, sep = '\n')
if cell[1] == '%': if cell[1] == '%':
linec = False linec = False
mcell = cell.lstrip('%%') magic = txt[0].lstrip('%%').strip()
body = txt[1]
self.result = True, self.shell.run_cell_magic(magic, line, body)
else: else:
linec = True linec = True
mcell = cell.lstrip('%') magic = cell.lstrip('%').strip()
txt0 = mcell.split(maxsplit = 2, sep = '\n')
txt = txt0[0].split(maxsplit = 2) txt = txt0[0].split(maxsplit = 2)
magic = txt[0] magic = txt[0]
if len(txt) == 2: self.shell.run_line_magic(magic, line)
line = txt[1]
else:
line = ""
if linec:
self.shell.run_line_magic(magic, line)
else:
if len(txt0) == 1:
cell = ""
else:
body = txt0[1]+'\n'+txt0[2]
self.result = True, self.shell.run_cell_magic(magic, line, body)
return self.result
# Give the displayhook a reference to our ExecutionResult so it # Give the displayhook a reference to our ExecutionResult so it
# can fill in the output value. # can fill in the output value.
self.shell.displayhook.exec_result = self.result self.shell.displayhook.exec_result = self.result
if syntaxErrors(self, text):
self.result.result = False
has_raised = False has_raised = False
try: try:
self.yapeng.mgoal(streams(True),"user", True) self.yapeng.mgoal(streams(True),"user", True)
@ -743,7 +736,7 @@ class YAPRun:
# trace=1, # trace=1,
# count=0) # count=0)
# #
# def f(self, cell, state): # def f(self, cell, state):
# state = self.jupyter_query( cell ) # state = self.jupyter_query( cell )