def error_report_from(format, text, errortext):
    """XML and JSON parse error texts look like this:
          not well-formed (invalid token): line 155, column 8
      or  Expecting ':' delimiter: line 14 column 32 (char 303)

    Extract the line and column information to report the offending
    line with a caret positioned under the shady character.
    """
    linepos = errortext.rfind('line')
    errmsg = format % 'Error: parsing %s failed'
    standard_error = 1, 1, errmsg
    if linepos == -1:
        return standard_error
    errortext = errortext[linepos:]
    numbers = [int(x) for x in re.split(r"[^\d]+", errortext) if x]
    if len(numbers) not in [2, 3]:  # Do we have line, column, [char]?
        return standard_error
    linenr, column = numbers[:2]

    errstart = 0
    for idx, line in enumerate(text.splitlines(True)):
        if idx + 1 == linenr:
            errstart += column - 1
            break
        errstart += len(line)
    else:
        # If the line containing the error wasn't found
        # no extended error report is genenerated
        return linenr, column, errmsg

    return parse_error_report(text, errstart, errstart, format)
dataset/ETHPy150Open mikr/xcodeprojer/xcodeprojer.py/error_report_from/swapped operands of `%`