def write_table(self): """ |write_table| with `Labeled Tab-separated Values (LTSV) <http://ltsv.org/>`__ format. Invalid characters in labels/data are removed. :raises pytablewriter.EmptyHeaderError: If the |header_list| is empty. :Example: :ref:`example-ltsv-table-writer` """ with self._logger: self._verify_property() self._preprocess() for value_list in self._table_value_matrix: ltsv_item_list = [ "{:s}:{}".format(pathvalidate.sanitize_ltsv_label(header_name), value) for header_name, value in zip(self.header_list, value_list) if typepy.is_not_null_string(value) ] if typepy.is_empty_sequence(ltsv_item_list): continue self._write_line("\t".join(ltsv_item_list))
def write_table(self): """ |write_table| with `Labeled Tab-separated Values (LTSV) <http://ltsv.org/>`__ format. Invalid characters in labels/data are removed. :raises pytablewriter.EmptyHeaderError: If the |headers| is empty. :Example: :ref:`example-ltsv-table-writer` """ with self._logger: self._verify_property() self._preprocess() for values in self._table_value_matrix: ltsv_item_list = [ "{:s}:{}".format(pathvalidate.sanitize_ltsv_label(header_name), value) for header_name, value in zip(self.headers, values) if typepy.is_not_null_string(value) ] if typepy.is_empty_sequence(ltsv_item_list): continue self._write_line("\t".join(ltsv_item_list))
def test_abnormal(self, value, expected): with pytest.raises(expected): sanitize_ltsv_label(value)
def test_normal_multibyte(self, value, expected): sanitize_ltsv_label(value)
def test_normal(self, value, replace_text, expected): assert sanitize_ltsv_label(value, replace_text) == expected
def test_abnormal(self, value, expected): with pytest.raises(expected): sanitize_ltsv_label(value)
def test_normal_multibyte(self, value, expected): sanitize_ltsv_label(value)
def test_normal(self, value, replace_text, expected): assert sanitize_ltsv_label(value, replace_text) == expected