Project

General

Profile

« Previous | Next » 

Revision 2480

strings.py: as_table(): Fixed bug where table was not ended properly, by adding a space after the last \n and having rstrip() string only newlines

View differences:

lib/strings.py
73 73

  
74 74
def remove_extra_newl(str_):
75 75
    if is_multiline(str_): return str_
76
    else: return str_.rstrip()
76
    else: return str_.rstrip('\n')
77 77

  
78 78
def std_newl(str_): return str_.replace('\r\n', '\n').replace('\r', '\n')
79 79

  
......
101 101

  
102 102
def as_code(str_, lang=None, multiline=True):
103 103
    '''Wraps a string in Redmine tags to syntax-highlight it.'''
104
    str_ = '\n'+str_.rstrip()+'\n'
104
    str_ = '\n'+str_.rstrip('\n')+'\n'
105 105
    if lang != None: str_ = '<code class="'+lang+'">'+str_+'</code>'
106 106
    if multiline: str_ = '<pre>'+str_+'</pre>'
107 107
    return str_
......
112 112
    def row(entry): return ('|'.join(['']+entry+['']))+'\n'# '' for outer border
113 113
    str_ += row([key_label, value_label])
114 114
    for entry in dict_.iteritems(): str_ += row([as_tt(ustr(v)) for v in entry])
115
    return str_
115
    return str_+' ' # space protects last \n so blank line ends table
bin/map
114 114
        '''Higher level -> more verbose'''
115 115
        if level <= verbosity:
116 116
            if level > 1: msg = '['+str(level)+'] '+msg # include level in msg
117
            sys.stderr.write(msg.rstrip()+'\n')
117
            sys.stderr.write(msg.rstrip('\n')+'\n')
118 118
    if debug: log_debug = lambda msg, level=2: log(msg, level)
119 119
    else: log_debug = sql.log_debug_none
120 120
    

Also available in: Unified diff