def markLocation(line, loc):
if len(line) <= 60:
# line is short enough
pass
elif loc <= 30:
# error at beginning
line = line[:60] + '[...]'
elif loc >= (len(line) - 30):
# error at end
loc = 60 - (len(line) - loc) + 5
line = '[...]' + line[-60:]
else:
# error in middle
line = '[...]' + line[loc-30:loc+30] + '[...]'
loc = 35
return "Offending query: " + line + "\n" + (" " * (loc + 17)) + \
"^.-- Error location"
评论列表
文章目录