mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-07-19 09:23:48 +00:00
reprlib already handles both truncation and exceptions
This commit is contained in:
parent
7de345f5cc
commit
a5e420a3ab
1 changed files with 1 additions and 7 deletions
|
|
@ -13,18 +13,12 @@ except ImportError:
|
|||
|
||||
from .third_party import six
|
||||
|
||||
MAX_VARIABLE_LENGTH = 100
|
||||
ipython_filename_pattern = re.compile('^<ipython-input-([0-9]+)-.*>$')
|
||||
|
||||
|
||||
def get_shortish_repr(item):
|
||||
try:
|
||||
r = reprlib.repr(item)
|
||||
except Exception:
|
||||
r = 'REPR FAILED'
|
||||
r = reprlib.repr(item)
|
||||
r = r.replace('\r', '').replace('\n', '')
|
||||
if len(r) > MAX_VARIABLE_LENGTH:
|
||||
r = '{truncated_r}...'.format(truncated_r=r[:MAX_VARIABLE_LENGTH])
|
||||
return r
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue