MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _parse_error

Function _parse_error

lib/sqlalchemy/dialects/postgresql/hstore.py:341–359  ·  view source on GitHub ↗

format an unmarshalling error.

(hstore_str: str, pos: int)

Source from the content-addressed store, hash-verified

339
340
341def _parse_error(hstore_str: str, pos: int) -> str:
342 """format an unmarshalling error."""
343
344 ctx = 20
345 hslen = len(hstore_str)
346
347 parsed_tail = hstore_str[max(pos - ctx - 1, 0) : min(pos, hslen)]
348 residual = hstore_str[min(pos, hslen) : min(pos + ctx + 1, hslen)]
349
350 if len(parsed_tail) > ctx:
351 parsed_tail = "[...]" + parsed_tail[1:]
352 if len(residual) > ctx:
353 residual = residual[:-1] + "[...]"
354
355 return "After %r, could not parse residual at position %d: %r" % (
356 parsed_tail,
357 pos,
358 residual,
359 )
360
361
362def _parse_hstore(hstore_str: str) -> _HSTORE_VAL:

Callers 1

_parse_hstoreFunction · 0.85

Calls 2

maxClass · 0.85
minClass · 0.85

Tested by

no test coverage detected