Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _write_table(self):
self._preprocess()
self._write_opening_row()
try:
self._write_header()
self.__write_header_row_separator()
except EmptyHeaderError:
pass
is_first_value_row = True
for values, value_dp_list in zip(self._table_value_matrix, self._table_value_dp_matrix):
try:
if is_first_value_row:
is_first_value_row = False
else:
if self.is_write_value_separator_row:
self._write_value_row_separator()
self._write_value_row(values, value_dp_list)
except TypeError:
continue
self._write_closing_row()
def _validate_empty_header(self):
"""
:raises pytablewriter.EmptyHeaderError: If the |headers| is empty.
"""
if typepy.is_empty_sequence(self.headers):
raise EmptyHeaderError("headers expected to have one or more header names")
tags = _get_tags_module()
with self._logger:
self._verify_property()
self._preprocess()
if typepy.is_not_null_string(self.table_name):
self._table_tag = tags.table(id=sanitize_python_var_name(self.table_name))
self._table_tag += tags.caption(MultiByteStrDecoder(self.table_name).unicode_str)
else:
self._table_tag = tags.table()
try:
self._write_header()
except EmptyHeaderError:
pass
self._write_body()
def _write_header(self):
tags = _get_tags_module()
if not self.is_write_header:
return
if typepy.is_empty_sequence(self.headers):
raise EmptyHeaderError("headers is empty")
tr_tag = tags.tr()
for header in self.headers:
tr_tag += tags.th(MultiByteStrDecoder(header).unicode_str)
thead_tag = tags.thead()
thead_tag += tr_tag
self._table_tag += thead_tag
def _write_header(self):
if not self.is_write_header:
return
if typepy.is_empty_sequence(self._table_headers):
raise EmptyHeaderError("header is empty")
self._write_row(self._table_headers)