class BasePythonQueryHook
Public Instance Methods
command_line(filename)
click to toggle source
# File lib/base/query_hook.rb, line 5 def command_line(filename) "python #{filename} 2>&1" end
compile_file_content(req)
click to toggle source
# File lib/base/query_hook.rb, line 9 def compile_file_content(req) "#{compile_file_header(req)}\n#{compile_query(req.query)}" end
compile_file_header(req)
click to toggle source
# File lib/base/query_hook.rb, line 13 def compile_file_header(req) <<python import string, sys, os #{req.extra} #{req.content} sys.stdout = open(os.devnull, 'w') #{compile_cookie(req.cookie)} sys.stdout = sys.__stdout__ python end
compile_state(cookie)
click to toggle source
# File lib/base/query_hook.rb, line 26 def compile_state(cookie) (cookie||[]).map do |statement| <<~python try: #{statement} except: pass python end end
error_patterns()
click to toggle source
# File lib/base/query_hook.rb, line 41 def error_patterns [ Mumukit::ErrorPattern::Errored.new(syntax_error_regexp) ] end
syntax_error_regexp()
click to toggle source
# File lib/base/query_hook.rb, line 47 def syntax_error_regexp /(SyntheticMumukiSyntaxError: )|((\A File .*\n)?(?m)(?=.*(SyntaxError|IndentationError)))/ end