MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / chop_traceback

Function chop_traceback

lib/sqlalchemy/util/langhelpers.py:2009–2032  ·  view source on GitHub ↗

Chop extraneous lines off beginning and end of a traceback. :param tb: a list of traceback lines as returned by ``traceback.format_stack()`` :param exclude_prefix: a regular expression object matching lines to skip at beginning of ``tb`` :param exclude_suffix:

(
    tb: List[str],
    exclude_prefix: re.Pattern[str] = _UNITTEST_RE,
    exclude_suffix: re.Pattern[str] = _SQLA_RE,
)

Source from the content-addressed store, hash-verified

2007
2008
2009def chop_traceback(
2010 tb: List[str],
2011 exclude_prefix: re.Pattern[str] = _UNITTEST_RE,
2012 exclude_suffix: re.Pattern[str] = _SQLA_RE,
2013) -> List[str]:
2014 """Chop extraneous lines off beginning and end of a traceback.
2015
2016 :param tb:
2017 a list of traceback lines as returned by ``traceback.format_stack()``
2018
2019 :param exclude_prefix:
2020 a regular expression object matching lines to skip at beginning of
2021 ``tb``
2022
2023 :param exclude_suffix:
2024 a regular expression object matching lines to skip at end of ``tb``
2025 """
2026 start = 0
2027 end = len(tb) - 1
2028 while start <= end and exclude_prefix.search(tb[start]):
2029 start += 1
2030 while start <= end and exclude_suffix.search(tb[end]):
2031 end -= 1
2032 return tb[start : end + 1]
2033
2034
2035def attrsetter(attrname):

Callers 1

_do_getMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected