Skip to content

Commit

Permalink
Merge pull request #52 from pyexcel/dev
Browse files Browse the repository at this point in the history
Release 0.5.9
  • Loading branch information
chfw committed Aug 23, 2018
2 parents 59ac347 + 9a5a463 commit 317e170
Show file tree
Hide file tree
Showing 32 changed files with 653 additions and 701 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
Change log
================================================================================

0.5.9 - 23.08.2018
--------------------------------------------------------------------------------

added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `pyexcel#148 <https://github.com/pyexcel/pyexcel/issues/148>`_, support
force_file_type

0.5.8 - 16.08.2018
--------------------------------------------------------------------------------

fixed
added
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#49 <https://github.com/pyexcel/pyexcel-io/issues/49>`_, support additional
Expand Down
8 changes: 7 additions & 1 deletion changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ name: pyexcel-io
organisation: pyexcel
releases:
- changes:
- action: fixed
- action: added
details:
- '`pyexcel#148`, support force_file_type'
date: 23.08.2018
version: 0.5.9
- changes:
- action: added
details:
- '`#49`, support additional options when detecting float values in csv format. default_float_nan, ignore_nan_text'
date: 16.08.2018
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
author = u'C.W.'

# The short X.Y version
version = u'0.5.8'
version = u'0.5.9'
# The full version, including alpha/beta/rc tags
release = u'0.5.8'
release = u'0.5.9'


# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions pyexcel-io.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
overrides: "pyexcel.yaml"
name: "pyexcel-io"
nick_name: io
version: 0.5.8
current_version: 0.5.8
release: 0.5.8
version: 0.5.9
current_version: 0.5.9
release: 0.5.9
dependencies:
- ordereddict;python_version<"2.7"
- lml==0.0.1
Expand Down
4 changes: 3 additions & 1 deletion pyexcel_io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

BLACK_LIST = [__name__, "pyexcel_webio", "pyexcel_text"]
WHITE_LIST = [
"pyexcel_io.readers", "pyexcel_io.writers", "pyexcel_io.database"
"pyexcel_io.readers",
"pyexcel_io.writers",
"pyexcel_io.database",
]
PREFIX = "pyexcel_"

Expand Down
2 changes: 0 additions & 2 deletions pyexcel_io/_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
except ImportError:

class NullHandler(logging.Handler):

def emit(self, record):
pass

Expand All @@ -46,7 +45,6 @@ def emit(self, record):
irange = xrange

class Iterator(object):

def next(self):
return type(self).__next__(self)

Expand Down
1 change: 1 addition & 0 deletions pyexcel_io/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RWInterface(object):
"""
The common methods for book reader and writer
"""

stream_type = None

def __init__(self):
Expand Down
22 changes: 16 additions & 6 deletions pyexcel_io/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,21 @@
MESSAGE_ERROR_02 = "No content, file name. Nothing is given"
MESSAGE_ERROR_03 = "cannot handle unknown content"
MESSAGE_WRONG_IO_INSTANCE = "Wrong io instance is passed for your file format."
MESSAGE_CANNOT_WRITE_STREAM_FORMATTER = "Cannot write content of file type %s to stream"
MESSAGE_CANNOT_READ_STREAM_FORMATTER = "Cannot read content of file type %s from stream"
MESSAGE_CANNOT_WRITE_FILE_TYPE_FORMATTER = "Cannot write content of file type %s to file %s"
MESSAGE_CANNOT_READ_FILE_TYPE_FORMATTER = "Cannot read content of file type %s from file %s"
MESSAGE_LOADING_FORMATTER = "The plugin for file type %s is not installed. Please install %s"
MESSAGE_CANNOT_WRITE_STREAM_FORMATTER = (
"Cannot write content of file type %s to stream"
)
MESSAGE_CANNOT_READ_STREAM_FORMATTER = (
"Cannot read content of file type %s from stream"
)
MESSAGE_CANNOT_WRITE_FILE_TYPE_FORMATTER = (
"Cannot write content of file type %s to file %s"
)
MESSAGE_CANNOT_READ_FILE_TYPE_FORMATTER = (
"Cannot read content of file type %s from file %s"
)
MESSAGE_LOADING_FORMATTER = (
"The plugin for file type %s is not installed. Please install %s"
)
MESSAGE_EMPTY_ARRAY = "One empty row is found"
MESSAGE_IGNORE_ROW = "One row is ignored"
MESSAGE_DB_EXCEPTION = """
Expand All @@ -47,5 +57,5 @@
DEFAULT_MULTI_CSV_SEPARATOR = "__"
SEPARATOR_FORMATTER = "---%s---" % DEFAULT_NAME + "%s"
SEPARATOR_MATCHER = "---%s:(.*)---" % DEFAULT_NAME
DEFAULT_CSV_STREAM_FILE_FORMATTER = ("---%s:" % DEFAULT_NAME + "%s---%s")
DEFAULT_CSV_STREAM_FILE_FORMATTER = "---%s:" % DEFAULT_NAME + "%s---%s"
DEFAULT_CSV_NEWLINE = "\r\n"
3 changes: 1 addition & 2 deletions pyexcel_io/database/importers/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def create_sheet(self, sheet_name):
)
else:
raise Exception(
"Sheet: %s does not match any given models."
% sheet_name
"Sheet: %s does not match any given models." % sheet_name
+ "Please be aware of case sensitivity."
)

Expand Down
4 changes: 2 additions & 2 deletions pyexcel_io/database/importers/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PyexcelSQLSkipRowException(Exception):
Raised this exception to skipping a row
while data import
"""

pass


Expand Down Expand Up @@ -93,8 +94,7 @@ def create_sheet(self, sheet_name):
)
else:
raise Exception(
"Sheet: %s does not match any given tables."
% sheet_name
"Sheet: %s does not match any given tables." % sheet_name
+ "Please be aware of case sensitivity."
)

Expand Down
3 changes: 3 additions & 0 deletions pyexcel_io/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

class NoSupportingPluginFound(Exception):
"""raised when an known file extension is seen"""

pass


class SupportingPluginAvailableButNotInstalled(Exception):
"""raised when a known plugin is not installed"""

pass


class UpgradePlugin(Exception):
"""raised when a known plugin is not compatible"""

pass
16 changes: 12 additions & 4 deletions pyexcel_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def iget_data(afile, file_type=None, **keywords):
:param sheet_index: the index of the sheet to be loaded
:param sheets: a list of sheet to be loaded
:param file_type: used only when filename is not a physial file name
:param force_file_type: used only when filename refers to a physical file
and it is intended to open it as forced file type.
:param streaming: toggles the type of returned data. The values of the
returned dictionary remain as generator if it is set
to True. Default is False.
Expand Down Expand Up @@ -147,6 +149,7 @@ def load_data(
file_content=None,
file_stream=None,
file_type=None,
force_file_type=None,
sheet_name=None,
sheet_index=None,
sheets=None,
Expand All @@ -158,6 +161,8 @@ def load_data(
:param filename: actual file name, a file stream or actual content
:param file_type: used only when filename is not a physial file name
:param force_file_type: used only when filename refers to a physical file
and it is intended to open it as forced file type.
:param sheet_name: the name of the sheet to be loaded
:param sheet_index: the index of the sheet to be loaded
:param keywords: any other parameters
Expand All @@ -169,10 +174,13 @@ def load_data(
raise IOError(constants.MESSAGE_ERROR_02)

if file_type is None:
try:
file_type = file_name.split(".")[-1]
except AttributeError:
raise Exception("file_name should be a string type")
if force_file_type:
file_type = force_file_type
else:
try:
file_type = file_name.split(".")[-1]
except AttributeError:
raise Exception("file_name should be a string type")

reader = READERS.get_a_plugin(file_type, library)
if file_name:
Expand Down
4 changes: 3 additions & 1 deletion pyexcel_io/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def raise_exception(self, file_type):
message = "Please install "
if len(plugins) > 1:
message += ERROR_MESSAGE_FORMATTER % (
self.action, file_type, ",".join(plugins)
self.action,
file_type,
",".join(plugins),
)
else:
message += plugins[0]
Expand Down
12 changes: 6 additions & 6 deletions pyexcel_io/readers/csvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __next__(self):
if bom_header == BOM_BIG_ENDIAN:
self.__endian = BIG_ENDIAN
elif self.__endian == LITTLE_ENDIAN:
line = line[self.__zeros_left_in_2_row:]
line = line[self.__zeros_left_in_2_row :] # flake8: noqa
if self.__endian == LITTLE_ENDIAN:
line = line.rstrip()
line = line.decode(self.__encoding)
Expand Down Expand Up @@ -168,14 +168,14 @@ def __convert_cell(self, csv_cell_text):
ret = service.detect_int_value(csv_cell_text, self.__pep_0515_off)
if ret is None and self.__auto_detect_float:
ret = service.detect_float_value(
csv_cell_text, self.__pep_0515_off,
csv_cell_text,
self.__pep_0515_off,
ignore_nan_text=self.__ignore_nan_text,
default_float_nan=self.__default_float_nan
default_float_nan=self.__default_float_nan,
)
shall_we_ignore_the_conversion = (
(ret in [float("inf"), float("-inf")])
and self.__ignore_infinity
)
ret in [float("inf"), float("-inf")]
) and self.__ignore_infinity
if shall_we_ignore_the_conversion:
ret = None
if ret is None and self.__auto_detect_datetime:
Expand Down
5 changes: 2 additions & 3 deletions pyexcel_io/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ def detect_date_value(cell_text):


def detect_float_value(
cell_text, pep_0515_off=True,
ignore_nan_text=False,
default_float_nan=None):
cell_text, pep_0515_off=True, ignore_nan_text=False, default_float_nan=None
):
should_we_skip_it = (
cell_text.startswith("0") and cell_text.startswith("0.") is False
)
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

NAME = 'pyexcel-io'
AUTHOR = 'C.W.'
VERSION = '0.5.8'
VERSION = '0.5.9'
EMAIL = 'wangc_2011@hotmail.com'
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.8.tar.gz' % URL
DOWNLOAD_URL = '%s/archive/0.5.9.tar.gz' % URL
FILES = ['README.rst', 'CHANGELOG.rst']
KEYWORDS = [
'API',
Expand Down Expand Up @@ -63,8 +63,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.8 ' +
"Find 0.5.8 in changelog for more details")
GS_COMMAND = ('gs pyexcel-io v0.5.9 ' +
"Find 0.5.9 in changelog for more details")
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
'Please install gease to enable it.')
UPLOAD_FAILED_MSG = (
Expand Down
2 changes: 1 addition & 1 deletion test.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip freeze
nosetests --with-coverage --cover-package pyexcel_io --cover-package tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_io && flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
nosetests --with-coverage --cover-package pyexcel_io --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_io && flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip freeze
nosetests --with-coverage --cover-package pyexcel_io --cover-package tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_io && flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
nosetests --with-coverage --cover-package pyexcel_io --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_io && flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
1 change: 1 addition & 0 deletions tests/fixtures/force_file_type.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,2,3
21 changes: 5 additions & 16 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from pyexcel_io.sheet import (
SheetReader, SheetWriter, NamedContent
)
from pyexcel_io.sheet import SheetReader, SheetWriter, NamedContent
from pyexcel_io.book import BookWriter
from pyexcel_io.utils import is_empty_array
from nose.tools import raises
Expand Down Expand Up @@ -28,7 +26,6 @@ def write_row(self, array):


class TestSheetReader:

@raises(Exception)
def test_abstractness(self):
reader = SheetReader("test")
Expand All @@ -54,13 +51,13 @@ def name(self):

def to_array(self):
pass

b = B(name)
b.to_array()
assert b.name == name


class TestSheetWriter:

@raises(NotImplementedError)
def test_abstractness(self):
writer = SheetWriter("te", "st", "abstract")
Expand All @@ -71,28 +68,20 @@ class D(SheetWriter):
def write_row(self, row):
pass

d = D('t', 'e', 's')
d = D("t", "e", "s")
d.write_row([11, 11])

def test_writer(self):
native_sheet = NamedContent("test", [])
content = [
[1, 2],
[3, 4],
[5, 6]
]
content = [[1, 2], [3, 4], [5, 6]]
writer = ArrayWriter(None, native_sheet, "test")
writer.write_row(content[0])
writer.write_array(content[1:])
assert native_sheet.payload == content

def test_writer2(self):
native_sheet = NamedContent("test", [])
content = [
[1, 2],
[3, 4],
[5, 6]
]
content = [[1, 2], [3, 4], [5, 6]]
writer = ArrayWriter(None, native_sheet, None)
writer.write_row(content[0])
writer.write_array(content[1:])
Expand Down

0 comments on commit 317e170

Please sign in to comment.