From d2cbb5decf6a1035b4157ed1156e97d9f7429e00 Mon Sep 17 00:00:00 2001 From: chfw Date: Fri, 28 Jan 2022 23:47:23 +0000 Subject: [PATCH] :green_heart: convert print to log. resolves #112 --- changelog.yml | 6 ++++++ pyexcel-io.yml | 6 +++--- pyexcel_io/database/importers/django.py | 2 +- pyexcel_io/database/importers/sqlalchemy.py | 10 +++++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/changelog.yml b/changelog.yml index 6a2482d..1a42dff 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,12 @@ name: pyexcel-io organisation: pyexcel releases: +- changes: + - action: updated + details: + - "`#112`: Log "Empty Row Warning" instead 'print' " + version: 0.6.6 + date: 31.1.2022 - changes: - action: updated details: diff --git a/pyexcel-io.yml b/pyexcel-io.yml index 24df243..7c32477 100644 --- a/pyexcel-io.yml +++ b/pyexcel-io.yml @@ -3,9 +3,9 @@ project: "pyexcel-io" name: pyexcel-io nick_name: io version: 0.6.5 -current_version: 0.6.5 -release: 0.6.5 -copyright_year: 2015-2020 +current_version: 0.6.6 +release: 0.6.6 +copyright_year: 2015-2022 moban_command: false is_on_conda: true dependencies: diff --git a/pyexcel_io/database/importers/django.py b/pyexcel_io/database/importers/django.py index 1c30f3d..101c43c 100644 --- a/pyexcel_io/database/importers/django.py +++ b/pyexcel_io/database/importers/django.py @@ -31,7 +31,7 @@ class DjangoModelWriter(ISheetWriter): def write_row(self, array): if is_empty_array(array): - print(constants.MESSAGE_EMPTY_ARRAY) + log.warning(constants.MESSAGE_EMPTY_ARRAY) else: new_array = swap_empty_string_for_none(array) if self.mapdict: diff --git a/pyexcel_io/database/importers/sqlalchemy.py b/pyexcel_io/database/importers/sqlalchemy.py index 2cb0c30..859077f 100644 --- a/pyexcel_io/database/importers/sqlalchemy.py +++ b/pyexcel_io/database/importers/sqlalchemy.py @@ -7,10 +7,14 @@ :copyright: (c) 2014-2020 by Onni Software Ltd. :license: New BSD License, see LICENSE for more details """ +import logging + import pyexcel_io.constants as constants from pyexcel_io.utils import is_empty_array, swap_empty_string_for_none from pyexcel_io.plugin_api import IWriter, ISheetWriter +LOG = logging.getLogger(__name__) + class PyexcelSQLSkipRowException(Exception): """ @@ -35,14 +39,14 @@ class SQLTableWriter(ISheetWriter): def write_row(self, array): if is_empty_array(array): - print(constants.MESSAGE_EMPTY_ARRAY) + LOG.warning(constants.MESSAGE_EMPTY_ARRAY) else: new_array = swap_empty_string_for_none(array) try: self._write_row(new_array) except PyexcelSQLSkipRowException: - print(constants.MESSAGE_IGNORE_ROW) - print(new_array) + LOG.info(constants.MESSAGE_IGNORE_ROW) + LOG.info(new_array) def _write_row(self, array): new_array = array