:wheel_chair: better error message. fix #68

This commit is contained in:
chfw 2019-04-04 21:26:36 +01:00
parent 935c8a05b6
commit 086aacff85
8 changed files with 43 additions and 17 deletions

View File

@ -1,3 +1,4 @@
sudo: false
dist: xenial
language: python

View File

@ -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
--------------------------------------------------------------------------------

View File

@ -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:

View File

@ -26,9 +26,9 @@ project = 'pyexcel-io'
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 ---------------------------------------------------

View File

@ -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

View File

@ -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:

View File

@ -29,15 +29,15 @@ except (ValueError, UnicodeError, locale.Error):
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 @@ EXTRAS_REQUIRE = {
# 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 = (

View File

@ -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: