Issue 96 (#97)
* 🐛 regression: unknown file type shall trigger NoSupportingPluginFound. fix #96 * This is an auto-commit, updating project meta data, such as changelog.rst, contributors.rst * 💚 update coding style. #96 * 🔬 more test coverage Co-authored-by: chfw <chfw@users.noreply.github.com>
This commit is contained in:
parent
b77fc8125c
commit
71c28b4bc9
|
@ -1,6 +1,14 @@
|
|||
Change log
|
||||
================================================================================
|
||||
|
||||
0.6.3 - tbd
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
**updated**
|
||||
|
||||
#. `#96 <https://github.com/pyexcel/pyexcel-io/issues/96>`_: regression: unknown
|
||||
file type shall trigger NoSupportingPluginFound
|
||||
|
||||
0.6.2 - 7.10.2020
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
name: pyexcel-io
|
||||
organisation: pyexcel
|
||||
releases:
|
||||
- changes:
|
||||
- action: updated
|
||||
details:
|
||||
- "`#96`: regression: unknown file type shall trigger NoSupportingPluginFound"
|
||||
version: 0.6.3
|
||||
date: tbd
|
||||
- changes:
|
||||
- action: updated
|
||||
details:
|
||||
|
|
|
@ -21,12 +21,6 @@ class SupportingPluginAvailableButNotInstalled(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class UpgradePlugin(Exception):
|
||||
"""raised when a known plugin is not compatible"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class IntegerAccuracyLossError(Exception):
|
||||
"""
|
||||
When an interger is greater than 999999999999999, ods loses its accuracy.
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from pyexcel_io import exceptions
|
||||
from pyexcel_io.book import _convert_content_to_stream
|
||||
from pyexcel_io.sheet import SheetReader
|
||||
from pyexcel_io.plugins import NEW_READERS
|
||||
from pyexcel_io._compact import OrderedDict
|
||||
|
@ -53,23 +51,14 @@ class Reader(object):
|
|||
|
||||
def open_content(self, file_content, **keywords):
|
||||
self.keywords, native_sheet_keywords = clean_keywords(keywords)
|
||||
try:
|
||||
if self.reader_class is None:
|
||||
self.reader_class = NEW_READERS.get_a_plugin(
|
||||
self.file_type, location="content", library=self.library
|
||||
)
|
||||
self.reader = self.reader_class(
|
||||
file_content, self.file_type, **native_sheet_keywords
|
||||
if self.reader_class is None:
|
||||
self.reader_class = NEW_READERS.get_a_plugin(
|
||||
self.file_type, location="content", library=self.library
|
||||
)
|
||||
return self.reader
|
||||
except (
|
||||
exceptions.NoSupportingPluginFound,
|
||||
exceptions.SupportingPluginAvailableButNotInstalled,
|
||||
):
|
||||
file_stream = _convert_content_to_stream(
|
||||
file_content, self.file_type
|
||||
)
|
||||
return self.open_stream(file_stream, **native_sheet_keywords)
|
||||
self.reader = self.reader_class(
|
||||
file_content, self.file_type, **native_sheet_keywords
|
||||
)
|
||||
return self.reader
|
||||
|
||||
def open_stream(self, file_stream, **keywords):
|
||||
self.keywords, native_sheet_keywords = clean_keywords(keywords)
|
||||
|
|
|
@ -29,4 +29,9 @@ IOPluginInfoChainV2(__name__).add_a_reader(
|
|||
file_types=["csvz", "tsvz"],
|
||||
locations=["file", "memory"],
|
||||
stream_type="binary",
|
||||
).add_a_reader(
|
||||
relative_plugin_class_path="csvz.ContentReader",
|
||||
file_types=["csvz", "tsvz"],
|
||||
locations=["content"],
|
||||
stream_type="binary",
|
||||
)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
:license: New BSD License, see LICENSE for more details
|
||||
"""
|
||||
import zipfile
|
||||
from io import BytesIO
|
||||
|
||||
import chardet
|
||||
from pyexcel_io import constants
|
||||
|
@ -48,6 +49,12 @@ class FileReader(IReader):
|
|||
return CSVinMemoryReader(NamedContent(name, sheet), **self.keywords)
|
||||
|
||||
|
||||
class ContentReader(FileReader):
|
||||
def __init__(self, file_content, file_type, **keywords):
|
||||
io = BytesIO(file_content)
|
||||
super().__init__(io, file_type, **keywords)
|
||||
|
||||
|
||||
def _get_sheet_name(filename):
|
||||
len_of_a_dot = 1
|
||||
len_of_csv_word = 3
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
import pyexcel as p
|
||||
from pyexcel_io import get_data, save_data
|
||||
from pyexcel_io.exceptions import NoSupportingPluginFound
|
||||
|
||||
from nose import SkipTest
|
||||
from nose.tools import eq_
|
||||
from nose.tools import eq_, raises
|
||||
|
||||
IN_TRAVIS = "TRAVIS" in os.environ
|
||||
|
||||
|
@ -41,17 +39,6 @@ def test_issue_23():
|
|||
eq_(data["issue23.csv"], expected)
|
||||
|
||||
|
||||
# def test_issue_28():
|
||||
# from pyexcel_io.plugins import readers
|
||||
# from pyexcel_io.exceptions import UpgradePlugin
|
||||
# expected = "Please upgrade the plugin '%s' according to "
|
||||
# expected += "plugin compactibility table."
|
||||
# try:
|
||||
# readers.load_me_later('pyexcel_test')
|
||||
# except UpgradePlugin as e:
|
||||
# eq_(str(e), expected % 'pyexcel_test')
|
||||
|
||||
|
||||
def test_issue_33_34():
|
||||
import mmap
|
||||
|
||||
|
@ -154,5 +141,10 @@ def test_pyexcel_issue_138():
|
|||
os.unlink("test.csv")
|
||||
|
||||
|
||||
@raises(NoSupportingPluginFound)
|
||||
def test_issue_96():
|
||||
get_data("foo-bar-data", file_type="Idonotexist")
|
||||
|
||||
|
||||
def get_fixture(file_name):
|
||||
return os.path.join("tests", "fixtures", file_name)
|
||||
|
|
|
@ -3,6 +3,7 @@ from datetime import time, datetime, timedelta
|
|||
from pyexcel_io.service import (
|
||||
date_value,
|
||||
time_value,
|
||||
float_value,
|
||||
boolean_value,
|
||||
ods_bool_value,
|
||||
ods_date_value,
|
||||
|
@ -162,3 +163,8 @@ def test_time_value():
|
|||
test_time_value = "PT23H00M01S"
|
||||
delta = time_value(test_time_value)
|
||||
eq_(delta, time(23, 0, 1))
|
||||
|
||||
|
||||
def test_float_value():
|
||||
a = float_value("1.2")
|
||||
eq_(a, 1.2)
|
||||
|
|
Loading…
Reference in New Issue