Skip to content

Commit

Permalink
🤝 merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Jul 15, 2019
2 parents ec62f38 + c21d36f commit 3408497
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 74 deletions.
19 changes: 13 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

sudo: false
dist: xenial
language: python
Expand All @@ -18,32 +17,40 @@ stages:
- lint

.disable_global: &disable_global
addons: false
cache: false
env: {}
python: false
before_install: false
install: true
install: false
before_script: false
script: false
after_success: false
after_failure: false
before_deploy: false
deploy: false

.lint: &lint
<<: *disable_global
git:
submodules: false
python: 3.6
stage: lint
install: pip install flake8
script: make lint

jobs:
include:
- *moban
- *lint

stage: test

script: make test

before_install:
- if [[ -f min_requirements.txt && "$MINREQ" -eq 1 ]]; then
mv min_requirements.txt requirements.txt ;
fi
- test ! -f rnd_requirements.txt || pip install --no-deps -r rnd_requirements.txt
- test ! -f rnd_requirements.txt ||
pip install --no-deps -r rnd_requirements.txt
- test ! -f rnd_requirements.txt || pip install -r rnd_requirements.txt ;
- pip install -r tests/requirements.txt
script:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Change log
================================================================================

0.5.19 - 14.7.2019
--------------------------------------------------------------------------------

updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `pyexcel#185 <https://github.com/pyexcel/pyexcel/issues/185>`_: handle stream
conversion if file type(html) needs string content then bytes to handle

0.5.18 - 12.06.2019
--------------------------------------------------------------------------------

updated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#. `#69 <https://github.com/pyexcel/pyexcel-io/issues/69>`_: Force file
type(force_file_type) on write

0.5.17 - 04.04.2019
--------------------------------------------------------------------------------

Expand Down
12 changes: 12 additions & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
name: pyexcel-io
organisation: pyexcel
releases:
- changes:
- action: updated
details:
- '`pyexcel#185`: handle stream conversion if file type(html) needs string content then bytes to handle'
version: 0.5.19
date: 14.7.2019
- changes:
- action: updated
details:
- '`#69`: Force file type(force_file_type) on write'
version: 0.5.18
date: 12.06.2019
- changes:
- action: updated
details:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# The short X.Y version
version = '0.6.0'
# The full version, including alpha/beta/rc tags
release = '0.5.17'
release = '0.5.19'

# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -69,4 +69,4 @@
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'https://docs.python.org/': None}
1 change: 1 addition & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pip install flake8
flake8 . --exclude=.moban.d,docs --builtins=unicode,xrange,long
3 changes: 2 additions & 1 deletion pyexcel-io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ name: pyexcel-io
nick_name: io
version: 0.6.0
current_version: 0.6.0
release: 0.5.19
copyright_year: 2015-2019
release: 0.5.17
moban_command: false
dependencies:
- ordereddict;python_version<"2.7"
- lml>=0.0.4
Expand Down
10 changes: 10 additions & 0 deletions pyexcel_io/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ def create_sheet(self, sheet_name):

def _convert_content_to_stream(file_content, file_type):
stream = manager.get_io(file_type)
if not PY2:
target_content_type = manager.get_io_type(file_type)
needs_encode = (target_content_type == 'bytes' and
not isinstance(file_content, bytes))
needs_decode = (target_content_type == 'string' and
isinstance(file_content, bytes))
if needs_encode:
file_content = file_content.encode('utf-8')
elif needs_decode:
file_content = file_content.decode('utf-8')
stream.write(file_content)
stream.seek(0)
return stream
21 changes: 14 additions & 7 deletions pyexcel_io/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
The io interface to file extensions
:copyright: (c) 2014-2017 by Onni Software Ltd.
:copyright: (c) 2014-2019 by Onni Software Ltd.
:license: New BSD License, see LICENSE for more details
"""
import os
Expand All @@ -24,7 +24,7 @@ def iget_data(afile, file_type=None, **keywords):
:param sheet_name: the name of the sheet to be loaded
: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 file_type: used only when filename is not a physical 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
Expand Down Expand Up @@ -99,6 +99,8 @@ def save_data(afile, data, file_type=None, **keywords):
:param filename: actual file name, a file stream or actual content
:param data: a dictionary but an ordered dictionary is preferred
: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 library: explicitly name a library for use.
e.g. library='pyexcel-ods'
:param keywords: any other parameters that python csv module's
Expand Down Expand Up @@ -201,7 +203,8 @@ def load_data(


def get_writer(
file_name=None, file_stream=None, file_type=None, library=None, **keywords
file_name=None, file_stream=None, file_type=None,
library=None, force_file_type=None, **keywords
):
"""find a suitable writer"""
inputs = [file_name, file_stream]
Expand All @@ -211,11 +214,15 @@ def get_writer(
raise IOError(constants.MESSAGE_ERROR_02)

file_type_given = True

if file_type is None and file_name:
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")

file_type_given = False

Expand Down
Loading

0 comments on commit 3408497

Please sign in to comment.