From 086aacff85f9f09d4ba2925fd6d53b67c2061685 Mon Sep 17 00:00:00 2001 From: chfw Date: Thu, 4 Apr 2019 21:26:36 +0100 Subject: [PATCH] :wheel_chair: better error message. fix #68 --- .travis.yml | 1 + CHANGELOG.rst | 9 +++++++++ changelog.yml | 6 ++++++ docs/source/conf.py | 4 ++-- pyexcel-io.yml | 6 +++--- pyexcel_io/io.py | 12 +++++++++++- setup.py | 10 +++++----- tests/test_io.py | 12 ++++++------ 8 files changed, 43 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43b2d43..2787c2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ + sudo: false dist: xenial language: python diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 961c5af..8cb0e07 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,15 @@ Change log ================================================================================ +0.5.17 - 04.04.2019 +-------------------------------------------------------------------------------- + +updated +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +#. `#68 `_: Raise IOError when + the data file does not exist + 0.5.16 - 19.03.2019 -------------------------------------------------------------------------------- diff --git a/changelog.yml b/changelog.yml index 2d0beae..472012f 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,12 @@ name: pyexcel-io organisation: pyexcel releases: +- changes: + - action: updated + details: + - '`#68`: Raise IOError when the data file does not exist' + version: 0.5.17 + date: 04.04.2019 - changes: - action: updated details: diff --git a/docs/source/conf.py b/docs/source/conf.py index 5db4019..5a4812c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -26,9 +26,9 @@ copyright = 'copyright 2015-2019 Onni Software Ltd.' author = 'Onni Software Ltd.' # The short X.Y version -version = '0.5.16' +version = '0.5.17' # The full version, including alpha/beta/rc tags -release = '0.5.16' +release = '0.5.17' # -- General configuration --------------------------------------------------- diff --git a/pyexcel-io.yml b/pyexcel-io.yml index 06d261a..151b9cf 100644 --- a/pyexcel-io.yml +++ b/pyexcel-io.yml @@ -2,10 +2,10 @@ overrides: "pyexcel.yaml" project: "pyexcel-io" name: pyexcel-io nick_name: io -version: 0.5.16 -current_version: 0.5.16 +version: 0.5.17 +current_version: 0.5.17 copyright_year: 2015-2019 -release: 0.5.16 +release: 0.5.17 dependencies: - ordereddict;python_version<"2.7" - lml>=0.0.4 diff --git a/pyexcel_io/io.py b/pyexcel_io/io.py index 4dd0e76..90af4ce 100644 --- a/pyexcel_io/io.py +++ b/pyexcel_io/io.py @@ -7,11 +7,13 @@ :copyright: (c) 2014-2017 by Onni Software Ltd. :license: New BSD License, see LICENSE for more details """ +import os from types import GeneratorType import warnings from pyexcel_io._compact import isstream, PY2 from pyexcel_io.plugins import READERS, WRITERS +from pyexcel_io.exceptions import NoSupportingPluginFound import pyexcel_io.constants as constants @@ -182,7 +184,15 @@ def load_data( except AttributeError: raise Exception("file_name should be a string type") - reader = READERS.get_a_plugin(file_type, library) + try: + reader = READERS.get_a_plugin(file_type, library) + except NoSupportingPluginFound: + if file_name: + if not os.path.exists(file_name): + raise IOError("%s does not exist" % file_name) + else: + raise + if file_name: reader.open(file_name, **keywords) elif file_content: diff --git a/setup.py b/setup.py index a52976b..9ce9243 100644 --- a/setup.py +++ b/setup.py @@ -29,15 +29,15 @@ NAME = 'pyexcel-io' AUTHOR = 'C.W.' -VERSION = '0.5.16' -EMAIL = 'wangc_2011@hotmail.com' +VERSION = '0.5.17' +EMAIL = 'info@pyexcel.org' LICENSE = 'New BSD' DESCRIPTION = ( 'A python library to read and write structured data in csv, zipped csv' + 'format and to/from databases' ) URL = 'https://github.com/pyexcel/pyexcel-io' -DOWNLOAD_URL = '%s/archive/0.5.16.tar.gz' % URL +DOWNLOAD_URL = '%s/archive/0.5.17.tar.gz' % URL FILES = ['README.rst', 'CHANGELOG.rst'] KEYWORDS = [ 'python', @@ -81,8 +81,8 @@ # You do not need to read beyond this line PUBLISH_COMMAND = '{0} setup.py sdist bdist_wheel upload -r pypi'.format( sys.executable) -GS_COMMAND = ('gs pyexcel-io v0.5.16 ' + - "Find 0.5.16 in changelog for more details") +GS_COMMAND = ('gs pyexcel-io v0.5.17 ' + + "Find 0.5.17 in changelog for more details") NO_GS_MESSAGE = ('Automatic github release is disabled. ' + 'Please install gease to enable it.') UPLOAD_FAILED_MSG = ( diff --git a/tests/test_io.py b/tests/test_io.py index 8670c18..39748cf 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -24,6 +24,11 @@ def test_force_file_type(): eq_(expected, data[test_file]) +@raises(IOError) +def test_invalid_file(): + load_data('/something/does/not/exist') + + @raises(IOError) def test_no_valid_parameters(): load_data() @@ -84,7 +89,7 @@ def test_write_xlsx_data_to_memory(): eq_(str(e), msg) -@raises(exceptions.NoSupportingPluginFound) +@raises(IOError) def test_load_unknown_data(): get_data("test.unknown") @@ -109,11 +114,6 @@ def test_write_xlsx_data(): get_data("test.xlsx") -@raises(exceptions.NoSupportingPluginFound) -def test_write_unknown_data(): - get_data("test.unknown") - - @raises(Exception) def test_writer_csvz_data_from_memory(): if not PY2: