Project

General

Profile

« Previous | Next » 

Revision 2482

strings.py: Split as_table() into as_table() and as_inline_table() depending on whether the table needs to be inlined in an ordered list item or not

View differences:

strings.py
106 106
    if multiline: str_ = '<pre>'+str_+'</pre>'
107 107
    return str_
108 108

  
109
def as_table(dict_, key_label='Output', value_label='Input'):
109
def as_inline_table(dict_, key_label='Output', value_label='Input'):
110 110
    '''Wraps a dict in Redmine tags to format it as a table.'''
111 111
    str_ = ''
112 112
    def row(entry): return (': '.join(entry))+'\n'
113 113
    str_ += row([key_label, value_label])
114 114
    for entry in dict_.iteritems(): str_ += row([ustr(v) for v in entry])
115 115
    return '<pre>\n'+str_+'</pre>'
116

  
117
def as_table(dict_, key_label='Output', value_label='Input'):
118
    '''Wraps a dict in Redmine tags to format it as a table.'''
119
    str_ = ''
120
    def row(entry): return ('|'.join(['']+entry+['']))+'\n'# '' for outer border
121
    str_ += row([key_label, value_label])
122
    for entry in dict_.iteritems(): str_ += row([as_tt(ustr(v)) for v in entry])
123
    return '\n'+str_+' ' # space protects last \n so blank line ends table

Also available in: Unified diff