(self, *args, **kwargs)
| 138 | self._print('</td></tr>') |
| 139 | |
| 140 | def row(self, *args, **kwargs): |
| 141 | assert len(self._current_table_spec_stack) > 0 |
| 142 | |
| 143 | if len(args) > 0: |
| 144 | assert len(kwargs) == 0 and len(args) == len(self._current_columns) |
| 145 | for c, a in zip(self._current_columns, args): |
| 146 | kwargs[c.identifier] = a |
| 147 | |
| 148 | row_identifier = kwargs.pop('row_identifier', 'row{:06d}'.format(self._row_counter)) |
| 149 | |
| 150 | self._print('<tr>') |
| 151 | for c in self._current_columns: |
| 152 | obj = kwargs[c.identifier] |
| 153 | classname = 'table{}_td_{}'.format(self._current_table_spec, c.identifier) |
| 154 | self._print(' <td class="{}">'.format(classname)) |
| 155 | classname = 'table{}_column_{}'.format(self._current_table_spec, c.identifier) |
| 156 | if obj is None: |
| 157 | pass |
| 158 | elif c.type == 'file': |
| 159 | link, alt = self.canonize_link('file', obj) |
| 160 | self._print(' <a class="{}" href="{}">{}</a>'.format(classname, link, alt)) |
| 161 | elif c.type == 'image' or c.type == 'figure': |
| 162 | if isinstance(obj, dict): |
| 163 | info = obj['info'] |
| 164 | obj = obj[c.type] |
| 165 | else: |
| 166 | info = None |
| 167 | link, alt = self.canonize_link(c.type, obj, row_identifier, c.identifier) |
| 168 | self._print(' <img class="{}" src="{}" alt="{}" />'.format(classname, link, alt)) |
| 169 | if info is not None: |
| 170 | self._print(' <pre class="info">{}</pre>'.format(info)) |
| 171 | elif c.type == 'frames': |
| 172 | self._print_frames(row_identifier, c, obj, classname) |
| 173 | elif c.type == 'text' or c.type == 'code': |
| 174 | tag = 'pre' if c.type == 'code' else 'div' |
| 175 | self._print(' <{} class="{}">{}</{}>'.format(tag, classname, html.escape(str(obj)), tag)) |
| 176 | elif c.type == 'raw': |
| 177 | self._print(' {}'.format(obj)) |
| 178 | elif c.type == 'video': |
| 179 | link, alt = self.canonize_link(c.type, obj, row_identifier, c.identifier) |
| 180 | self._print( |
| 181 | # '<tr vertical-align="top">' \ |
| 182 | # '<td align=center>' \ |
| 183 | # f'<a class="{classname}" href="{link}">{alt}</a>' \ |
| 184 | # '<br>' \ |
| 185 | f'<video class={classname} autoplay loop controls>' |
| 186 | f'<source src="{link}" type="video/mp4"></video>' |
| 187 | # f'</td>' \ |
| 188 | # '</tr>' |
| 189 | ) |
| 190 | else: |
| 191 | raise ValueError('Unknown column type: {}.'.format(c.type)) |
| 192 | self._print(' </td>') |
| 193 | self._print('</tr>') |
| 194 | self._flush() |
| 195 | |
| 196 | self._row_counter += 1 |
| 197 |
no test coverage detected