Skip to content

Commit

Permalink
:wheel_chair: better error message. fix #68
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Apr 4, 2019
1 parent 935c8a0 commit 086aacf
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

sudo: false
dist: xenial
language: python
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Change log
================================================================================

0.5.17 - 04.04.2019
--------------------------------------------------------------------------------

updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#68 <https://github.com/pyexcel/pyexcel-io/issues/68>`_: Raise IOError when
the data file does not exist

0.5.16 - 19.03.2019
--------------------------------------------------------------------------------

Expand Down
6 changes: 6 additions & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions pyexcel-io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion pyexcel_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = (
Expand Down
12 changes: 6 additions & 6 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")

Expand All @@ -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:
Expand Down

0 comments on commit 086aacf

Please sign in to comment.