🤝 merge with 0.5.11
This commit is contained in:
commit
e0c7fedc04
|
@ -1,6 +1,27 @@
|
|||
Change log
|
||||
================================================================================
|
||||
|
||||
0.5.10 - 3.12.2018
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
updated
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
#. `#59 <https://github.com/pyexcel/pyexcel-io/issues/59>`_: Please use
|
||||
scan_plugins_regex, which lml 0.7 complains about
|
||||
|
||||
0.5.10 - 27.11.2018
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
added
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
#. `#57 <https://github.com/pyexcel/pyexcel-io/issues/57>`_, long type will not
|
||||
be written in ods. please use string type. And if the integer is equal or
|
||||
greater than 10 to the power of 16, it will not be written either in ods. In
|
||||
both situation, IntegerPrecisionLossError will be raised. And this version
|
||||
enables pyexcel-ods and pyexcel-ods3 to do so.
|
||||
|
||||
0.5.9.1 - 30.08.2018
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ Acceptance criteria
|
|||
#. Has all code lines tested
|
||||
#. Passes all Travis CI builds
|
||||
#. Has fair amount of documentation if your change is complex
|
||||
#. run 'make format' so as to confirm the pyexcel organisation's coding style
|
||||
#. Please update CHANGELOG.rst
|
||||
#. Please add yourself to CONTRIBUTORS.rst
|
||||
#. Agree on NEW BSD License for your contribution
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
name: pyexcel-io
|
||||
organisation: pyexcel
|
||||
releases:
|
||||
- changes:
|
||||
- action: updated
|
||||
details:
|
||||
- '`#59`: Please use scan_plugins_regex, which lml 0.7 complains about'
|
||||
version: 0.5.11
|
||||
date: 3.12.2018
|
||||
- changes:
|
||||
- action: added
|
||||
details:
|
||||
- '`#57`, long type will not be written in ods. please use string type. And if the integer is equal or greater than 10 to the power of 16, it will not be written either in ods. In both situation, IntegerPrecisionLossError will be raised. And this version enables pyexcel-ods and pyexcel-ods3 to do so.'
|
||||
date: 27.11.2018
|
||||
version: 0.5.10
|
||||
- changes:
|
||||
- action: updated
|
||||
details:
|
||||
|
|
|
@ -29,7 +29,7 @@ copyright = u'2015-2018 Onni Software Ltd.'
|
|||
author = u'C.W.'
|
||||
|
||||
# The short X.Y version
|
||||
version = u'0.5.9.1'
|
||||
version = u'0.5.11'
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = u'0.6.0'
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ name: "pyexcel-io"
|
|||
nick_name: io
|
||||
version: 0.6.0
|
||||
current_version: 0.6.0
|
||||
release: 0.5.9.1
|
||||
release: 0.5.11
|
||||
dependencies:
|
||||
- ordereddict;python_version<"2.7"
|
||||
- lml>=0.0.2
|
||||
- lml>=0.0.4
|
||||
extra_dependencies:
|
||||
- xls:
|
||||
- pyexcel-xls>=0.5.0
|
||||
|
|
|
@ -22,6 +22,10 @@ WHITE_LIST = [
|
|||
"pyexcel_io.writers",
|
||||
"pyexcel_io.database",
|
||||
]
|
||||
PREFIX = "pyexcel_"
|
||||
PREFIX_PATTERN = "^pyexcel_.*$"
|
||||
|
||||
plugins.load_plugins(PREFIX, __path__, BLACK_LIST, WHITE_LIST)
|
||||
plugins.load_plugins(
|
||||
PREFIX_PATTERN,
|
||||
__path__, # noqa: F821
|
||||
BLACK_LIST,
|
||||
WHITE_LIST)
|
||||
|
|
|
@ -59,3 +59,5 @@ SEPARATOR_FORMATTER = "---%s---" % DEFAULT_NAME + "%s"
|
|||
SEPARATOR_MATCHER = "---%s:(.*)---" % DEFAULT_NAME
|
||||
DEFAULT_CSV_STREAM_FILE_FORMATTER = "---%s:" % DEFAULT_NAME + "%s---%s"
|
||||
DEFAULT_CSV_NEWLINE = "\r\n"
|
||||
|
||||
MAX_INTEGER = 999999999999999
|
||||
|
|
|
@ -25,3 +25,32 @@ 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.
|
||||
|
||||
from pyexcel import Sheet, get_sheet
|
||||
s = Sheet()
|
||||
s[0,0] = 999999999999999 # 15 '9's
|
||||
print(s)
|
||||
s.save_as('abc.ods')
|
||||
b=get_sheet(file_name='abc.ods')
|
||||
b[0,0] == s[0,0]
|
||||
|
||||
s = Sheet()
|
||||
s[0,0] = 9999999999999999 # 16 '9's
|
||||
print(s)
|
||||
s.save_as('abc.ods')
|
||||
b=get_sheet(file_name='abc.ods')
|
||||
b[0,0] != s[0,0]
|
||||
"""
|
||||
def __init__(self, message):
|
||||
custom_message = (
|
||||
message + '\n' +
|
||||
"In order to keep its accuracy, please save as string. Then " +
|
||||
"convert to int, long or float after the value will be read back"
|
||||
)
|
||||
|
||||
super(IntegerAccuracyLossError, self).__init__(custom_message)
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
:copyright: (c) 2014-2017 by Onni Software Ltd.
|
||||
:license: New BSD License, see LICENSE for more details
|
||||
"""
|
||||
from lml.loader import scan_plugins
|
||||
from lml.plugin import PluginInfo, PluginManager, PluginInfoChain
|
||||
from lml.loader import scan_plugins_regex
|
||||
from lml.plugin import PluginManager
|
||||
from lml.plugin import PluginInfoChain, PluginInfo
|
||||
|
||||
import pyexcel_io.utils as ioutils
|
||||
import pyexcel_io.manager as manager
|
||||
|
@ -130,8 +131,11 @@ READERS = IOManager(READER_PLUGIN, ioutils.AVAILABLE_READERS)
|
|||
WRITERS = IOManager(WRITER_PLUGIN, ioutils.AVAILABLE_WRITERS)
|
||||
|
||||
|
||||
def load_plugins(prefix, path, black_list, white_list):
|
||||
def load_plugins(plugin_name_patterns, path, black_list, white_list):
|
||||
"""Try to discover all pyexcel-io plugins"""
|
||||
scan_plugins(
|
||||
prefix, path, black_list, white_list # constants.DEFAULT_PLUGIN_NAME,
|
||||
scan_plugins_regex(
|
||||
plugin_name_patterns=plugin_name_patterns,
|
||||
pyinstaller_path=path,
|
||||
black_list=black_list,
|
||||
white_list=white_list
|
||||
)
|
||||
|
|
|
@ -12,6 +12,8 @@ import math
|
|||
import datetime
|
||||
|
||||
from pyexcel_io._compact import PY2
|
||||
from pyexcel_io import constants
|
||||
from pyexcel_io import exceptions
|
||||
|
||||
|
||||
def has_no_digits_in_float(value):
|
||||
|
@ -177,7 +179,9 @@ ODS_WRITE_FORMAT_COVERSION = {
|
|||
}
|
||||
|
||||
if PY2:
|
||||
ODS_WRITE_FORMAT_COVERSION[unicode] = "string"
|
||||
ODS_WRITE_FORMAT_COVERSION[unicode] = "string" # noqa: F821
|
||||
ODS_WRITE_FORMAT_COVERSION[long] = "throw_exception" # noqa: F821
|
||||
|
||||
|
||||
VALUE_CONVERTERS = {
|
||||
"float": float_value,
|
||||
|
@ -189,6 +193,16 @@ VALUE_CONVERTERS = {
|
|||
}
|
||||
|
||||
|
||||
def throw_exception(value):
|
||||
raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
|
||||
|
||||
|
||||
def ods_float_value(value):
|
||||
if value > constants.MAX_INTEGER:
|
||||
raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
|
||||
return value
|
||||
|
||||
|
||||
def ods_date_value(value):
|
||||
return value.strftime("%Y-%m-%d")
|
||||
|
||||
|
@ -219,6 +233,8 @@ ODS_VALUE_CONVERTERS = {
|
|||
"time": ods_time_value,
|
||||
"boolean": ods_bool_value,
|
||||
"timedelta": ods_timedelta_value,
|
||||
"float": ods_float_value,
|
||||
"throw_exception": throw_exception
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
ordereddict;python_version<"2.7"
|
||||
lml>=0.0.2
|
||||
lml>=0.0.4
|
||||
|
|
8
setup.py
8
setup.py
|
@ -21,7 +21,7 @@ DESCRIPTION = (
|
|||
'format and to/from databases'
|
||||
)
|
||||
URL = 'https://github.com/pyexcel/pyexcel-io'
|
||||
DOWNLOAD_URL = '%s/archive/0.5.9.1.tar.gz' % URL
|
||||
DOWNLOAD_URL = '%s/archive/0.5.11.tar.gz' % URL
|
||||
FILES = ['README.rst', 'CHANGELOG.rst']
|
||||
KEYWORDS = [
|
||||
'python',
|
||||
|
@ -49,7 +49,7 @@ CLASSIFIERS = [
|
|||
]
|
||||
|
||||
INSTALL_REQUIRES = [
|
||||
'lml>=0.0.2',
|
||||
'lml>=0.0.4',
|
||||
]
|
||||
SETUP_COMMANDS = {}
|
||||
|
||||
|
@ -65,8 +65,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.9.1 ' +
|
||||
"Find 0.5.9.1 in changelog for more details")
|
||||
GS_COMMAND = ('gs pyexcel-io v0.5.11 ' +
|
||||
"Find 0.5.11 in changelog for more details")
|
||||
NO_GS_MESSAGE = ('Automatic github release is disabled. ' +
|
||||
'Please install gease to enable it.')
|
||||
UPLOAD_FAILED_MSG = (
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
from nose.tools import eq_, raises
|
||||
from pyexcel_io.service import (
|
||||
date_value,
|
||||
time_value,
|
||||
detect_int_value,
|
||||
detect_float_value,
|
||||
)
|
||||
from pyexcel_io.service import date_value, time_value
|
||||
from pyexcel_io.service import detect_int_value
|
||||
from pyexcel_io.service import detect_float_value
|
||||
from pyexcel_io.service import ODS_WRITE_FORMAT_COVERSION
|
||||
from pyexcel_io.service import ods_float_value
|
||||
from pyexcel_io.service import throw_exception
|
||||
from pyexcel_io._compact import PY2
|
||||
from pyexcel_io.exceptions import IntegerAccuracyLossError
|
||||
from nose import SkipTest
|
||||
|
||||
|
||||
def test_date_util_parse():
|
||||
|
@ -92,3 +95,21 @@ def test_detect_float_value_on_custom_nan_text():
|
|||
def test_detect_float_value_on_custom_nan_text2():
|
||||
result = detect_float_value("nan", default_float_nan="nan")
|
||||
eq_(str(result), "nan")
|
||||
|
||||
|
||||
def test_ods_write_format_conversion():
|
||||
if PY2:
|
||||
expected = ODS_WRITE_FORMAT_COVERSION[long] # noqa: F821
|
||||
eq_('throw_exception', expected)
|
||||
else:
|
||||
raise SkipTest()
|
||||
|
||||
|
||||
@raises(IntegerAccuracyLossError)
|
||||
def test_big_int_value():
|
||||
ods_float_value(1000000000000000)
|
||||
|
||||
|
||||
@raises(IntegerAccuracyLossError)
|
||||
def test_throw_exception():
|
||||
throw_exception(1000000000000000)
|
||||
|
|
Loading…
Reference in New Issue