MCPcopy Create free account
hub / github.com/Relento/lego_release / row

Method row

util/html_table.py:112–145  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

110 self._row_counter = 0
111
112 def row(self, *args, **kwargs):
113 assert self._current_columns is not None
114
115 if len(args) > 0:
116 assert len(kwargs) == 0 and len(args) == len(self._current_columns)
117 for c, a in zip(self._current_columns, args):
118 kwargs[c.identifier] = a
119
120 row_identifier = kwargs.pop('row_identifier', 'row{:06d}'.format(self._row_counter))
121
122 self._print('<tr>')
123 for c in self._current_columns:
124 obj = kwargs[c.identifier]
125 classname = 'table{}_td_{}'.format(self._table_counter, c.identifier)
126 self._print(' <td class="{}">'.format(classname))
127 classname = 'table{}_column_{}'.format(self._table_counter, c.identifier)
128 if c.type == 'file':
129 link, alt = self.canonize_link('file', obj)
130 self._print(' <a class="{}" href="{}">{}</a>'.format(classname, link, alt))
131 elif c.type == 'image' or c.type == 'figure':
132 link, alt = self.canonize_link(c.type, obj, row_identifier, c.identifier)
133 self._print(' <img class="{}" src="{}" alt="{}" />'.format(classname, link, alt))
134 elif c.type == 'text' or c.type == 'code':
135 tag = 'pre' if c.type == 'code' else 'div'
136 self._print(' <{} class="{}">{}</{}>'.format(tag, classname, obj, tag))
137 elif c.type == 'raw':
138 self._print(' {}'.format(obj))
139 else:
140 raise ValueError('Unknown column type: {}.'.format(c.type))
141 self._print(' </td>')
142 self._print('</tr>')
143 self._flush()
144
145 self._row_counter += 1
146
147 def _print(self, *args, **kwargs):
148 assert self._index_file is not None

Callers 1

Calls 3

_printMethod · 0.95
canonize_linkMethod · 0.95
_flushMethod · 0.95

Tested by

no test coverage detected