8000 :handshake: merge with 0.5.11 · pyexcel/pyexcel-io@e0c7fed · GitHub
[go: up one dir, main page]

Skip to content

Commit e0c7fed

Browse files
committed
🤝 merge with 0.5.11
2 parents 43a5a56 + 02f2e6d commit e0c7fed

File tree

13 files changed

+132
-22
lines changed

13 files changed

+132
-22
lines changed

CHANGELOG.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Change log
22
================================================================================
33

4+
0.5.10 - 3.12.2018
5+
--------------------------------------------------------------------------------
6+
7+
updated
8+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9+
10+
#. `#59 <https://github.com/pyexcel/pyexcel-io/issues/59>`_: Please use
11+
scan_plugins_regex, which lml 0.7 complains about
12+
13+
0.5.10 - 27.11.2018
14+
--------------------------------------------------------------------------------
15+
16+
added
17+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
19+
#. `#57 <https://github.com/pyexcel/pyexcel-io/issues/57>`_, long type will not
20+
be written in ods. please use string type. And if the integer is equal or
21+
greater than 10 to the power of 16, it will not be written either in ods. In
22+
both situation, IntegerPrecisionLossError will be raised. And this version
23+
enables pyexcel-ods and pyexcel-ods3 to do so.
24+
425
0.5.9.1 - 30.08.2018
526
--------------------------------------------------------------------------------
627

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ Acceptance criteria
211211
#. Has all code lines tested
212212
#. Passes all Travis CI builds
213213
#. Has fair amount of documenta 10000 tion if your change is complex
214+
#. run 'make format' so as to confirm the pyexcel organisation's coding style
214215
#. Please update CHANGELOG.rst
215216
#. Please add yourself to CONTRIBUTORS.rst
216217
#. Agree on NEW BSD License for your contribution

changelog.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
name: pyexcel-io
22
organisation: pyexcel
33
releases:
4+
- changes:
5+
- action: updated
6+
details:
7+
- '`#59`: Please use scan_plugins_regex, which lml 0.7 complains about'
8+
version: 0.5.11
9+
date: 3.12.2018
10+
- changes:
11+
- action: added
12+
details:
13+
- '`#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.'
14+
date: 27.11.2018
15+
version: 0.5.10
416
- changes:
517
- action: updated
618
details:

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
author = u'C.W.'
3030

3131
# The short X.Y version
32-
version = u'0.5.9.1'
32+
version = u'0.5.11'
3333
# The full version, including alpha/beta/rc tags
3434
release = u'0.6.0'
3535

pyexcel-io.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: "pyexcel-io"
33
nick_name: io
44
version: 0.6.0
55
current_version: 0.6.0
6-
release: 0.5.9.1
6+
release: 0.5.11
77
dependencies:
88
- ordereddict;python_version<"2.7"
9-
- lml>=0.0.2
9+
- lml>=0.0.4
1010
extra_dependencies:
1111
- xls:
1212
- pyexcel-xls>=0.5.0

pyexcel_io/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"pyexcel_io.writers",
2323
"pyexcel_io.database",
2424
]
25-
PREFIX = "pyexcel_"
25+
PREFIX_PATTERN = "^pyexcel_.*$"
2626

27-
plugins.load_plugins(PREFIX, __path__, BLACK_LIST, WHITE_LIST)
27+
plugins.load_plugins(
28+
PREFIX_PATTERN,
29+
__path__, # noqa: F821
30+
BLACK_LIST,
31+
WHITE_LIST)

pyexcel_io/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@
5959
SEPARATOR_MATCHER = "---%s:(.*)---" % DEFAULT_NAME
6060
DEFAULT_CSV_STREAM_FILE_FORMATTER = "---%s:" % DEFAULT_NAME + "%s---%s"
6161
DEFAULT_CSV_NEWLINE = "\r\n"
62+
63+
MAX_INTEGER = 999999999999999

pyexcel_io/exceptions.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,32 @@ class UpgradePlugin(Exception):
2525
"""raised when a known plugin is not compatible"""
2626

2727
pass
28+
29+
30+
class IntegerAccuracyLossError(Exception):
31+
"""
32+
When an interger is greater than 999999999999999, ods loses its accuracy.
33+
34+
from pyexcel import Sheet, get_sheet
35+
s = Sheet()
36+
s[0,0] = 999999999999999 # 15 '9's
37+
print(s)
38+
s.save_as('abc.ods')
39+
b=get_sheet(file_name='abc.ods')
40+
b[0,0] == s[0,0]
41+
42+
s = Sheet()
43+
s[0,0] = 9999999999999999 # 16 '9's
44+
print(s)
45+
s.save_as('abc.ods')
46+
b=get_sheet(file_name='abc.ods')
47+
b[0,0] != s[0,0]
48+
"""
49+
def __init__(self, message):
50+
custom_message = (
51+
message + '\n' +
52+
"In order to keep its accuracy, please save as string. Then " +
53+
"convert to int, long or float after the value will be read back"
54+
)
55+
56+
super(IntegerAccuracyLossError, self).__init__(custom_message)

pyexcel_io/plugins.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
:copyright: (c) 2014-2017 by Onni Software Ltd.
88
:license: New BSD License, see LICENSE for more details
99
"""
10-
from lml.loader import scan_plugins
11-
from lml.plugin import PluginInfo, PluginManager, PluginInfoChain
10+
from lml.loader import scan_plugins_regex
11+
from lml.plugin import PluginManager
12+
from lml.plugin import PluginInfoChain, PluginInfo
1213

1314
import pyexcel_io.utils as ioutils
1415
import pyexcel_io.manager as manager
@@ -130,8 +131,11 @@ def _do_additional_registration(plugin_info):
130131
WRITERS = IOManager(WRITER_PLUGIN, ioutils.AVAILABLE_WRITERS)
131132

132133

133-
def load_plugins(prefix, path, black_list, white_list):
134+
def load_plugins(plugin_name_patterns, path, black_list, white_list):
134135
"""Try to discover all pyexcel-io plugins"""
135-
scan_plugins(
136-
prefix, path, black_list, white_list # constants.DEFAULT_PLUGIN_NAME,
136+
scan_plugins_regex(
137+
plugin_name_patterns=plugin_name_patterns,
138+
pyinstaller_path=path,
139+
black_list=black_list,
140+
white_list=white_list
137141
)

pyexcel_io/service.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import datetime
1313

1414
from pyexcel_io._compact import PY2
15+
from pyexcel_io import constants
16+
from pyexcel_io import exceptions
1517

1618

1719
def has_no_digits_in_float(value):
@@ -177,7 +179,9 @@ def boolean_value(value):
177179
}
178180

179181
if PY2:
180-
ODS_WRITE_FORMAT_COVERSION[unicode] = "string"
182+
ODS_WRITE_FORMAT_COVERSION[unicode] = "string" # noqa: F821
183+
ODS_WRITE_FORMAT_COVERSION[long] = "throw_exception" # noqa: F821
184+
181185

182186
VALUE_CONVERTERS = {
183187
"float": float_value,
@@ -189,6 +193,16 @@ def boolean_value(value):
189193
}
190194

191195

196+
def throw_exception(value):
197+
raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
198+
199+
200+
def ods_float_value(value):
201+
if value > constants.MAX_INTEGER:
202+
raise exceptions.IntegerAccuracyLossError("%s is too big" % value)
203+
return value
204+
205+
192206
def ods_date_value(value):
193207
return value.strftime("%Y-%m-%d")
194208

@@ -219,6 +233,8 @@ def ods_timedelta_value(cell):
219233
"time": ods_time_value,
220234
"boolean": ods_bool_value,
221235
"timedelta": ods_timedelta_value,
236+
"float": ods_float_value,
237+
"throw_exception": throw_exception
222238
}
223239

224240

0 commit comments

Comments
 (0)
0