Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Jun 10, 2016
1 parent ae12a2c commit f1ddd65
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 331 deletions.
2 changes: 2 additions & 0 deletions .moban.d/docs/source/conf.py
@@ -1,6 +1,8 @@
{% extends 'docs/source/conf.py.jj2' %}

{%block custom_doc_theme%}
import os # noqa
import sys # noqa
sys.path.append(os.path.abspath('_themes'))
html_theme_path = ['_themes']
html_theme = 'djangodocs'
Expand Down
30 changes: 15 additions & 15 deletions .moban.d/setup.py
Expand Up @@ -2,22 +2,22 @@
{%block extras %}
{%endblock %}
{%block additional_keywords%}
'API',
'Django'
'API',
'Django'
{%endblock%}

{%block additional_classifiers%}
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5'
{%endblock%}
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -24,11 +24,11 @@ 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 --upgrade "setuptools" "pip==7.1"
- pip install --upgrade "setuptools" "pip==7.1"
- 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:
make test
- make test
after_success:
codecov
13 changes: 11 additions & 2 deletions README.rst
Expand Up @@ -27,9 +27,11 @@ formats by providing a common programming interface.
.. note::
Here is a typical conversation between the developer and the user::

User: "I have uploaded an excel file as instructed, but your application says un-supported file format"
User: "I have uploaded an excel file"
"but your application says un-supported file format"
Developer: "Did you upload an xlsx file or a csv file?"
User: "Well, I am not sure. I saved the data using Microsoft Excel. Surely, it must be in an excel format."
User: "Well, I am not sure. I saved the data using "
"Microsoft Excel. Surely, it must be in an excel format."

The highlighted features are:

Expand Down Expand Up @@ -90,6 +92,13 @@ Tested Django Versions

Installation
================================================================================

Recently, pyexcel(0.2.2+) and its plugins(0.2.0+) started using newer version of setuptools. Please upgrade your setup tools before install latest pyexcel components:

.. code-block:: bash
$ pip install --upgrade setuptools
You can install it via pip:

.. code-block:: bash
Expand Down
17 changes: 10 additions & 7 deletions django_excel/__init__.py
Expand Up @@ -31,7 +31,7 @@ def save_to_database(self, model=None, initializer=None, mapdict=None,
**keywords):
"""
Save data from a sheet to a nominated django model
"""
"""
params = self.get_params(**keywords)
if 'name_columns_by_row' not in params:
params['name_columns_by_row'] = 0
Expand All @@ -50,7 +50,7 @@ def save_book_to_database(self, models=None, initializers=None,
"""
params = self.get_params(**keywords)
params['dest_models'] = models
params['dest_initializers']=initializers
params['dest_initializers'] = initializers
params['dest_mapdicts'] = mapdicts
params['dest_batch_size'] = batch_size
pe.save_book_as(**params)
Expand All @@ -65,7 +65,7 @@ class ExcelInMemoryUploadedFile(ExcelMixin, InMemoryUploadedFile):

class TemporaryUploadedExcelFile(ExcelMixin, TemporaryUploadedFile):
"""
Mix-in pyexcel-webio methods in TemporaryUploadedFile
Mix-in pyexcel-webio methods in TemporaryUploadedFile
"""
pass

Expand Down Expand Up @@ -115,14 +115,15 @@ def _make_response(content, content_type, status, file_name=None):
"""
response = HttpResponse(content, content_type=content_type, status=status)
if file_name:
response["Content-Disposition"] = "attachment; filename=%s" % (file_name)
response["Content-Disposition"] = (
"attachment; filename=%s" % (file_name))
return response


webio.ExcelResponse = _make_response


from pyexcel_webio import (
from pyexcel_webio import ( # noqa
make_response,
make_response_from_array,
make_response_from_dict,
Expand All @@ -142,7 +143,8 @@ def make_response_from_a_table(model, file_type,
:param status: same as :meth:`~django_excel.make_response`
"""
sheet = pe.get_sheet(model=model, **keywords)
return make_response(sheet, file_type, status, file_name=file_name, **keywords)
return make_response(sheet, file_type, status,
file_name=file_name, **keywords)


def make_response_from_tables(models, file_type,
Expand All @@ -157,4 +159,5 @@ def make_response_from_tables(models, file_type,
:param status: same as :meth:`~django_excel.make_response`
"""
book = pe.get_book(models=models, **keywords)
return make_response(book, file_type, status, file_name=file_name, **keywords)
return make_response(book, file_type, status,
file_name=file_name, **keywords)

0 comments on commit f1ddd65

Please sign in to comment.