MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / parse_external

Method parse_external

pythonwhat/State.py:221–245  ·  view source on GitHub ↗
(self, code)

Source from the content-addressed store, hash-verified

219 )
220
221 def parse_external(self, code):
222 res = (None, None)
223 try:
224 return self.ast_dispatcher.parse(code)
225 except IndentationError as e:
226 e.filename = "script.py"
227 # no line info for now
228 self.report(
229 "Your code could not be parsed due to an error in the indentation:<br>`%s.`"
230 % str(e)
231 )
232
233 except SyntaxError as e:
234 e.filename = "script.py"
235 # no line info for now
236 self.report(
237 "Your code can not be executed due to a syntax error:<br>`%s.`" % str(e)
238 )
239
240 # Can happen, can't catch this earlier because we can't differentiate between
241 # TypeError in parsing or TypeError within code (at runtime).
242 except:
243 self.report("Something went wrong while parsing your code.")
244
245 return res
246
247 def parse_internal(self, code):
248 try:

Callers

nothing calls this directly

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected