1. Development¶
This section contains some information about module development - in a case you want to contribute to it. Which is welcome, btw.
1.1. Getting started¶
To get started with the development, follow the steps:
Install development-time dependencies:
pip install nose
1.3. Releasing¶
Steps to make a release:
Increase the version number (exceltable.py and CHANGES)
Run tox tests:
pip install tox tox
Build documentation:
# NOTE: Sphinx-pypi-upload runs only with Python 2 pip install sphinx-pypi-upload python setup.py build_sphinx
Upload documentation
python setup.py upload_docs
Publish app
python setup.py sdist upload
1.4. Testing¶
Project uses nose for unit testing, coverage for testing coverage reporting and tox for compliance testing. To execute the tests, run:
- Unittests:
python setup.py test
- Compliance:
tox
Project repository comes with ready-made configuration for both of the tools, which are used automatically.
1.5. API¶
This section provides some further information about internals of the module:
-
class
sphinxcontrib.exceltable.
ExcelTableDirective
(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)¶ ExcelTableDirective implements the directive. Directive allows to create RST tables from the contents of the Excel sheet. The functionality is very similar to csv-table (docutils) and xmltable (
sphinxcontrib.xmltable
).Example of the directive:
.. exceltable:: :file: path/to/document.xls :header: 1
-
class
sphinxcontrib.exceltable.
ExcelTable
(fobj, encoding=u'utf-8')¶ Class generates the list based table from the given excel-document, suitable for the directive.
Class also implements the custom query format, is to use for the directive.:
>>> import os >>> from sphinxcontrib import exceltable >>> >>> fo = open(os.path.join(os.path.dirname(exceltable.__file__),'../doc/example/cartoons.xls'), 'r+b') >>> et = exceltable.ExcelTable(fo) >>> >>> table = et.create_table(fromcell='A1', tocell='C4') >>> assert et.fromcell == (0, 0) >>> assert et.tocell == (2,3) >>> >>> table = et.create_table(fromcell='B10', tocell='B11', sheet='big') >>> assert et.fromcell == (1,9) >>> assert et.tocell == (1,10)
-
ExcelTable.
create_table
(fromcell=None, tocell=None, nheader=0, sheet=0)¶ Creates a table (as a list) based on given query and columns
- fromcell:
- The index of the cell where to begin. The default is from the beginning of the data set (0, 0).
- tocell:
- The index of the cell where to end the selection. Default is in the end of the data set.
- nheader:
- Number of lines which are considered as a header lines. Normally, the value is 0 (default) or 1.
- sheet:
Name or index of the sheet as string/unicode. The index starts from the 0 and is the default value. If numeric value is given, provide it in format:
et.create_table(fromcell='A1', tocell='B2', sheet='2')
1.6. Licensing¶
The software is licensed with liberal MIT license, making it suitable for both commercial and open source usage:
The MIT License
Copyright (c) 2009 Juha Mustonen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.