skorokithakis / tbvaccine

A small utility to pretty-print Python tracebacks. ⛺
MIT License
377 stars 14 forks source link

Cap long lines #14

Closed MinchinWeb closed 7 years ago

MinchinWeb commented 7 years ago

I'm having issues where I have very long variables (like a spreadsheet loaded in memory) and so when TBVaccine prints that, I lose everything else in my console buffer. Here is a quick and dirty hack to cap line length. It works by dropping ANSI sequences from long variable lines, and cap their length at 79*4 chars (approx. 4 output lines). A note is added to the line that there is more un-printed data.

(I can't figure out how to get decent lengths with normal string slicing on strings with ANSI codes embedded. For example, the output line | __annotations__ = {} clocks in with a length of 148 (!) due to ANSI control codes.)

The downside of dropping ANSI sequences like this is that the line won't be coloured....

MinchinWeb commented 7 years ago

P.S. I think the variable printing is an awesome addition! Thanks for adding it!

skorokithakis commented 7 years ago

This looks good to me, can you post a screenshot with the before and after so I can see how it looks on your data? Thanks!

MinchinWeb commented 7 years ago

Before (~1,500 lines in this case):

image

After:

image

(before, when I was testing it, none of the variable lines where being color-ed, so I wasn't worried about losing that formatting)

MinchinWeb commented 7 years ago

(I figure out what is going on with the colours... initializing colorama means that colours beyond the basic 16 aren't displayed)

skorokithakis commented 7 years ago

Looks great, just a minor typo and we're good to merge, thank you!

skorokithakis commented 7 years ago

Thank you!