From 4be73e1e4cbcab26e71abbd973dd982055aa20fa Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 26 Oct 2017 22:52:23 +0200 Subject: Fix tests for towns --- ishtar_common/management/commands/import_geofla_csv.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ishtar_common/management') diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py index b7cb2b604..80e10bc81 100644 --- a/ishtar_common/management/commands/import_geofla_csv.py +++ b/ishtar_common/management/commands/import_geofla_csv.py @@ -18,6 +18,7 @@ # See the file COPYING for details. import csv +import sys from django.core.management.base import BaseCommand from django.contrib.gis.geos import GEOSGeometry, Point @@ -36,14 +37,14 @@ class Command(BaseCommand): def handle(self, *args, **options): csv_file = options['csv_file'] - self.stdout.write('* Opening file {}\n'.format(csv_file)) + sys.stdout.write('* Opening file {}\n'.format(csv_file)) default_year = options['year'] nb_created, nb_changed = 0, 0 with open(csv_file, 'rb') as csvfile: reader = csv.DictReader(csvfile) for idx, row in enumerate(reader): - self.stdout.write('Processing town %d.\r' % (idx + 1)) - self.stdout.flush() + sys.stdout.write('Processing town %d.\r' % (idx + 1)) + sys.stdout.flush() num_insee = row['INSEE_COM'] if len(num_insee) < 5: num_insee = '0' + num_insee @@ -77,9 +78,9 @@ class Command(BaseCommand): if not created: nb_changed += 1 town.save() - self.stdout.write('\n* {} town created'.format(nb_created)) - self.stdout.write('\n* {} town changed\n'.format(nb_changed)) - self.stdout.flush() + sys.stdout.write('\n* {} town created'.format(nb_created)) + sys.stdout.write('\n* {} town changed\n'.format(nb_changed)) + sys.stdout.flush() -- cgit v1.2.3