Changeset 3508

Show
Ignore:
Timestamp:
04/12/08 22:30:45 (5 months ago)
Author:
tcoulter
Message:

Made it so ellipses are shown only if they actually break up the comment (ie., the excerpt does not cover either bound).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tracbacksplugin/0.11/tracbacks/tracbacks.py

    r3507 r3508  
    114114                end = index + len(string_representation) + self.EXCERPT_CHARACTERS   
    115115                     
    116                 # Make sure we don't go into the negative. 
    117                 if start < 0: 
     116                left_ellipsis = "..." 
     117                right_ellipsis = "..." 
     118                     
     119                # Make sure we don't go into the negative. Also, make the ellipsis' 
     120                # disappear if we're not actually cutting up the comment. 
     121                if start <= 0: 
     122                    left_ellipsis = "" 
    118123                    start = 0 
     124                 
     125                if end >= len(comment): 
     126                    right_ellipsis = "" 
    119127                 
    120128                excerpt = comment[start:end] 
     
    123131                # There's probably a better way to say this in python, but Tim doesn't know 
    124132                # how to do it. (He's tried """ but something's foobar'ed.) 
    125                 excerpts.append("\n> ''...%s...''\n" % excerpt
     133                excerpts.append("\n> ''%s%s%s''\n" % (left_ellipsis, excerpt, right_ellipsis)
    126134             
    127135        tracback += ''.join(excerpts)