Revision fb8357c8 snf-django-lib/snf_django/management/utils.py
b/snf-django-lib/snf_django/management/utils.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
import json |
35 |
import csv |
|
36 | 35 |
import operator |
37 | 36 |
import locale |
38 | 37 |
import unicodedata |
... | ... | |
41 | 40 |
from django.utils.timesince import timesince, timeuntil |
42 | 41 |
from django.db.models.query import QuerySet |
43 | 42 |
from django.utils.encoding import smart_unicode, smart_str |
43 |
from snf_django.management.unicodecsv import UnicodeWriter |
|
44 | 44 |
|
45 | 45 |
|
46 | 46 |
def smart_locale_unicode(s, **kwargs): |
... | ... | |
211 | 211 |
out.write(json.dumps(table, indent=4)) |
212 | 212 |
out.write("\n") |
213 | 213 |
elif output_format == "csv": |
214 |
cw = csv.writer(out) |
|
214 |
enc = locale.getpreferredencoding() |
|
215 |
cw = UnicodeWriter(out, encoding=enc) |
|
215 | 216 |
if headers: |
216 | 217 |
table.insert(0, headers) |
217 | 218 |
cw.writerows(table) |
Also available in: Unified diff