From 9711f5e0b047f424974dc50d3d9139a0dd04a787 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 10:56:57 +0900 Subject: [PATCH 01/29] Rename a method --- pytablewriter/_factory.py | 13 ++++++++----- test/test_writer_factory.py | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pytablewriter/_factory.py b/pytablewriter/_factory.py index 897d8d3d..eea14c6a 100644 --- a/pytablewriter/_factory.py +++ b/pytablewriter/_factory.py @@ -81,9 +81,7 @@ def create_from_file_extension(cls, file_extension): [ "{:s} (unknown file extension).".format(file_extension), "", - "acceptable file extensions are: {}.".format( - ", ".join(cls.get_extension_list()) - ), + "acceptable file extensions are: {}.".format(", ".join(cls.get_extensions())), ] ) ) @@ -206,7 +204,7 @@ def get_format_name_list(cls): return sorted(list(format_name_set)) @classmethod - def get_extension_list(cls): + def get_extensions(cls): """ :return: Available file extensions. :rtype: list @@ -215,7 +213,7 @@ def get_extension_list(cls): .. code:: python >>> import pytablewriter as ptw - >>> for name in ptw.TableWriterFactory.get_extension_list(): + >>> for name in ptw.TableWriterFactory.get_extensions(): ... print(name) ... csv @@ -245,3 +243,8 @@ def get_extension_list(cls): file_extension_set.add(file_extension) return sorted(list(file_extension_set)) + + @classmethod + def get_extension_list(cls): + # deprecated: alias to get_extensions + return cls.get_extensions() diff --git a/test/test_writer_factory.py b/test/test_writer_factory.py index 35c7c312..3038c86d 100644 --- a/test/test_writer_factory.py +++ b/test/test_writer_factory.py @@ -52,9 +52,9 @@ def test_normal(self): ] -class Test_WriterFactory_get_extension_list(object): +class Test_WriterFactory_get_extensions(object): def test_normal(self): - assert ptw.TableWriterFactory.get_extension_list() == [ + assert ptw.TableWriterFactory.get_extensions() == [ "csv", "htm", "html", From 3eb57cf21c5371a31943022a87e9cf2b705d8208 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 11:02:45 +0900 Subject: [PATCH 02/29] Rename a method --- pytablewriter/_factory.py | 13 ++++++++----- test/test_multibyte.py | 2 +- test/test_writer_factory.py | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pytablewriter/_factory.py b/pytablewriter/_factory.py index eea14c6a..73d524c0 100644 --- a/pytablewriter/_factory.py +++ b/pytablewriter/_factory.py @@ -139,15 +139,13 @@ def create_from_format_name(cls, format_name): "\n".join( [ "{} (unknown format name).".format(format_name), - "acceptable format names are: {}.".format( - ", ".join(cls.get_format_name_list()) - ), + "acceptable format names are: {}.".format(", ".join(cls.get_format_names())), ] ) ) @classmethod - def get_format_name_list(cls): + def get_format_names(cls): """ :return: Available format names. :rtype: list @@ -156,7 +154,7 @@ def get_format_name_list(cls): .. code:: python >>> import pytablewriter as ptw - >>> for name in ptw.TableWriterFactory.get_format_name_list(): + >>> for name in ptw.TableWriterFactory.get_format_names(): ... print(name) ... csv @@ -203,6 +201,11 @@ def get_format_name_list(cls): return sorted(list(format_name_set)) + @classmethod + def get_format_name_list(cls): + # deprecated: alias to get_format_names + return cls.get_format_names() + @classmethod def get_extensions(cls): """ diff --git a/test/test_multibyte.py b/test/test_multibyte.py index 9aa2d651..8ec13e00 100644 --- a/test/test_multibyte.py +++ b/test/test_multibyte.py @@ -15,7 +15,7 @@ class Test_CsvTableWriter_write_table(object): ["format_name"], [ [format_name] - for format_name in ptw.TableWriterFactory.get_format_name_list() + for format_name in ptw.TableWriterFactory.get_format_names() if format_name not in ["null", "elasticsearch", "excel", "sqlite"] ], ) diff --git a/test/test_writer_factory.py b/test/test_writer_factory.py index 3038c86d..e57c0a20 100644 --- a/test/test_writer_factory.py +++ b/test/test_writer_factory.py @@ -12,9 +12,9 @@ import pytest -class Test_WriterFactory_get_format_name_list(object): +class Test_WriterFactory_get_format_names(object): def test_normal(self): - assert ptw.TableWriterFactory.get_format_name_list() == [ + assert ptw.TableWriterFactory.get_format_names() == [ "csv", "elasticsearch", "excel", From 13bd0c3a7dc3b349d9656bb1ded94549f5d2b223 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 11:02:56 +0900 Subject: [PATCH 03/29] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 5a099c03..cbac6e07 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ parts/ sdist/ var/ wheels/ +pip-wheel-metadata/ share/python-wheels/ *.egg-info/ .installed.cfg @@ -115,6 +116,7 @@ dmypy.json .pyre/ # User settings +_sandbox/ *_profile Untitled.ipynb From 909e8e6a175dccce1e1baffdbd1e61763df92864 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 11:50:20 +0900 Subject: [PATCH 04/29] Refactor: rename a private variable --- pytablewriter/_table_format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index af4fd0e4..be98fa7e 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -229,13 +229,13 @@ def file_extension_list(self): :rtype: list """ - return self.__file_extension_list + return self.__file_extensions def __init__(self, name_list, writer_class, format_attribute, file_extension_list): self.__name_list = name_list self.__writer_class = writer_class self.__format_attribute = format_attribute - self.__file_extension_list = file_extension_list + self.__file_extensions = file_extension_list @classmethod def find_all_attr(cls, format_attribute): From 34e787a4188e4469e3baea1cc75c54eb0173ba06 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 11:51:41 +0900 Subject: [PATCH 05/29] Refactor: rename an argument --- pytablewriter/_table_format.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index be98fa7e..b48d9fb0 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -231,11 +231,11 @@ def file_extension_list(self): return self.__file_extensions - def __init__(self, name_list, writer_class, format_attribute, file_extension_list): + def __init__(self, name_list, writer_class, format_attribute, file_extensions): self.__name_list = name_list self.__writer_class = writer_class self.__format_attribute = format_attribute - self.__file_extensions = file_extension_list + self.__file_extensions = file_extensions @classmethod def find_all_attr(cls, format_attribute): From 7007fe2f03ce61f756fe75248ea6b9221bd1a8bd Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 11:53:20 +0900 Subject: [PATCH 06/29] Rename a property --- pytablewriter/_factory.py | 4 ++-- pytablewriter/_table_format.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pytablewriter/_factory.py b/pytablewriter/_factory.py index 73d524c0..58ab46f9 100644 --- a/pytablewriter/_factory.py +++ b/pytablewriter/_factory.py @@ -68,7 +68,7 @@ def create_from_file_extension(cls, file_extension): file_extension = file_extension.lstrip(".").lower() for table_format in TableFormat: - if file_extension not in table_format.file_extension_list: + if file_extension not in table_format.file_extensions: continue if table_format.format_attribute & FormatAttr.SECONDARY_EXT: @@ -242,7 +242,7 @@ def get_extensions(cls): file_extension_set = set() for table_format in TableFormat: - for file_extension in table_format.file_extension_list: + for file_extension in table_format.file_extensions: file_extension_set.add(file_extension) return sorted(list(file_extension_set)) diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index b48d9fb0..25489923 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -223,7 +223,7 @@ def format_attribute(self): return self.__format_attribute @property - def file_extension_list(self): + def file_extensions(self): """ :return: File extensions associated with the table format. :rtype: list @@ -231,6 +231,11 @@ def file_extension_list(self): return self.__file_extensions + @property + def file_extension_list(self): + # deprecated: alias to file_extensions + return self.file_extensions + def __init__(self, name_list, writer_class, format_attribute, file_extensions): self.__name_list = name_list self.__writer_class = writer_class From 62410ea4459d2bcb9a31daaf9dc12676110ea26c Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:00:01 +0900 Subject: [PATCH 07/29] Add DeprecationWarnings --- pytablewriter/_factory.py | 7 +++++-- pytablewriter/_table_format.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pytablewriter/_factory.py b/pytablewriter/_factory.py index 58ab46f9..9afd6ce2 100644 --- a/pytablewriter/_factory.py +++ b/pytablewriter/_factory.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, unicode_literals import os +import warnings import typepy @@ -203,7 +204,9 @@ def get_format_names(cls): @classmethod def get_format_name_list(cls): - # deprecated: alias to get_format_names + warnings.warn( + "'get_format_name_list()' has moved to 'get_format_names()'", DeprecationWarning + ) return cls.get_format_names() @classmethod @@ -249,5 +252,5 @@ def get_extensions(cls): @classmethod def get_extension_list(cls): - # deprecated: alias to get_extensions + warnings.warn("'get_extension_list()' has moved to 'get_extensions()'", DeprecationWarning) return cls.get_extensions() diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index 25489923..3d8bc3de 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -7,6 +7,7 @@ from __future__ import absolute_import, unicode_literals import enum +import warnings from .writer import ( CsvTableWriter, @@ -233,7 +234,7 @@ def file_extensions(self): @property def file_extension_list(self): - # deprecated: alias to file_extensions + warnings.warn("'file_extension_list' has moved to 'file_extensions'", DeprecationWarning) return self.file_extensions def __init__(self, name_list, writer_class, format_attribute, file_extensions): From 5b74cf983c45e8802261e4ec4d809839f2417cc4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:00:13 +0900 Subject: [PATCH 08/29] Update Makefile rules --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7556c103..9d5e06d9 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ build: cd $(PACKAGE); \ python setup.py build @twine check $(DIST_DIR)/* - ls $(DIST_DIR) + ls -l $(DIST_DIR) .PHONY: clean clean: @@ -53,4 +53,4 @@ readme: .PHONY: release release: @cd $(BUILD_WORK_DIR)/$(PACKAGE); python setup.py release --sign - @rm -rf $(BUILD_WORK_DIR) + @make clean From 8f3a640888ca693d5d7a920ea53b91c8f7230c43 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:03:30 +0900 Subject: [PATCH 09/29] Rename an argument --- pytablewriter/_table_format.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index 3d8bc3de..bc341dfb 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -202,7 +202,7 @@ def name_list(self): :rtype: list """ - return self.__name_list + return self.__names @property def writer_class(self): @@ -237,8 +237,8 @@ def file_extension_list(self): warnings.warn("'file_extension_list' has moved to 'file_extensions'", DeprecationWarning) return self.file_extensions - def __init__(self, name_list, writer_class, format_attribute, file_extensions): - self.__name_list = name_list + def __init__(self, names, writer_class, format_attribute, file_extensions): + self.__names = names self.__writer_class = writer_class self.__format_attribute = format_attribute self.__file_extensions = file_extensions From a3112d9fcfaf66230c820fc866e85fcfff75ac09 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:07:09 +0900 Subject: [PATCH 10/29] Rename a property --- pytablewriter/_factory.py | 4 ++-- pytablewriter/_table_format.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pytablewriter/_factory.py b/pytablewriter/_factory.py index 9afd6ce2..3b5ea3f0 100644 --- a/pytablewriter/_factory.py +++ b/pytablewriter/_factory.py @@ -131,7 +131,7 @@ def create_from_format_name(cls, format_name): format_name = format_name.lower() for table_format in TableFormat: - if format_name in table_format.name_list and not ( + if format_name in table_format.names and not ( table_format.format_attribute & FormatAttr.SECONDARY_NAME ): return table_format.writer_class() @@ -197,7 +197,7 @@ def get_format_names(cls): format_name_set = set() for table_format in TableFormat: - for format_name in table_format.name_list: + for format_name in table_format.names: format_name_set.add(format_name) return sorted(list(format_name_set)) diff --git a/pytablewriter/_table_format.py b/pytablewriter/_table_format.py index bc341dfb..bcf1e1fe 100644 --- a/pytablewriter/_table_format.py +++ b/pytablewriter/_table_format.py @@ -196,7 +196,7 @@ class TableFormat(enum.Enum): TSV = ([TsvTableWriter.FORMAT_NAME], TsvTableWriter, FormatAttr.FILE | FormatAttr.TEXT, ["tsv"]) @property - def name_list(self): + def names(self): """ :return: Names associated with the table format. :rtype: list @@ -204,6 +204,11 @@ def name_list(self): return self.__names + @property + def name_list(self): + warnings.warn("'name_list' has moved to 'names'", DeprecationWarning) + return self.names + @property def writer_class(self): """ From 00396006c0ae26f58e6f9086873a621f7359e7df Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:11:25 +0900 Subject: [PATCH 11/29] Refactor: rename a private method --- pytablewriter/writer/text/_text_writer.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index 0043a837..acf2e840 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -216,26 +216,22 @@ def _write_table(self): self._write_closing_row() def _get_opening_row_item_list(self): - return self.__get_row_separator_item_list( - self.__opening_row_cell_format, self.char_opening_row - ) + return self.__get_row_separator_items(self.__opening_row_cell_format, self.char_opening_row) def _get_header_row_separator_item_list(self): - return self.__get_row_separator_item_list( + return self.__get_row_separator_items( self._header_row_separator_cell_format, self.char_header_row_separator ) def _get_value_row_separator_item_list(self): - return self.__get_row_separator_item_list( + return self.__get_row_separator_items( self.__value_row_separator_cell_format, self.char_value_row_separator ) def _get_closing_row_item_list(self): - return self.__get_row_separator_item_list( - self.__closing_row_cell_format, self.char_closing_row - ) + return self.__get_row_separator_items(self.__closing_row_cell_format, self.char_closing_row) - def __get_row_separator_item_list(self, margin_format, separator_char): + def __get_row_separator_items(self, margin_format, separator_char): return [ margin_format.format(separator_char * self._get_padding_len(col_dp)) for col_dp in self._column_dp_list From 9db5000c807203c73f229bf4f425ef7b02053cdc Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:13:59 +0900 Subject: [PATCH 12/29] Refactor: rename a method --- pytablewriter/writer/text/_latex.py | 4 ++-- pytablewriter/writer/text/_markdown.py | 2 +- pytablewriter/writer/text/_mediawiki.py | 4 ++-- pytablewriter/writer/text/_text_writer.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pytablewriter/writer/text/_latex.py b/pytablewriter/writer/text/_latex.py index b4f6b8fc..9aa9d33b 100644 --- a/pytablewriter/writer/text/_latex.py +++ b/pytablewriter/writer/text/_latex.py @@ -124,7 +124,7 @@ def _to_row_item(self, col_dp, value_dp): return row_item - def _get_header_row_separator_item_list(self): + def _get_header_row_separator_items(self): return [] def _get_opening_row_item_list(self): @@ -216,7 +216,7 @@ def _to_row_item(self, col_dp, value_dp): return row_item - def _get_header_row_separator_item_list(self): + def _get_header_row_separator_items(self): return [r"\hline"] def _get_closing_row_item_list(self): diff --git a/pytablewriter/writer/text/_markdown.py b/pytablewriter/writer/text/_markdown.py index 614a9da5..59ef1f3d 100644 --- a/pytablewriter/writer/text/_markdown.py +++ b/pytablewriter/writer/text/_markdown.py @@ -58,7 +58,7 @@ def _to_row_item(self, col_dp, value_dp): def _get_opening_row_item_list(self): return [] - def _get_header_row_separator_item_list(self): + def _get_header_row_separator_items(self): header_separator_list = [] for col_dp in self._column_dp_list: padding_len = self._get_padding_len(col_dp) + self.margin * 2 diff --git a/pytablewriter/writer/text/_mediawiki.py b/pytablewriter/writer/text/_mediawiki.py index 450b88c0..390867fb 100644 --- a/pytablewriter/writer/text/_mediawiki.py +++ b/pytablewriter/writer/text/_mediawiki.py @@ -69,11 +69,11 @@ def _write_value_row(self, value_list, value_dp_list): def _get_opening_row_item_list(self): return ['{| class="wikitable"'] - def _get_header_row_separator_item_list(self): + def _get_header_row_separator_items(self): return ["|-"] def _get_value_row_separator_item_list(self): - return self._get_header_row_separator_item_list() + return self._get_header_row_separator_items() def _get_closing_row_item_list(self): return ["|}"] diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index acf2e840..e1c124c7 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -218,7 +218,7 @@ def _write_table(self): def _get_opening_row_item_list(self): return self.__get_row_separator_items(self.__opening_row_cell_format, self.char_opening_row) - def _get_header_row_separator_item_list(self): + def _get_header_row_separator_items(self): return self.__get_row_separator_items( self._header_row_separator_cell_format, self.char_header_row_separator ) @@ -312,7 +312,7 @@ def __write_header_row_separator(self): if any([not self.is_write_header, not self.is_write_header_separator_row]): return - self.__write_separator_row(self._get_header_row_separator_item_list()) + self.__write_separator_row(self._get_header_row_separator_items()) def _write_value_row_separator(self): """ From d47e46a7cd92588b7f18c2841f4cd7ce6ffcf99c Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:16:08 +0900 Subject: [PATCH 13/29] Refactor: rename a method --- pytablewriter/writer/text/_csv.py | 2 +- pytablewriter/writer/text/_markdown.py | 2 +- pytablewriter/writer/text/_mediawiki.py | 2 +- pytablewriter/writer/text/_rst.py | 2 +- pytablewriter/writer/text/_text_writer.py | 4 ++-- pytablewriter/writer/text/sourcecode/_sourcecode.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pytablewriter/writer/text/_csv.py b/pytablewriter/writer/text/_csv.py index e7415148..5e46844c 100644 --- a/pytablewriter/writer/text/_csv.py +++ b/pytablewriter/writer/text/_csv.py @@ -46,7 +46,7 @@ def _write_header(self): def _get_opening_row_item_list(self): return [] - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return [] def _get_closing_row_item_list(self): diff --git a/pytablewriter/writer/text/_markdown.py b/pytablewriter/writer/text/_markdown.py index 59ef1f3d..7c5777f4 100644 --- a/pytablewriter/writer/text/_markdown.py +++ b/pytablewriter/writer/text/_markdown.py @@ -75,7 +75,7 @@ def _get_header_row_separator_items(self): return header_separator_list - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return [] def _get_closing_row_item_list(self): diff --git a/pytablewriter/writer/text/_mediawiki.py b/pytablewriter/writer/text/_mediawiki.py index 390867fb..cddcb276 100644 --- a/pytablewriter/writer/text/_mediawiki.py +++ b/pytablewriter/writer/text/_mediawiki.py @@ -72,7 +72,7 @@ def _get_opening_row_item_list(self): def _get_header_row_separator_items(self): return ["|-"] - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return self._get_header_row_separator_items() def _get_closing_row_item_list(self): diff --git a/pytablewriter/writer/text/_rst.py b/pytablewriter/writer/text/_rst.py index 53613e0f..51990798 100644 --- a/pytablewriter/writer/text/_rst.py +++ b/pytablewriter/writer/text/_rst.py @@ -133,7 +133,7 @@ def _write_header(self): ) self._write_line() - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return [] def _get_closing_row_item_list(self): diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index e1c124c7..948690e2 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -223,7 +223,7 @@ def _get_header_row_separator_items(self): self._header_row_separator_cell_format, self.char_header_row_separator ) - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return self.__get_row_separator_items( self.__value_row_separator_cell_format, self.char_value_row_separator ) @@ -321,7 +321,7 @@ def _write_value_row_separator(self): :py:attr:`.is_write_value_separator_row`. """ - self.__write_separator_row(self._get_value_row_separator_item_list()) + self.__write_separator_row(self._get_value_row_separator_items()) def _write_closing_row(self): if not self.is_write_closing_row: diff --git a/pytablewriter/writer/text/sourcecode/_sourcecode.py b/pytablewriter/writer/text/sourcecode/_sourcecode.py index 3bb4f682..78985011 100644 --- a/pytablewriter/writer/text/sourcecode/_sourcecode.py +++ b/pytablewriter/writer/text/sourcecode/_sourcecode.py @@ -54,7 +54,7 @@ def __init__(self): self._quoting_flags[typepy.Typecode.DATETIME] = False self._is_require_table_name = True - def _get_value_row_separator_item_list(self): + def _get_value_row_separator_items(self): return [] def _write_opening_row(self): From 38d233f43a9e5da3bbde711cc0ed52910a0168fb Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:17:50 +0900 Subject: [PATCH 14/29] Refactor: rename a method --- pytablewriter/writer/text/_csv.py | 2 +- pytablewriter/writer/text/_json.py | 2 +- pytablewriter/writer/text/_latex.py | 4 ++-- pytablewriter/writer/text/_markdown.py | 2 +- pytablewriter/writer/text/_mediawiki.py | 2 +- pytablewriter/writer/text/_rst.py | 2 +- pytablewriter/writer/text/_text_writer.py | 4 ++-- pytablewriter/writer/text/sourcecode/_javascript.py | 2 +- pytablewriter/writer/text/sourcecode/_numpy.py | 2 +- pytablewriter/writer/text/sourcecode/_pandas.py | 2 +- pytablewriter/writer/text/sourcecode/_python.py | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pytablewriter/writer/text/_csv.py b/pytablewriter/writer/text/_csv.py index 5e46844c..38ecccbc 100644 --- a/pytablewriter/writer/text/_csv.py +++ b/pytablewriter/writer/text/_csv.py @@ -49,5 +49,5 @@ def _get_opening_row_item_list(self): def _get_value_row_separator_items(self): return [] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return [] diff --git a/pytablewriter/writer/text/_json.py b/pytablewriter/writer/text/_json.py index 5d40ca10..a737a371 100644 --- a/pytablewriter/writer/text/_json.py +++ b/pytablewriter/writer/text/_json.py @@ -137,7 +137,7 @@ def _get_opening_row_item_list(self): return ["["] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): if typepy.is_not_null_string(self.table_name): return ["]}"] diff --git a/pytablewriter/writer/text/_latex.py b/pytablewriter/writer/text/_latex.py index 9aa9d33b..44ed4769 100644 --- a/pytablewriter/writer/text/_latex.py +++ b/pytablewriter/writer/text/_latex.py @@ -141,7 +141,7 @@ def _get_opening_row_item_list(self): return ["".join(row_item_list)] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return [r"\end{array} \right)"] def _write_opening_row(self): @@ -219,5 +219,5 @@ def _to_row_item(self, col_dp, value_dp): def _get_header_row_separator_items(self): return [r"\hline"] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return [r"\end{array}"] diff --git a/pytablewriter/writer/text/_markdown.py b/pytablewriter/writer/text/_markdown.py index 7c5777f4..8fcfeac9 100644 --- a/pytablewriter/writer/text/_markdown.py +++ b/pytablewriter/writer/text/_markdown.py @@ -78,7 +78,7 @@ def _get_header_row_separator_items(self): def _get_value_row_separator_items(self): return [] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return [] def write_table(self): diff --git a/pytablewriter/writer/text/_mediawiki.py b/pytablewriter/writer/text/_mediawiki.py index cddcb276..1e154ebd 100644 --- a/pytablewriter/writer/text/_mediawiki.py +++ b/pytablewriter/writer/text/_mediawiki.py @@ -75,7 +75,7 @@ def _get_header_row_separator_items(self): def _get_value_row_separator_items(self): return self._get_header_row_separator_items() - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return ["|}"] def _get_header_format_string(self, col_dp, value_dp): diff --git a/pytablewriter/writer/text/_rst.py b/pytablewriter/writer/text/_rst.py index 51990798..d4e3ff49 100644 --- a/pytablewriter/writer/text/_rst.py +++ b/pytablewriter/writer/text/_rst.py @@ -136,7 +136,7 @@ def _write_header(self): def _get_value_row_separator_items(self): return [] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return [] diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index 948690e2..a0847bd3 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -228,7 +228,7 @@ def _get_value_row_separator_items(self): self.__value_row_separator_cell_format, self.char_value_row_separator ) - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return self.__get_row_separator_items(self.__closing_row_cell_format, self.char_closing_row) def __get_row_separator_items(self, margin_format, separator_char): @@ -327,7 +327,7 @@ def _write_closing_row(self): if not self.is_write_closing_row: return - self.__write_separator_row(self._get_closing_row_item_list()) + self.__write_separator_row(self._get_closing_row_items()) def __make_margin_format(self, margin_char): margin_str = margin_char * self.__margin diff --git a/pytablewriter/writer/text/sourcecode/_javascript.py b/pytablewriter/writer/text/sourcecode/_javascript.py index 0e41f1e5..bed3183b 100644 --- a/pytablewriter/writer/text/sourcecode/_javascript.py +++ b/pytablewriter/writer/text/sourcecode/_javascript.py @@ -129,7 +129,7 @@ def _write_table(self): def _get_opening_row_item_list(self): return ["{:s} {:s} = [".format(self.variable_declaration, self.variable_name)] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return ["];"] def _to_row_item(self, col_dp, value_dp): diff --git a/pytablewriter/writer/text/sourcecode/_numpy.py b/pytablewriter/writer/text/sourcecode/_numpy.py index 3c2874f3..15210d17 100644 --- a/pytablewriter/writer/text/sourcecode/_numpy.py +++ b/pytablewriter/writer/text/sourcecode/_numpy.py @@ -66,5 +66,5 @@ def _get_opening_row_item_list(self): return [array_def] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return ["])"] diff --git a/pytablewriter/writer/text/sourcecode/_pandas.py b/pytablewriter/writer/text/sourcecode/_pandas.py index 1da77bc1..0b1283a3 100644 --- a/pytablewriter/writer/text/sourcecode/_pandas.py +++ b/pytablewriter/writer/text/sourcecode/_pandas.py @@ -66,7 +66,7 @@ def __init__(self): def _get_opening_row_item_list(self): return ["{} = {}.DataFrame([".format(self.variable_name, self.import_pandas_as)] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): if typepy.is_not_empty_sequence(self.headers): return [ "], columns=[{}])".format( diff --git a/pytablewriter/writer/text/sourcecode/_python.py b/pytablewriter/writer/text/sourcecode/_python.py index f9b70613..831c3950 100644 --- a/pytablewriter/writer/text/sourcecode/_python.py +++ b/pytablewriter/writer/text/sourcecode/_python.py @@ -82,5 +82,5 @@ def _get_opening_row_item_list(self): return ["["] - def _get_closing_row_item_list(self): + def _get_closing_row_items(self): return ["]"] From 873b76942b0bdb1eeb48be997cb37ce46246b403 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:19:28 +0900 Subject: [PATCH 15/29] Refactor: rename a method --- pytablewriter/writer/text/_csv.py | 2 +- pytablewriter/writer/text/_json.py | 2 +- pytablewriter/writer/text/_latex.py | 4 ++-- pytablewriter/writer/text/_markdown.py | 2 +- pytablewriter/writer/text/_mediawiki.py | 2 +- pytablewriter/writer/text/_rst.py | 2 +- pytablewriter/writer/text/_text_writer.py | 4 ++-- pytablewriter/writer/text/sourcecode/_javascript.py | 2 +- pytablewriter/writer/text/sourcecode/_numpy.py | 2 +- pytablewriter/writer/text/sourcecode/_pandas.py | 2 +- pytablewriter/writer/text/sourcecode/_python.py | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pytablewriter/writer/text/_csv.py b/pytablewriter/writer/text/_csv.py index 38ecccbc..1e24e0aa 100644 --- a/pytablewriter/writer/text/_csv.py +++ b/pytablewriter/writer/text/_csv.py @@ -43,7 +43,7 @@ def _write_header(self): super(CsvTableWriter, self)._write_header() - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return [] def _get_value_row_separator_items(self): diff --git a/pytablewriter/writer/text/_json.py b/pytablewriter/writer/text/_json.py index a737a371..9a7f614f 100644 --- a/pytablewriter/writer/text/_json.py +++ b/pytablewriter/writer/text/_json.py @@ -131,7 +131,7 @@ def __get_data_helper(dp): return dp.data - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): if typepy.is_not_null_string(self.table_name): return ['{{ "{:s}" : ['.format(MultiByteStrDecoder(self.table_name).unicode_str)] diff --git a/pytablewriter/writer/text/_latex.py b/pytablewriter/writer/text/_latex.py index 44ed4769..33ac67a4 100644 --- a/pytablewriter/writer/text/_latex.py +++ b/pytablewriter/writer/text/_latex.py @@ -127,7 +127,7 @@ def _to_row_item(self, col_dp, value_dp): def _get_header_row_separator_items(self): return [] - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): row_item_list = [] if typepy.is_not_null_string(self.table_name): @@ -182,7 +182,7 @@ def __init__(self): self.char_right_side_row = r" \\ \hline" self._dp_extractor.type_value_map[Typecode.INFINITY] = r"\infty" - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return [ "".join( [ diff --git a/pytablewriter/writer/text/_markdown.py b/pytablewriter/writer/text/_markdown.py index 8fcfeac9..f29d4b1b 100644 --- a/pytablewriter/writer/text/_markdown.py +++ b/pytablewriter/writer/text/_markdown.py @@ -55,7 +55,7 @@ def _to_row_item(self, col_dp, value_dp): super(MarkdownTableWriter, self)._to_row_item(col_dp, value_dp) ) - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return [] def _get_header_row_separator_items(self): diff --git a/pytablewriter/writer/text/_mediawiki.py b/pytablewriter/writer/text/_mediawiki.py index 1e154ebd..1881954b 100644 --- a/pytablewriter/writer/text/_mediawiki.py +++ b/pytablewriter/writer/text/_mediawiki.py @@ -66,7 +66,7 @@ def _write_value_row(self, value_list, value_dp_list): ] ) - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return ['{| class="wikitable"'] def _get_header_row_separator_items(self): diff --git a/pytablewriter/writer/text/_rst.py b/pytablewriter/writer/text/_rst.py index d4e3ff49..6861d947 100644 --- a/pytablewriter/writer/text/_rst.py +++ b/pytablewriter/writer/text/_rst.py @@ -101,7 +101,7 @@ def write_table(self): IndentationTextTableWriter.write_table(self) - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): directive = ".. csv-table:: " if typepy.is_null_string(self.table_name): diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index a0847bd3..0569713d 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -215,7 +215,7 @@ def _write_table(self): self._write_closing_row() - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return self.__get_row_separator_items(self.__opening_row_cell_format, self.char_opening_row) def _get_header_row_separator_items(self): @@ -306,7 +306,7 @@ def _write_opening_row(self): if not self.is_write_opening_row: return - self.__write_separator_row(self._get_opening_row_item_list()) + self.__write_separator_row(self._get_opening_row_items()) def __write_header_row_separator(self): if any([not self.is_write_header, not self.is_write_header_separator_row]): diff --git a/pytablewriter/writer/text/sourcecode/_javascript.py b/pytablewriter/writer/text/sourcecode/_javascript.py index bed3183b..ed564e3d 100644 --- a/pytablewriter/writer/text/sourcecode/_javascript.py +++ b/pytablewriter/writer/text/sourcecode/_javascript.py @@ -126,7 +126,7 @@ def _write_table(self): self._write_line(js_matrix_var_def_text) self.inc_indent_level() - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return ["{:s} {:s} = [".format(self.variable_declaration, self.variable_name)] def _get_closing_row_items(self): diff --git a/pytablewriter/writer/text/sourcecode/_numpy.py b/pytablewriter/writer/text/sourcecode/_numpy.py index 15210d17..061b82ad 100644 --- a/pytablewriter/writer/text/sourcecode/_numpy.py +++ b/pytablewriter/writer/text/sourcecode/_numpy.py @@ -58,7 +58,7 @@ def __init__(self): self.import_numpy_as ) - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): array_def = "{:s}.array([".format(self.import_numpy_as) if typepy.is_not_null_string(self.table_name): diff --git a/pytablewriter/writer/text/sourcecode/_pandas.py b/pytablewriter/writer/text/sourcecode/_pandas.py index 0b1283a3..0a30cedb 100644 --- a/pytablewriter/writer/text/sourcecode/_pandas.py +++ b/pytablewriter/writer/text/sourcecode/_pandas.py @@ -63,7 +63,7 @@ def __init__(self): self.import_pandas_as = "pd" self.is_write_header = False - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): return ["{} = {}.DataFrame([".format(self.variable_name, self.import_pandas_as)] def _get_closing_row_items(self): diff --git a/pytablewriter/writer/text/sourcecode/_python.py b/pytablewriter/writer/text/sourcecode/_python.py index 831c3950..a1c5355b 100644 --- a/pytablewriter/writer/text/sourcecode/_python.py +++ b/pytablewriter/writer/text/sourcecode/_python.py @@ -76,7 +76,7 @@ def _write_table(self): super(PythonCodeTableWriter, self)._write_table() self.dec_indent_level() - def _get_opening_row_item_list(self): + def _get_opening_row_items(self): if typepy.is_not_null_string(self.table_name): return [self.variable_name + " = ["] From 1dadff172cb9dd1d411dc9d9d907ef7f3b000972 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:21:39 +0900 Subject: [PATCH 16/29] Refactor: rename a loop variable --- pytablewriter/writer/text/_html.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytablewriter/writer/text/_html.py b/pytablewriter/writer/text/_html.py index 95c65a27..7d2e8a1d 100644 --- a/pytablewriter/writer/text/_html.py +++ b/pytablewriter/writer/text/_html.py @@ -106,9 +106,9 @@ def _write_body(self): tags = _get_tags_module() tbody_tag = tags.tbody() - for value_list, value_dp_list in zip(self._table_value_matrix, self._table_value_dp_matrix): + for values, value_dp_list in zip(self._table_value_matrix, self._table_value_dp_matrix): tr_tag = tags.tr() - for value, value_dp, styler in zip(value_list, value_dp_list, self._styler_list): + for value, value_dp, styler in zip(values, value_dp_list, self._styler_list): td_tag = tags.td(MultiByteStrDecoder(value).unicode_str) td_tag["align"] = value_dp.align.align_string From 33bc672c152976bafc12043c077a0436e7234d4b Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:24:55 +0900 Subject: [PATCH 17/29] Refactor: rename local variables --- pytablewriter/writer/_elasticsearch.py | 4 ++-- pytablewriter/writer/text/_json.py | 4 +--- pytablewriter/writer/text/_jsonlines.py | 4 ++-- pytablewriter/writer/text/_ltsv.py | 4 ++-- pytablewriter/writer/text/_text_writer.py | 4 ++-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/pytablewriter/writer/_elasticsearch.py b/pytablewriter/writer/_elasticsearch.py index 87e029c7..a1ee435e 100644 --- a/pytablewriter/writer/_elasticsearch.py +++ b/pytablewriter/writer/_elasticsearch.py @@ -155,12 +155,12 @@ def _get_body(self): str_datatype = (Typecode.DATETIME, Typecode.IP_ADDRESS, Typecode.INFINITY, Typecode.NAN) for value_dp_list in self._table_value_dp_matrix: - value_list = [ + values = [ value_dp.data if value_dp.typecode not in str_datatype else value_dp.to_str() for value_dp in value_dp_list ] - yield dict(zip(self.headers, value_list)) + yield dict(zip(self.headers, values)) def _write_table(self): import elasticsearch as es diff --git a/pytablewriter/writer/text/_json.py b/pytablewriter/writer/text/_json.py index 9a7f614f..0e388eaf 100644 --- a/pytablewriter/writer/text/_json.py +++ b/pytablewriter/writer/text/_json.py @@ -115,9 +115,7 @@ def _preprocess_value_matrix(self): value_matrix = [[self.__get_data_helper(dp) for dp in dp_list] for dp_list in dp_matrix] - self._table_value_matrix = [ - dict(zip(self.headers, value_list)) for value_list in value_matrix - ] + self._table_value_matrix = [dict(zip(self.headers, values)) for values in value_matrix] self._is_complete_value_matrix_preprocess = True diff --git a/pytablewriter/writer/text/_jsonlines.py b/pytablewriter/writer/text/_jsonlines.py index 7c3e3034..d44aed7e 100644 --- a/pytablewriter/writer/text/_jsonlines.py +++ b/pytablewriter/writer/text/_jsonlines.py @@ -44,5 +44,5 @@ def write_table(self): self._verify_property() self._preprocess() - for value_list in self._table_value_matrix: - self._write_line(json.dumps(value_list)) + for values in self._table_value_matrix: + self._write_line(json.dumps(values)) diff --git a/pytablewriter/writer/text/_ltsv.py b/pytablewriter/writer/text/_ltsv.py index 94400e89..0d5ff728 100644 --- a/pytablewriter/writer/text/_ltsv.py +++ b/pytablewriter/writer/text/_ltsv.py @@ -50,10 +50,10 @@ def write_table(self): self._verify_property() self._preprocess() - for value_list in self._table_value_matrix: + 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, value_list) + for header_name, value in zip(self.headers, values) if typepy.is_not_null_string(value) ] diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index 0569713d..0f078619 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -201,7 +201,7 @@ def _write_table(self): pass is_first_value_row = True - for value_list, value_dp_list in zip(self._table_value_matrix, self._table_value_dp_matrix): + 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 @@ -209,7 +209,7 @@ def _write_table(self): if self.is_write_value_separator_row: self._write_value_row_separator() - self._write_value_row(value_list, value_dp_list) + self._write_value_row(values, value_dp_list) except TypeError: continue From ef389b50153ba32c9f381d3953a20ebcb8479354 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:26:26 +0900 Subject: [PATCH 18/29] Refactor: rename arguments --- pytablewriter/writer/text/_mediawiki.py | 4 ++-- pytablewriter/writer/text/_text_writer.py | 20 ++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pytablewriter/writer/text/_mediawiki.py b/pytablewriter/writer/text/_mediawiki.py index 1881954b..a11b5261 100644 --- a/pytablewriter/writer/text/_mediawiki.py +++ b/pytablewriter/writer/text/_mediawiki.py @@ -58,11 +58,11 @@ def _write_header(self): super(MediaWikiTableWriter, self)._write_header() - def _write_value_row(self, value_list, value_dp_list): + def _write_value_row(self, values, value_dp_list): self._write_row( [ self.__modify_table_element(value, value_dp) - for value, value_dp, in zip(value_list, value_dp_list) + for value, value_dp, in zip(values, value_dp_list) ] ) diff --git a/pytablewriter/writer/text/_text_writer.py b/pytablewriter/writer/text/_text_writer.py index 0f078619..1a4b759b 100644 --- a/pytablewriter/writer/text/_text_writer.py +++ b/pytablewriter/writer/text/_text_writer.py @@ -265,14 +265,12 @@ def _write(self, text): def _write_line(self, text=""): self._write_raw_line(text) - def _write_row(self, value_list): - if typepy.is_empty_sequence(value_list): + def _write_row(self, values): + if typepy.is_empty_sequence(values): return self._write_line( - self.char_left_side_row - + self.column_delimiter.join(value_list) - + self.char_right_side_row + self.char_left_side_row + self.column_delimiter.join(values) + self.char_right_side_row ) def _write_header(self): @@ -284,11 +282,11 @@ def _write_header(self): self._write_row(self._table_header_list) - def _write_value_row(self, value_list, value_dp_list): - self._write_row(value_list) + def _write_value_row(self, values, value_dp_list): + self._write_row(values) - def __write_separator_row(self, value_list): - if typepy.is_empty_sequence(value_list): + def __write_separator_row(self, values): + if typepy.is_empty_sequence(values): return left_cross_point = self.char_cross_point @@ -298,9 +296,7 @@ def __write_separator_row(self, value_list): if typepy.is_null_string(self.char_right_side_row): right_cross_point = "" - self._write_line( - left_cross_point + self.char_cross_point.join(value_list) + right_cross_point - ) + self._write_line(left_cross_point + self.char_cross_point.join(values) + right_cross_point) def _write_opening_row(self): if not self.is_write_opening_row: From 6a84db7015bb599912ed3377b1e29d9d5756fbf6 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:30:06 +0900 Subject: [PATCH 19/29] Rename a variable --- test/sanitizer/_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sanitizer/_common.py b/test/sanitizer/_common.py index 72276c5f..7e596acb 100644 --- a/test/sanitizer/_common.py +++ b/test/sanitizer/_common.py @@ -10,7 +10,7 @@ import string -alphanum_char_list = [x for x in string.digits + string.ascii_letters] +alphanum_chars = [x for x in string.digits + string.ascii_letters] INVALID_PATH_CHARS = ["\0"] @@ -77,5 +77,5 @@ INVALID_PYTHON_VAR_CHARS = INVALID_JS_VAR_CHARS + ["$"] -def make_random_str(length, char_list=alphanum_char_list): +def make_random_str(length, char_list=alphanum_chars): return "".join([random.choice(char_list) for _i in range(length)]) From dfbdb781a63b11264b6641e54d62b5922f6f4434 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Sat, 16 Feb 2019 12:33:43 +0900 Subject: [PATCH 20/29] Rename an argument --- test/sanitizer/_common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sanitizer/_common.py b/test/sanitizer/_common.py index 7e596acb..8b4c56f5 100644 --- a/test/sanitizer/_common.py +++ b/test/sanitizer/_common.py @@ -77,5 +77,5 @@ INVALID_PYTHON_VAR_CHARS = INVALID_JS_VAR_CHARS + ["$"] -def make_random_str(length, char_list=alphanum_chars): - return "".join([random.choice(char_list) for _i in range(length)]) +def make_random_str(length, chars=alphanum_chars): + return "".join([random.choice(chars) for _i in range(length)]) From c4fea529b6bb85caf31b3257d266063ef6357d60 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 20:39:16 +0900 Subject: [PATCH 21/29] Update requirements --- requirements/requirements.txt | 6 +++--- setup.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 7ee5ec21..4e5c33b1 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -1,9 +1,9 @@ DataProperty>=0.42.0,<1.0.0 enum34;python_version<"3.4" ipaddress;python_version<"3.3" -mbstrdecoder[all]>=0.6.2,<1.0.0 +mbstrdecoder[all]>=0.7.0,<1.0.0 msgfy>=0.0.5,<0.1.0 -pathvalidate>=0.24.0,<1.0.0 +pathvalidate>=0.24.1,<1.0.0 six>=1.11.0,<2.0.0 -tabledata>=0.7.1,<1.0.0 +tabledata>=0.8.0,<1.0.0 typepy[datetime]>=0.4.0,<1.0.0 diff --git a/setup.py b/setup.py index 8c48e179..38a9c85a 100644 --- a/setup.py +++ b/setup.py @@ -57,10 +57,10 @@ def get_release_command_class(): excel_requires = ["xlwt", "XlsxWriter>=1.1.4,<2.0.0"] es6_requires = ["elasticsearch>=6.2.0,<7.0.0"] -from_requires = ["pytablereader>=0.24.1,<1.0.0"] +from_requires = ["pytablereader>=0.25.0,<1.0.0"] html_requires = ["dominate>=2.3.5,<3.0.0"] logging_requires = ["Logbook>=1.1.0,<2.0.0"] -sqlite_requires = ["SimpleSQLite>=0.39.0,<1.0.0"] +sqlite_requires = ["SimpleSQLite>=0.39.1,<1.0.0"] toml_requires = ["toml>=0.9.4,<1.0.0"] optional_requires = ["simplejson>=3.16,<4.0"] all_requires = ( From 0c6c5ada02a51177545648aee7d2b93b471826d0 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 20:42:47 +0900 Subject: [PATCH 22/29] Add pandas.DataFrame pickle support for from_dataframe method --- pytablewriter/writer/_table_writer.py | 11 ++++++++--- test/test_markdown_writer.py | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/pytablewriter/writer/_table_writer.py b/pytablewriter/writer/_table_writer.py index f750343c..ab00ce5d 100644 --- a/pytablewriter/writer/_table_writer.py +++ b/pytablewriter/writer/_table_writer.py @@ -615,15 +615,15 @@ def from_csv(self, csv_source, delimiter=","): def from_dataframe(self, dataframe, add_index_column=False): """ Set tabular attributes to the writer from :py:class:`pandas.DataFrame`. - Following attributes are set to the writer by the method: + Following attributes are set by the method: - :py:attr:`~.headers`. - :py:attr:`~.value_matrix`. - :py:attr:`~.type_hints`. Args: - dataframe(pandas.DataFrame): - Input dataframe. + dataframe(pandas.DataFrame or |str|): + Input pandas.DataFrame object or pickle. add_index_column(bool, optional): If |True|, add a column of ``index`` of the ``dataframe``. Defaults to |False|. @@ -632,6 +632,11 @@ def from_dataframe(self, dataframe, add_index_column=False): :ref:`example-from-pandas-dataframe` """ + if typepy.String(dataframe).is_type(): + import pandas as pd + + dataframe = pd.read_pickle(dataframe) + self.headers = list(dataframe.columns.values) self.type_hints = [self.__get_typehint_from_dtype(dtype) for dtype in dataframe.dtypes] diff --git a/test/test_markdown_writer.py b/test/test_markdown_writer.py index 69bebdf7..b191a2ce 100644 --- a/test/test_markdown_writer.py +++ b/test/test_markdown_writer.py @@ -1121,15 +1121,21 @@ class Test_MarkdownTableWriter_from_dataframe(object): ], ], ) - def test_normal(self, add_index_column, expected): + def test_normal(self, tmpdir, add_index_column, expected): writer = table_writer_class() writer.table_name = "add_index_column: {}".format(add_index_column) - writer.from_dataframe( - pd.DataFrame({"A": [1, 2], "B": [10, 11]}, index=["a", "b"]), - add_index_column=add_index_column, - ) + df = pd.DataFrame({"A": [1, 2], "B": [10, 11]}, index=["a", "b"]) + writer.from_dataframe(df, add_index_column=add_index_column) out = writer.dumps() print_test_result(expected=expected, actual=out) - assert out == expected + + if not SKIP_DATAFRAME_TEST: + df_pkl_filepath = str(tmpdir.join("df.pkl")) + df.to_pickle(df_pkl_filepath) + + writer.from_dataframe(df_pkl_filepath, add_index_column=add_index_column) + out = writer.dumps() + print_test_result(expected=expected, actual=out) + assert out == expected From 07f811be12f3407e4a96b9e1f65c032cab21ba00 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:10:23 +0900 Subject: [PATCH 23/29] Modify a test case --- test/test_markdown_writer.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_markdown_writer.py b/test/test_markdown_writer.py index b191a2ce..3e7dc1bd 100644 --- a/test/test_markdown_writer.py +++ b/test/test_markdown_writer.py @@ -1131,11 +1131,11 @@ def test_normal(self, tmpdir, add_index_column, expected): print_test_result(expected=expected, actual=out) assert out == expected - if not SKIP_DATAFRAME_TEST: - df_pkl_filepath = str(tmpdir.join("df.pkl")) - df.to_pickle(df_pkl_filepath) - - writer.from_dataframe(df_pkl_filepath, add_index_column=add_index_column) - out = writer.dumps() - print_test_result(expected=expected, actual=out) - assert out == expected + # pickle test + df_pkl_filepath = str(tmpdir.join("df.pkl")) + df.to_pickle(df_pkl_filepath) + + writer.from_dataframe(df_pkl_filepath, add_index_column=add_index_column) + out = writer.dumps() + print_test_result(expected=expected, actual=out) + assert out == expected From f15bf27afe89b2d1b1ba20b6c1ca42ffe6bb2937 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:52:49 +0900 Subject: [PATCH 24/29] Update docstring --- pytablewriter/writer/_table_writer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pytablewriter/writer/_table_writer.py b/pytablewriter/writer/_table_writer.py index ab00ce5d..520da115 100644 --- a/pytablewriter/writer/_table_writer.py +++ b/pytablewriter/writer/_table_writer.py @@ -617,9 +617,9 @@ def from_dataframe(self, dataframe, add_index_column=False): Set tabular attributes to the writer from :py:class:`pandas.DataFrame`. Following attributes are set by the method: - - :py:attr:`~.headers`. - - :py:attr:`~.value_matrix`. - - :py:attr:`~.type_hints`. + - :py:attr:`~.headers` + - :py:attr:`~.value_matrix` + - :py:attr:`~.type_hints` Args: dataframe(pandas.DataFrame or |str|): From 89ed1d3476b58342eed6d1eca67191e49a7df52b Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:54:10 +0900 Subject: [PATCH 25/29] Add from_series method --- pytablewriter/writer/_table_writer.py | 34 +++++++++++++++++ test/test_markdown_writer.py | 55 +++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/pytablewriter/writer/_table_writer.py b/pytablewriter/writer/_table_writer.py index 520da115..a7d2d123 100644 --- a/pytablewriter/writer/_table_writer.py +++ b/pytablewriter/writer/_table_writer.py @@ -651,6 +651,40 @@ def from_dataframe(self, dataframe, add_index_column=False): else: self.value_matrix = dataframe.values.tolist() + def from_series(self, series, add_index_column=True): + """ + Set tabular attributes to the writer from :py:class:`pandas.Series`. + Following attributes are set by the method: + + - :py:attr:`~.headers` + - :py:attr:`~.value_matrix` + - :py:attr:`~.type_hints` + + Args: + series(pandas.Series): + Input pandas.Series object. + add_index_column(bool, optional): + If |True|, add a column of ``index`` of the ``series``. + Defaults to |True|. + """ + + if series.name: + self.headers = [series.name] + else: + self.headers = ["value"] + + self.type_hints = [self.__get_typehint_from_dtype(series.dtype)] + + if add_index_column: + self.headers = [""] + self.headers + if self.type_hints: + self.type_hints = [None] + self.type_hints + self.value_matrix = [ + [index] + [value] for index, value in zip(series.index.tolist(), series.tolist()) + ] + else: + self.value_matrix = [[value] for value in series.tolist()] + def from_tablib(self, tablib_dataset): """ Set tabular attributes to the writer from :py:class:`tablib.Dataset`. diff --git a/test/test_markdown_writer.py b/test/test_markdown_writer.py index 3e7dc1bd..618d8ba3 100644 --- a/test/test_markdown_writer.py +++ b/test/test_markdown_writer.py @@ -1139,3 +1139,58 @@ def test_normal(self, tmpdir, add_index_column, expected): out = writer.dumps() print_test_result(expected=expected, actual=out) assert out == expected + + +@pytest.mark.skipif("SKIP_DATAFRAME_TEST is True") +class Test_MarkdownTableWriter_from_series(object): + @pytest.mark.parametrize( + ["add_index_column", "expected"], + [ + [ + False, + dedent( + """\ + # add_index_column: False + |value | + |-----:| + |100.00| + | 49.50| + | 29.01| + | 0.00| + | 24.75| + | 49.50| + | 74.25| + | 99.00| + """ + ), + ], + [ + True, + dedent( + """\ + # add_index_column: True + | |value | + |-----|-----:| + |count|100.00| + |mean | 49.50| + |std | 29.01| + |min | 0.00| + |25% | 24.75| + |50% | 49.50| + |75% | 74.25| + |max | 99.00| + """ + ), + ], + ], + ) + def test_normal(self, add_index_column, expected): + writer = table_writer_class() + writer.table_name = "add_index_column: {}".format(add_index_column) + + writer.from_series( + pd.Series(list(range(100))).describe(), add_index_column=add_index_column + ) + out = writer.dumps() + print_test_result(expected=expected, actual=out) + assert out == expected From 13923921f75355f4bac7d5df77aca1a6a783d3cb Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:55:19 +0900 Subject: [PATCH 26/29] Update docs --- docs/index.rst | 7 +++ docs/pages/examples/basic.rst | 43 +++++++------------ docs/pages/examples/index.rst | 3 +- .../examples/{ => output}/dump/dumps.txt | 2 +- .../examples/{ => output}/dump/index.rst | 0 docs/pages/examples/output/index.rst | 8 ++++ .../examples/{ => output}/stream/index.rst | 0 docs/pages/introduction/feature.txt | 13 ++++-- 8 files changed, 43 insertions(+), 33 deletions(-) rename docs/pages/examples/{ => output}/dump/dumps.txt (95%) rename docs/pages/examples/{ => output}/dump/index.rst (100%) create mode 100644 docs/pages/examples/output/index.rst rename docs/pages/examples/{ => output}/stream/index.rst (100%) diff --git a/docs/index.rst b/docs/index.rst index 6754cf2a..bf4b5693 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,6 +1,13 @@ Welcome to pytablewriter's documentation! ========================================= +.. raw:: html + +
+ +
+
+ .. toctree:: :caption: Table of Contents :maxdepth: 4 diff --git a/docs/pages/examples/basic.rst b/docs/pages/examples/basic.rst index aff70f58..9ae88f2b 100644 --- a/docs/pages/examples/basic.rst +++ b/docs/pages/examples/basic.rst @@ -6,21 +6,15 @@ Basic usage of the ``pytablewriter`` is as follows: 2. Assign a value to instance variables (such as |table_name|/|headers|/|value_matrix|) of the writer 3. Call the ``write_table`` method -Next examples show how to write a table to the standard output/file with reStructuredText format. - - -Write a table to the standard output (defaults) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The standard output is the default output stream of writers -(except the |ExcelXlsxTableWriter|). +The next example show how to write a table with markdown format: :Sample Code: .. code-block:: python - :caption: Write a table to stdout + :caption: Write a table - import pytablewriter + from pytablewriter import MarkdownTableWriter - writer = pytablewriter.RstGridTableWriter() + writer = MarkdownTableWriter() writer.table_name = "zone" writer.headers = ["zone_id", "country_code", "zone_name"] writer.value_matrix = [ @@ -34,20 +28,15 @@ The standard output is the default output stream of writers writer.write_table() :Output: - .. code-block:: ReST - - .. table:: zone - - +-------+------------+----------------+ - |zone_id|country_code| zone_name | - +=======+============+================+ - | 1|AD |Europe/Andorra | - +-------+------------+----------------+ - | 2|AE |Asia/Dubai | - +-------+------------+----------------+ - | 3|AF |Asia/Kabul | - +-------+------------+----------------+ - | 4|AG |America/Antigua | - +-------+------------+----------------+ - | 5|AI |America/Anguilla| - +-------+------------+----------------+ + .. code-block:: none + + # zone + |zone_id|country_code| zone_name | + |------:|------------|----------------| + | 1|AD |Europe/Andorra | + | 2|AE |Asia/Dubai | + | 3|AF |Asia/Kabul | + | 4|AG |America/Antigua | + | 5|AI |America/Anguilla| + +The default output stream is the standard output for text format writers, binary format writers will write to a binary file that opened by ``open`` method. diff --git a/docs/pages/examples/index.rst b/docs/pages/examples/index.rst index 5c95c56d..fbb217a3 100644 --- a/docs/pages/examples/index.rst +++ b/docs/pages/examples/index.rst @@ -6,10 +6,9 @@ Examples basic table_format/index - stream/index + output/index datasource/index style/index - dump/index multibyte/index typehint/index jupyter_notebook/index diff --git a/docs/pages/examples/dump/dumps.txt b/docs/pages/examples/output/dump/dumps.txt similarity index 95% rename from docs/pages/examples/dump/dumps.txt rename to docs/pages/examples/output/dump/dumps.txt index 2498cd96..42410795 100644 --- a/docs/pages/examples/dump/dumps.txt +++ b/docs/pages/examples/output/dump/dumps.txt @@ -1,5 +1,5 @@ ``dumps`` method returns rendered tabular text. -``dumps`` available only for text format writers. +``dumps`` only available for text format writers. :Sample Code: .. code-block:: python diff --git a/docs/pages/examples/dump/index.rst b/docs/pages/examples/output/dump/index.rst similarity index 100% rename from docs/pages/examples/dump/index.rst rename to docs/pages/examples/output/dump/index.rst diff --git a/docs/pages/examples/output/index.rst b/docs/pages/examples/output/index.rst new file mode 100644 index 00000000..7686c900 --- /dev/null +++ b/docs/pages/examples/output/index.rst @@ -0,0 +1,8 @@ +Configure output +================ + +.. toctree:: + :maxdepth: 2 + + stream/index + dump/index diff --git a/docs/pages/examples/stream/index.rst b/docs/pages/examples/output/stream/index.rst similarity index 100% rename from docs/pages/examples/stream/index.rst rename to docs/pages/examples/output/stream/index.rst diff --git a/docs/pages/introduction/feature.txt b/docs/pages/introduction/feature.txt index 11dd3784..46970571 100644 --- a/docs/pages/introduction/feature.txt +++ b/docs/pages/introduction/feature.txt @@ -14,7 +14,7 @@ Features - Source code - JavaScript code (Definition of a nested list variable) - `NumPy `__ (Definition of a `numpy.array `__ variable) - - `Pandas `__ (Definition of a `pandas.DataFrame `__ variable) + - `Pandas `__ (Definition of a `pandas.DataFrame `__ variable) - Python code (Definition of a nested list variable) - Space aligned values - `TOML `__ @@ -31,7 +31,14 @@ Features - Text alignment - Font size/weight - Thousand separator for numbers: e.g. ``1,000``/``1 000`` +- Configure ouput: + - Write table to a stream such as a file/standard-output/string-buffer/Jupyter-Notebook + - Get rendered tabular text +- Data source + - nested list + - CSV + - `pandas.DataFrame `__ + - `pandas.Series `__ + - etc. - Multibyte character support -- Write table to a stream such as a file/standard-output/string-buffer/Jupyter-Notebook -- Get rendered tabular text - ANSI color support From 0c56b228c4d4f39f1c0ac6dff74d8118ee28f3f0 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:57:11 +0900 Subject: [PATCH 27/29] Update examples --- examples/ipynb/pytablewriter_examples.ipynb | 107 +++++++++++++------- examples/py/from_pandas_dataframe.py | 3 +- 2 files changed, 73 insertions(+), 37 deletions(-) diff --git a/examples/ipynb/pytablewriter_examples.ipynb b/examples/ipynb/pytablewriter_examples.ipynb index 6ab3d4c6..90fb69f8 100644 --- a/examples/ipynb/pytablewriter_examples.ipynb +++ b/examples/ipynb/pytablewriter_examples.ipynb @@ -69,7 +69,7 @@ } ], "source": [ - "for name in pytablewriter.TableWriterFactory.get_format_name_list():\n", + "for name in pytablewriter.TableWriterFactory.get_format_names():\n", " print(name)" ] }, @@ -105,13 +105,50 @@ } ], "source": [ - "for name in pytablewriter.TableWriterFactory.get_extension_list():\n", + "for name in pytablewriter.TableWriterFactory.get_extensions():\n", " print(name)" ] }, { "cell_type": "code", "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "# zone\n", + "|zone_id|country_code| zone_name |\n", + "|------:|------------|----------------|\n", + "| 1|AD |Europe/Andorra |\n", + "| 2|AE |Asia/Dubai |\n", + "| 3|AF |Asia/Kabul |\n", + "| 4|AG |America/Antigua |\n", + "| 5|AI |America/Anguilla|\n" + ] + } + ], + "source": [ + "from pytablewriter import MarkdownTableWriter\n", + "\n", + "writer = MarkdownTableWriter()\n", + "writer.table_name = \"zone\"\n", + "writer.headers = [\"zone_id\", \"country_code\", \"zone_name\"]\n", + "writer.value_matrix = [\n", + " [\"1\", \"AD\", \"Europe/Andorra\"],\n", + " [\"2\", \"AE\", \"Asia/Dubai\"],\n", + " [\"3\", \"AF\", \"Asia/Kabul\"],\n", + " [\"4\", \"AG\", \"America/Antigua\"],\n", + " [\"5\", \"AI\", \"America/Anguilla\"],\n", + "]\n", + "\n", + "writer.write_table()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, "metadata": { "scrolled": true }, @@ -138,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -168,7 +205,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -193,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -261,7 +298,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -289,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -343,7 +380,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -367,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -421,7 +458,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -464,7 +501,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": { "scrolled": true }, @@ -512,7 +549,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -554,7 +591,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -582,7 +619,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -611,7 +648,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -669,7 +706,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 19, "metadata": { "scrolled": true }, @@ -699,7 +736,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -726,7 +763,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -754,7 +791,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -782,7 +819,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -811,7 +848,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 24, "metadata": { "scrolled": false }, @@ -847,7 +884,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -878,7 +915,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -907,7 +944,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -931,7 +968,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -984,7 +1021,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -1029,7 +1066,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -1073,7 +1110,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -1101,7 +1138,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -1137,7 +1174,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1179,7 +1216,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": { "scrolled": true }, @@ -1230,7 +1267,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -1272,7 +1309,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -1306,7 +1343,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -1342,7 +1379,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "metadata": {}, "outputs": [ { diff --git a/examples/py/from_pandas_dataframe.py b/examples/py/from_pandas_dataframe.py index 1542c311..88255b56 100644 --- a/examples/py/from_pandas_dataframe.py +++ b/examples/py/from_pandas_dataframe.py @@ -7,11 +7,10 @@ from textwrap import dedent +import pandas as pd import pytablewriter import six -import pandas as pd - df = pd.read_csv(six.StringIO(dedent("""\ "i","f","c","if","ifc","bool","inf","nan","mix_num","time" From 4f84320e464aadd765c0926b2cf12853ef1fc22b Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 21:57:26 +0900 Subject: [PATCH 28/29] Update README --- README.rst | 15 +++++++++++---- docs/make_readme.py | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 5ca35da7..73eb2b93 100644 --- a/README.rst +++ b/README.rst @@ -46,7 +46,7 @@ Features - Source code - JavaScript code (Definition of a nested list variable) - `NumPy `__ (Definition of a `numpy.array `__ variable) - - `Pandas `__ (Definition of a `pandas.DataFrame `__ variable) + - `Pandas `__ (Definition of a `pandas.DataFrame `__ variable) - Python code (Definition of a nested list variable) - Space aligned values - `TOML `__ @@ -63,9 +63,16 @@ Features - Text alignment - Font size/weight - Thousand separator for numbers: e.g. ``1,000``/``1 000`` +- Configure ouput: + - Write table to a stream such as a file/standard-output/string-buffer/Jupyter-Notebook + - Get rendered tabular text +- Data source + - nested list + - CSV + - `pandas.DataFrame `__ + - `pandas.Series `__ + - etc. - Multibyte character support -- Write table to a stream such as a file/standard-output/string-buffer/Jupyter-Notebook -- Get rendered tabular text - ANSI color support Examples @@ -345,7 +352,7 @@ Write a markdown table from a space-separated values Get rendered tabular text as str ---------------------------------- ``dumps`` method returns rendered tabular text. -``dumps`` available only for text format writers. +``dumps`` only available for text format writers. :Sample Code: .. code-block:: python diff --git a/docs/make_readme.py b/docs/make_readme.py index b073cb65..cf772058 100644 --- a/docs/make_readme.py +++ b/docs/make_readme.py @@ -62,7 +62,7 @@ def write_examples(maker): maker.set_indent_level(1) maker.write_chapter("Get rendered tabular text as str") - maker.write_file(examples_root.joinpath("dump", "dumps.txt")) + maker.write_file(examples_root.joinpath("output", "dump", "dumps.txt")) maker.set_indent_level(1) maker.write_chapter("Configure table styles") From 2063a28f2382f4846868b5b7267f82818e8a04e9 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Hombashi Date: Mon, 18 Feb 2019 22:10:49 +0900 Subject: [PATCH 29/29] Bump version --- pytablewriter/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytablewriter/__version__.py b/pytablewriter/__version__.py index 0fa54b74..1bb1527d 100644 --- a/pytablewriter/__version__.py +++ b/pytablewriter/__version__.py @@ -6,6 +6,6 @@ __author__ = "Tsuyoshi Hombashi" __copyright__ = "Copyright 2016-{}, {}".format(datetime.now().year, __author__) __license__ = "MIT License" -__version__ = "0.43.1" +__version__ = "0.44.0" __maintainer__ = __author__ __email__ = "tsuyoshi.hombashi@gmail.com"