format an unmarshalling error.
(hstore_str, pos)
| 322 | |
| 323 | |
| 324 | def _parse_error(hstore_str, pos): |
| 325 | """format an unmarshalling error.""" |
| 326 | |
| 327 | ctx = 20 |
| 328 | hslen = len(hstore_str) |
| 329 | |
| 330 | parsed_tail = hstore_str[max(pos - ctx - 1, 0) : min(pos, hslen)] |
| 331 | residual = hstore_str[min(pos, hslen) : min(pos + ctx + 1, hslen)] |
| 332 | |
| 333 | if len(parsed_tail) > ctx: |
| 334 | parsed_tail = "[...]" + parsed_tail[1:] |
| 335 | if len(residual) > ctx: |
| 336 | residual = residual[:-1] + "[...]" |
| 337 | |
| 338 | return "After %r, could not parse residual at position %d: %r" % ( |
| 339 | parsed_tail, |
| 340 | pos, |
| 341 | residual, |
| 342 | ) |
| 343 | |
| 344 | |
| 345 | def _parse_hstore(hstore_str): |
no test coverage detected