]> git.parisson.com Git - telemeta.git/commitdiff
fix csv export command, add more deps
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 22 Jan 2016 16:47:23 +0000 (17:47 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Fri, 22 Jan 2016 16:47:23 +0000 (17:47 +0100)
setup.py
telemeta/management/commands/telemeta-export-all-to-csv.py

index 7fa75c1b244aa934bf725981a4854644b19fc108..d85c9f4dec52da580ef7b3abfd9bc9aead5481be 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -74,6 +74,8 @@ setup(
         'elasticsearch==1.6.0',
         'django-haystack',
         'ebooklib',
+        'django-environ',
+        'redis',
     ],
   tests_require=['pytest-django', 'pytest-cov', 'factory-boy'],
   # Provide a test command through django-setuptest
index 582072226dfd921457f0799b38bf9f13c3106677..2fc5623047a0a50e6511c64afd6dd13bc32e92a7 100644 (file)
@@ -9,7 +9,7 @@ import timeside.core
 from timeside.server.models import *
 from timeside.core.tools.test_samples import generateSamples
 from telemeta.models import *
-from telemeta.util.unicode import *
+from telemeta.util.unicode import Echo, UnicodeCSVWriter
 
 
 class Command(BaseCommand):
@@ -18,14 +18,17 @@ class Command(BaseCommand):
     def handle(self, *args, **options):
         path = args[-1]
         element_type = args[-2]
-        f = open(path, 'w')
+        pseudo_buffer = Echo()
+
         if element_type == "item":
             elements = MediaItem.objects.all().order_by('id')
         elif element_type == "collection":
             elements = MediaCollection.objects.all().order_by('id')
         else:
             raise TypeError('type should be "item" or "collection"')
-        writer = UnicodeWriter(f)
-        csv = CSVExport(writer)
-        csv.write(elements)
+
+        f = open(path, 'w')
+        writer = UnicodeCSVWriter(pseudo_buffer, elements)
+        for data in writer.output():
+            f.write(data)
         f.close()