Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
language: python
python:
- "2.6"
- "2.7"
- "3.3"
env:
- DJANGO=1.5
- DJANGO=1.6
install:
- pip install -r dev_requirements.txt --use-mirrors
- python setup.py install
- pip install -q Django==$DJANGO --use-mirrors
script:
- coverage run --source=djqscsv test_app/manage.py test djqscsv_tests
Expand Down
9 changes: 7 additions & 2 deletions djqscsv/djqscsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

from django.db.models.query import ValuesQuerySet

import six

""" A simple python package for turning django models into csvs """


Expand Down Expand Up @@ -78,7 +80,10 @@ def write_csv(queryset, file_obj, field_header_map=None,

# merge the custom field headers into the verbose/raw defaults, if provided
_field_header_map = field_header_map or {}
merged_header_map = dict(name_map.items() + _field_header_map.items())
merged_header_map = dict(list(name_map.items()) + list(_field_header_map.items()))
# try this later
# merged_header_map = name_map.copy()
# merged_header_map.update(_field_header_map)

writer = csv.DictWriter(file_obj, field_names)
writer.writerow(merged_header_map)
Expand Down Expand Up @@ -126,7 +131,7 @@ def _sanitize_value(value):
return localize(value)

obj = {}
for key, val in record.iteritems():
for key, val in six.iteritems(record):
if val:
obj[_sanitize_value(key)] = _sanitize_value(val)

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
django>=1.5
six==1.5.2
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
"Framework :: Django",
"License :: OSI Approved :: GNU General Public License (GPL)"
],
install_requires=['django>=1.5'],
install_requires=['django>=1.5',
'six==1.5'],
)
12 changes: 9 additions & 3 deletions test_app/djqscsv_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

import csv

from StringIO import StringIO
from .context import djqscsv

from context import djqscsv
from .models import Person

from models import Person
import six

if six.PY3:
from functools import filter
from io import StringIO
else:
from StringIO import StringIO


class ValidateCleanFilenameTests(TestCase):
Expand Down