From 9c0a54d0bd11c5987eb69ccfbb0b9e206dc6d42c Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Tue, 10 May 2016 17:28:50 +0700 Subject: [PATCH] Replace applymoban.py with Yaml configuration Add Change log. --- .moban.d/travis.yml | 7 ++- .moban.yml | 17 +++++++ .travis.yml | 12 ++--- CHANGELOG.rst | 101 +++++++++++++++++++++++++++++++++++++++++ MANIFEST.in | 1 + README.rst | 58 +++++++++++++++++++---- applymoban.py | 15 ------ docs/source/conf.py | 2 +- pyexcel_ods.yaml | 9 ++++ setup.py | 91 +++++++++++++++++++++++-------------- test.bat | 3 +- test.sh | 3 +- tests/requirements.txt | 1 - 13 files changed, 251 insertions(+), 69 deletions(-) create mode 100644 .moban.yml create mode 100644 CHANGELOG.rst delete mode 100644 applymoban.py create mode 100644 pyexcel_ods.yaml diff --git a/.moban.d/travis.yml b/.moban.d/travis.yml index e819f5a..ec64988 100644 --- a/.moban.d/travis.yml +++ b/.moban.d/travis.yml @@ -1,5 +1,10 @@ {% extends "travis.yml.jj2" %} -{%block test_other_python_versions%} - 2.6 +{%block custom_python_versions%} +python: + - 2.6 + - 2.7 {%endblock%} +{% block custom_install %} - rm README.rst; touch README.rst # fails +{%endblock%} diff --git a/.moban.yml b/.moban.yml new file mode 100644 index 0000000..8294aab --- /dev/null +++ b/.moban.yml @@ -0,0 +1,17 @@ +configuration: + configuration_dir: "commons/config" + template_dir: + - "commons/templates" + - ".moban.d" + configuration: pyexcel_ods.yaml +targets: + - README.rst: README.rst + - setup.py: setup.py + - "docs/source/conf.py": "docs/source/conf.py.jj2" + - .travis.yml: travis.yml + - requirements.txt: requirements.txt + - LICENSE: LICENSE.jj2 + - MANIFEST.in: MANIFEST.in.jj2 + - "tests/requirements.txt": "tests/requirements.txt" + - test.sh: test.sh.jj2 + - test.bat: test.sh.jj2 diff --git a/.travis.yml b/.travis.yml index 6b4aed2..692d456 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,14 @@ sudo: false language: python notifications: email: false -env: - global: python: - - 2.7 - 2.6 -install: - - rm applymoban.py - - pip install -r requirements.txt + - 2.7 +before_install: + - rm README.rst; touch README.rst # fails + - if [[ -f rnd_requirements.txt ]]; then pip install -r rnd_requirements.txt; fi - pip install -r tests/requirements.txt script: make test after_success: - codecov \ No newline at end of file + codecov diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..75e3eb7 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,101 @@ +Change log +================================================================================ + + +0.1.1 - 30.01.2016 +-------------------------------------------------------------------------------- + +Added +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +#. 'streaming' is an extra option given to get_data. Only when 'streaming' + is explicitly set to True, the data will be consisted of generators, + hence will break your existing code. +#. uses yield in to_array and returns a generator +#. support multi-line text cell #5 +#. feature migration from pyexcel-ods3 pyexcel/pyexcel-ods3#5 + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. compatibility with pyexcel-io 0.1.1 + + +0.0.12 - 10.10.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Bug fix: excessive trailing columns with empty values + + +0.0.11 - 26.09.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Complete fix for libreoffice datetime field + + +0.0.10 - 15.09.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Bug fix: date field could have datetime from libreoffice + + +0.0.9 - 21.08.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Bug fix: utf-8 string throw unicode exceptions + + +0.0.8 - 28.06.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Pin dependency odfpy 0.9.6 to avoid buggy odfpy 1.3.0 + + +0.0.7 - 28.05.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. Bug fix: "number-columns-repeated" is now respected + + +0.0.6 - 21.05.2015 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. get_data and save_data are seen across pyexcel-* extensions. remember them + once and use them across all extensions. + + +0.0.5 - 22.02.2015 +-------------------------------------------------------------------------------- + +Added +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +#. Loads only one sheet from a multiple sheet book +#. Use New BSD License + + +0.0.4 - 14.12.2014 +-------------------------------------------------------------------------------- + +Updated +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +#. IO interface update as pyexcel-io introduced keywords. + + +0.0.3 - 08.12.2014 +-------------------------------------------------------------------------------- + +#. initial release diff --git a/MANIFEST.in b/MANIFEST.in index 9561fb1..5f13ef0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include README.rst +include CHANGELOG.rst diff --git a/README.rst b/README.rst index 643e783..88691b7 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ does the same thing but supports Python 3.3 and 3.4 and depends on lxml. Known constraints ================== -Fonts, colors and charts are not supported. +Fonts, colors and charts are not supported. Installation ================================================================================ @@ -62,7 +62,11 @@ Write to an ods file ... from StringIO import StringIO ... else: ... from io import BytesIO as StringIO - >>> from pyexcel_io import OrderedDict + >>> PY2 = sys.version_info[0] == 2 + >>> if PY2 and sys.version_info[1] < 7: + ... from ordereddict import OrderedDict + ... else: + ... from collections import OrderedDict Here's the sample code to write a dictionary to an ods file: @@ -125,6 +129,12 @@ Continue from previous example: As a pyexcel plugin -------------------------------------------------------------------------------- +No longer, explicit import is needed since pyexcel version 0.2.2. Instead, +this library is auto-loaded. So if you want to read data in ods format, +installing it is enough. + +Any version under pyexcel 0.2.2, you have to keep doing the following: + Import it in your file to enable this plugin: .. code-block:: python @@ -141,16 +151,16 @@ Here is the sample code: .. code-block:: python >>> import pyexcel as pe - >>> from pyexcel.ext import ods + >>> # from pyexcel.ext import ods >>> sheet = pe.get_book(file_name="your_file.ods") >>> sheet - Sheet Name: Sheet 1 + Sheet 1: +---+---+---+ | 1 | 2 | 3 | +---+---+---+ | 4 | 5 | 6 | +---+---+---+ - Sheet Name: Sheet 2 + Sheet 2: +-------+-------+-------+ | row 1 | row 2 | row 3 | +-------+-------+-------+ @@ -180,13 +190,13 @@ You got to wrap the binary content with stream to get ods working: ... r = pe.get_book(file_type="ods", file_content=content) ... print(r) ... - Sheet Name: Sheet 1 + Sheet 1: +---+---+---+ | 1 | 2 | 3 | +---+---+---+ | 4 | 5 | 6 | +---+---+---+ - Sheet Name: Sheet 2 + Sheet 2: +-------+-------+-------+ | row 1 | row 2 | row 3 | +-------+-------+-------+ @@ -215,6 +225,38 @@ License New BSD License +Developer guide +================== + +Development steps for code changes + +#. git clone https://github.com/pyexcel/pyexcel-ods.git +#. cd pyexcel-ods +#. pip install -r requirements.txt +#. pip install -r tests/requirements.txt + + +In order to update test envrionment, and documentation, additional setps are +required: + +#. pip install moban +#. git clone https://github.com/pyexcel/pyexcel-commons.git +#. make your changes in `.moban.d` directory, then issue command `moban` + + +How to test your contribution +------------------------------ + +Although `nose` and `doctest` are both used in code testing, it is adviable that unit tests are put in tests. `doctest` is incorporated only to make sure the code examples in documentation remain valid across different development releases. + +On Linux/Unix systems, please launch your tests like this:: + + $ make test + +On Windows systems, please issue this command:: + + > test.bat + Credits ================================================================================ @@ -225,4 +267,4 @@ ODSReader is originally written by `Marco Conti >> import os >>> os.unlink("your_file.ods") - >>> os.unlink("another_file.ods") \ No newline at end of file + >>> os.unlink("another_file.ods") diff --git a/applymoban.py b/applymoban.py deleted file mode 100644 index af32720..0000000 --- a/applymoban.py +++ /dev/null @@ -1,15 +0,0 @@ -from os import path, system - -config_dir = 'commons/config' -template_dir = 'commons/templates' - -if not path.exists("commons"): - system("git clone https://github.com/pyexcel/pyexcel-commons.git commons") -system("moban -cd {0} -td {1} -t docs/source/conf.py.jj2 -o docs/source/conf.py -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td {1} .moban.d -t README.rst -o README.rst -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td {1} .moban.d -t setup.py -o setup.py -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td {1} .moban.d -t travis.yml -o .travis.yml -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td .moban.d -t requirements.txt -o requirements.txt -c moban.yaml".format(config_dir)) -system("moban -cd {0} -td {1} -t LICENSE.jj2 -o LICENSE -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td {1} .moban.d -t tests/requirements.txt -o tests/requirements.txt -c moban.yaml".format(config_dir, template_dir)) -system("moban -cd {0} -td {1} .moban.d -t MANIFEST.in.jj2 -o MANIFEST.in -c moban.yaml".format(config_dir, template_dir)) diff --git a/docs/source/conf.py b/docs/source/conf.py index a4a8b5d..e06a389 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -248,4 +248,4 @@ texinfo_documents = [ #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False \ No newline at end of file +#texinfo_no_detailmenu = False diff --git a/pyexcel_ods.yaml b/pyexcel_ods.yaml new file mode 100644 index 0000000..7d22d7a --- /dev/null +++ b/pyexcel_ods.yaml @@ -0,0 +1,9 @@ +overrides: "pyexcel.yaml" +name: "pyexcel-ods" +nick_name: ods +version: 0.1.1 +file_type: ods +dependencies: + - pyexcel-io>=0.1.0 + - odfpy==0.9.6 +description: A wrapper library to read, manipulate and write data in ods format diff --git a/setup.py b/setup.py index 6d990d9..aa9a04a 100644 --- a/setup.py +++ b/setup.py @@ -5,45 +5,68 @@ except ImportError: use_setuptools() from setuptools import setup, find_packages -with open("README.rst", 'r') as readme: - README_txt = readme.read() +NAME = 'pyexcel-ods' +AUTHOR = 'C.W.' +VERSION = '0.1.1' +EMAIL = 'wangc_2011 (at) hotmail.com' +LICENSE = 'New BSD' +PACKAGES = find_packages(exclude=['ez_setup', 'examples', 'tests']) +DESCRIPTION = 'A wrapper library to read, manipulate and write data in ods format' +KEYWORDS = [ + 'excel', + 'python', + 'pyexcel', +] -dependencies = [ +INSTALL_REQUIRES = [ 'pyexcel-io>=0.1.0', 'odfpy==0.9.6', ] -extras = {} +EXTRAS_REQUIRE = { +} - -setup( - name='pyexcel-ods', - author='C. W.', - version='0.1.1', - author_email='wangc_2011 (at) hotmail.com', - url='https://github.com/pyexcel/pyexcel-ods', - description='A wrapper library to read, manipulate and write data in ods format', - install_requires=dependencies, - extras_require=extras, - packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - include_package_data=True, - long_description=README_txt, - zip_safe=False, - tests_require=['nose'], - keywords=[ - 'excel', - 'python', - 'pyexcel', - ], - license='New BSD', - classifiers=[ - 'Topic :: Office/Business', - 'Topic :: Utilities', - 'Topic :: Software Development :: Libraries', - 'Programming Language :: Python', - 'License :: OSI Approved :: BSD License', - 'Intended Audience :: Developers', +CLASSIFIERS = [ + 'Topic :: Office/Business', + 'Topic :: Utilities', + 'Topic :: Software Development :: Libraries', + 'Programming Language :: Python', + 'License :: OSI Approved :: BSD License', + 'Intended Audience :: Developers', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7' - ] -) \ No newline at end of file +] + + +def read_files(*files): + """Read files into setup""" + text = "" + for single_file in files: + text = text + read(single_file) + "\n" + return text + + +def read(afile): + """Read a file into setup""" + with open(afile, 'r') as opened_file: + return opened_file.read() + + +if __name__ == '__main__': + setup( + name=NAME, + author=AUTHOR, + version=VERSION, + author_email=EMAIL, + description=DESCRIPTION, + install_requires=INSTALL_REQUIRES, + keywords=KEYWORDS, + extras_require=EXTRAS_REQUIRE, + packages=PACKAGES, + include_package_data=True, + long_description=read_files('README.rst', 'CHANGELOG.rst'), + zip_safe=False, + tests_require=['nose'], + license=LICENSE, + classifiers=CLASSIFIERS + ) diff --git a/test.bat b/test.bat index 6c81ef9..bb4d168 100644 --- a/test.bat +++ b/test.bat @@ -1 +1,2 @@ -nosetests --with-cov --with-doctest --doctest-extension=.rst -I applymoban.py -I setup.py +pip freeze +nosetests --with-cov --cov pyexcel_ods --cov tests --with-doctest --doctest-extension=.rst tests README.rst pyexcel_ods diff --git a/test.sh b/test.sh index f751a57..bb4d168 100644 --- a/test.sh +++ b/test.sh @@ -1 +1,2 @@ -nosetests --rednose --with-cov --cov pyexcel_ods --cov tests --with-doctest --doctest-extension=.rst +pip freeze +nosetests --with-cov --cov pyexcel_ods --cov tests --with-doctest --doctest-extension=.rst tests README.rst pyexcel_ods diff --git a/tests/requirements.txt b/tests/requirements.txt index eb3d30a..c63425d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,4 @@ nose -rednose nose-cov codecov coverage