MCPcopy Create free account
hub / github.com/aws/aws-cli / _render_column_titles

Method _render_column_titles

awscli/table.py:303–333  ·  view source on GitHub ↗
(self, section, max_width, stream)

Source from the content-addressed store, hash-verified

301 stream.write('+%s+' % ('-' * (max_width - 2)) + '\n')
302
303 def _render_column_titles(self, section, max_width, stream):
304 if not section.headers:
305 return
306 # In order to render the column titles we need to know
307 # the width of each of the columns.
308 widths = section.calculate_column_widths(
309 padding=4, max_width=max_width
310 )
311 # TODO: Built a list instead of +=, it's more efficient.
312 current = ''
313 length_so_far = 0
314 # The first cell needs both left and right edges '| foo |'
315 # while subsequent cells only need right edges ' foo |'.
316 first = True
317 for width, header in zip(widths, section.headers):
318 stylized_header = self._styler.style_header_column(header)
319 if first:
320 left_edge = '|'
321 first = False
322 else:
323 left_edge = ''
324 current += center_text(
325 text=stylized_header,
326 length=width,
327 left_edge=left_edge,
328 right_edge='|',
329 text_length=get_text_length(header),
330 )
331 length_so_far += width
332 self._write_line_break(stream, widths)
333 stream.write(current + '\n')
334
335 def _write_line_break(self, stream, widths):
336 # Write out something like:

Callers 1

_render_sectionMethod · 0.95

Calls 6

_write_line_breakMethod · 0.95
center_textFunction · 0.85
get_text_lengthFunction · 0.85
style_header_columnMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected