app/controllers/preprocessor/python/python_preprocessor.rb
def error_line(line)
    # A previously processed error line may cause us to drop the current one
    if @drop_next_error_line
      @drop_next_error_line = false
      return {:type => :no}
    end

    stripped_line = line.strip

    # We always throw away lines that start with certain prefixes
    throw_away_prefixes = ["Traceback ", 'File "<string>"', "SyntaxError: "]
    if stripped_line.start_with?(*throw_away_prefixes)
      return {:type => :no}
    end

    # Recognize the syntax error message
    match = /File \"\", line (\d+)/.match(stripped_line)
    if match
      # Note that at this point, we haven't inserted any code yet, so there's no need to convert
      # any line numbers
      return {:type => :error, :message => "Syntaxfehler in Zeile #{match[1]}:"}
    end

    # Recognize the first runtime error message
    match = /File \"pyraten.py\", line (\d+), in <module>/.match(stripped_line)
    if match
      # We need to convert line numbers
      ln = original_line_number(match[1]).to_s
      return {:type => :error, :message => "Laufzeitfehler in Zeile #{ln}:"}
    end

    # Recognize further runtime error messages
    match = /File \"[^\"]+\", line (\d+), in turn/.match(stripped_line)
    if match
      # Ignore this and the next line
      @drop_next_error_line = true
      return {:type => :no}
    end

    # Recognize the syntax error marker
    if stripped_line == "^"
      return {:type => :error, :message => line}
    end

    # It is some other line; be sure to remove any trailing end-of-line comment
    return {:type => :error, :message => PythonCodeAugmenter.remove_line_number(line)}
  end
# Takes a line of an error message and makes it ready to be presented to the user.
Takes a line of an error message and makes it ready to be presented to the user.
Takes a line of an error message and makes it ready to be presented to the user .
def error_line(line)
    if @drop_next_error_line
      @drop_next_error_line = false
      return {:type => :no}
    end
    stripped_line = line.strip
    throw_away_prefixes = ["Traceback ", 'File "<string>"', "SyntaxError: "]
    if stripped_line.start_with?(*throw_away_prefixes)
      return {:type => :no}
    end
    match = /File \"\", line (\d+)/.match(stripped_line)
    if match
      return {:type => :error, :message => "Syntaxfehler in Zeile #{match[1]}:"}
    end
    match = /File \"pyraten.py\", line (\d+), in <module>/.match(stripped_line)
    if match
      ln = original_line_number(match[1]).to_s
      return {:type => :error, :message => "Laufzeitfehler in Zeile #{ln}:"}
    end
    match = /File \"[^\"]+\", line (\d+), in turn/.match(stripped_line)
    if match
      @drop_next_error_line = true
      return {:type => :no}
    end
    if stripped_line == "^"
      return {:type => :error, :message => line}
    end
    return {:type => :error, :message => PythonCodeAugmenter.remove_line_number(line)}
  end
def error_line ( line ) if @drop_next_error_line @drop_next_error_line = false return { :type => :no } end stripped_line = line . strip throw_away_prefixes = [ "Traceback " , 'File "<string>"' , "SyntaxError: " ] if stripped_line . start_with? ( * throw_away_prefixes ) return { :type => :no } end match = / File  \" \" , line ( \d +) / . match ( stripped_line ) if match return { :type => :error , :message => "Syntaxfehler in Zeile #{match[1]}:" } end match = / File  \" pyraten.py \" , line ( \d +), in <module> / . match ( stripped_line ) if match ln = original_line_number ( match [ 1 ] ) . to_s return { :type => :error , :message => "Laufzeitfehler in Zeile #{ln}:" } end match = / File  \" [^ \" ]+ \" , line ( \d +), in turn / . match ( stripped_line ) if match @drop_next_error_line = true return { :type => :no } end if stripped_line == "^" return { :type => :error , :message => line } end return { :type => :error , :message => PythonCodeAugmenter . remove_line_number ( line ) } end
Takes a line of an error message and makes it ready to be presented to the user.
Takes a line of an error message and makes it ready to be presented to the user .
# A previously processed error line may cause us to drop the current one # We always throw away lines that start with certain prefixes # Recognize the syntax error message # Note that at this point, we haven't inserted any code yet, so there's no need to convert # any line numbers # Recognize the first runtime error message # We need to convert line numbers # Recognize further runtime error messages # Ignore this and the next line # Recognize the syntax error marker # It is some other line; be sure to remove any trailing end-of-line comment
line