diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b99b85a --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +# application builds +build/* +dist/* +MANIFEST + +# python skin +*.pyc +*.pyo + +# osx noise +.DS_Store +profile + +# pycharm noise +.idea +.idea/* + +# vi noise +*.swp +docs/_build/* \ No newline at end of file diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..92f6b24 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,13 @@ +Pyandoc is written and maintained by Kenneth Reitz and +various contributors: + +Development Lead +```````````````` + +- Kenneth Reitz + + +Patches and Suggestions +``````````````````````` + +- A lucky someone! \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..717ff16 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2010 Kenneth Reitz. + +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. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..4506cce --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include HISTORY.rst README.rst LICENSE AUTHORS \ No newline at end of file diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..f072112 --- /dev/null +++ b/NOTICE @@ -0,0 +1,136 @@ +Tablib includes some vendorized python libraries: pyyaml, simplejson, and xlwt. + + + +PyYAML License +============== + +Copyright (c) 2006 Kirill Simonov + +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. + + + +SimpleJSON License +================== + +Copyright (c) 2006 Bob Ippolito + +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. + + + + +XLWT License +============ + +Portions copyright © 2007, Stephen John Machin, Lingfo Pty Ltd +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. None of the names of Stephen John Machin, Lingfo Pty Ltd and any +contributors may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. +""" + +""" + Copyright (C) 2005 Roman V. Kiseliov + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: + "This product includes software developed by + Roman V. Kiseliov ." + + 4. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes software developed by + Roman V. Kiseliov ." + + THIS SOFTWARE IS PROVIDED BY Roman V. Kiseliov ``AS IS'' AND ANY + EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Roman V. Kiseliov OR + ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + OF THE POSSIBILITY OF SUCH DAMAGE. + +Roman V. Kiseliov +Russia +Kursk +Libknecht St., 4 + ++7(0712)56-09-83 + + +Subject: pyExcelerator \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..e626d41 --- /dev/null +++ b/README.rst @@ -0,0 +1,188 @@ +Tablib: format-agnostic tabular dataset library +=============================================== + +:: + + _____ ______ ___________ ______ + __ /_______ ____ /_ ___ /___(_)___ /_ + _ __/_ __ `/__ __ \__ / __ / __ __ \ + / /_ / /_/ / _ /_/ /_ / _ / _ /_/ / + \__/ \__,_/ /_.___/ /_/ /_/ /_.___/ + + + +Tablib is a format-agnostic tabular dataset library, written in Python. + +Output formats supported: + +- Excel (Sets + Books) +- JSON (Sets + Books) +- YAML (Sets + Books) +- CSV (Sets) + +Import formats supported: + +- JSON (Sets + Books) +- YAML (Sets + Books) +- CSV (Sets) + +Note that tablib *purposefully* excludes XML support. It always will. + +Overview +-------- + +`tablib.Dataset()` + A Dataset is a table of tabular data. It may or may not have a header row. They can be build and maniuplated as raw Python datatypes (Lists of tuples|dictonaries). Datasets can be imported from JSON, YAML, and CSV; they can be exported to Excel (XLS), JSON, YAML, and CSV. + +`tablib.Databook()` + A Databook is a set of Datasets. The most common form of a Databook is an Excel file with multiple spreadsheets. Databooks can be imported from JSON and YAML; they can be exported to Excel (XLS), JSON, and YAML. + +Usage +----- + + +Populate fresh data files: :: + + headers = ('first_name', 'last_name') + + data = [ + ('John', 'Adams'), + ('George', 'Washington') + ] + + data = tablib.Dataset(*data, headers=headers) + + +Intelligently add new rows: :: + + >>> data.append(('Henry', 'Ford')) + +Intelligently add new columns: :: + + >>> data.append(col=('age', 90, 67, 83)) + +Slice rows: :: + + >>> print data[:2] + [('John', 'Adams', 90), ('George', 'Washington', 67)] + + +Slice columns by header: :: + + >>> print data['first_name'] + ['John', 'George', 'Henry'] + +Easily delete rows: :: + + >>> del data[1] + +Exports +------- + +Drumroll please........... + +JSON! ++++++ +:: + + >>> print data.json + [ + { + "last_name": "Adams", + "age": 90, + "first_name": "John" + }, + { + "last_name": "Ford", + "age": 83, + "first_name": "Henry" + } + ] + + +YAML! ++++++ +:: + + >>> print data.yaml + - {age: 90, first_name: John, last_name: Adams} + - {age: 83, first_name: Henry, last_name: Ford} + +CSV... +++++++ +:: + + >>> print data.csv + first_name,last_name,age + John,Adams,90 + Henry,Ford,83 + +EXCEL! +++++++ +:: + + >>> open('people.xls', 'wb').write(data.xls) + +It's that easy. + +Imports! +-------- + +JSON +++++ + +:: + + >>> data.json = '[{"last_name": "Adams","age": 90,"first_name": "John"}]' + >>> print data[0] + ('John', 'Adams', 90) + + +YAML +++++ +:: + + >>> data.yaml = '- {age: 90, first_name: John, last_name: Adams}' + >>> print data[0] + ('John', 'Adams', 90) + +CSV ++++ +:: + + >>> data.csv = 'age, first_name, last_name\n90, John, Adams' + >>> print data[0] + ('John', 'Adams', 90) + + >>> print data.yaml + - {age: 90, first_name: John, last_name: Adams} + + + +Installation +------------ + +To install tablib, simply: :: + + $ pip install tablib + +Or, if you absolutely must: :: + + $ easy_install tablib + + +Contribute +---------- + +If you'd like to contribute, simply fork `the repository`_, commit your changes to the **develop** branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS_. + + +Roadmap +------- +- Release CLI Interface +- Auto-detect import format +- Add possible other exports (SQL?) +- Ability to assign types to rows (set, regex=, &c.) + +.. _`the repository`: http://github.com/kennethreitz/tablib +.. _AUTHORS: http://github.com/kennethreitz/tablib/blob/master/AUTHORS diff --git a/TODO.rst b/TODO.rst new file mode 100644 index 0000000..9506d77 --- /dev/null +++ b/TODO.rst @@ -0,0 +1 @@ +* Get inital work implimented \ No newline at end of file diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..ce61d4b --- /dev/null +++ b/fabfile.py @@ -0,0 +1,8 @@ +import os +from fabric.api import * + + +def scrub(): + """ Death to the bytecode! """ + local('rm -fr dist build') + local("find . -name \"*.pyc\" -exec rm '{}' ';'") \ No newline at end of file diff --git a/pyandoc/__init__.py b/pyandoc/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/reqs.txt b/reqs.txt new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..82af8e0 --- /dev/null +++ b/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import sys + +from distutils.core import setup + + +def publish(): + """Publish to PyPi""" + os.system("python setup.py sdist upload") + +if sys.argv[-1] == "publish": + publish() + sys.exit() + +required = [] + +# if sys.version_info < (2, 6): +# required.append('simplejson') + +setup( + name='pyandoc', + version='0.1.0', + description='Python wrapper for Pandoc - the universal document converter', + long_description=open('README.rst').read() + '\n\n' + + open('HISTORY.rst').read(), + author='Kenneth Reitz', + author_email='me@kennethreitz.com', + url='http://tablib.org', + packages= [ + 'tablib', 'tablib.formats', + 'tablib.packages', + 'tablib.packages.simplejson', + 'tablib.packages.xlwt', + 'tablib.packages.yaml', + ], + install_requires=required, + license='MIT', + classifiers=( + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Natural Language :: English', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + # 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + # 'Programming Language :: Python :: 3.0', + # 'Programming Language :: Python :: 3.1', + ), + # entry_points={ + # 'console_scripts': [ + # 'tabbed = tablib.cli:start', + # ], + # } +)