Given an iterable of string contents, make a table row. Args: contents: An iterable yielding strings. tag: The tag to place contents in. Defaults to 'td', you might want 'th'. Returns: A string containing the content strings, organized into a table row. Example: make
(contents, tag="td")
| 46 | |
| 47 | |
| 48 | def make_table_row(contents, tag="td"): |
| 49 | """Given an iterable of string contents, make a table row. |
| 50 | |
| 51 | Args: |
| 52 | contents: An iterable yielding strings. |
| 53 | tag: The tag to place contents in. Defaults to 'td', you might want 'th'. |
| 54 | |
| 55 | Returns: |
| 56 | A string containing the content strings, organized into a table row. |
| 57 | |
| 58 | Example: make_table_row(['one', 'two', 'three']) == ''' |
| 59 | <tr> |
| 60 | <td>one</td> |
| 61 | <td>two</td> |
| 62 | <td>three</td> |
| 63 | </tr>''' |
| 64 | """ |
| 65 | columns = ("<%s>%s</%s>\n" % (tag, s, tag) for s in contents) |
| 66 | return "<tr>\n" + "".join(columns) + "</tr>\n" |
| 67 | |
| 68 | |
| 69 | def make_table(contents, headers=None): |
no test coverage detected
searching dependent graphs…