summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/import_geofla_csv.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/management/commands/import_geofla_csv.py')
-rw-r--r--ishtar_common/management/commands/import_geofla_csv.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py
index 7ef0e0a38..3ef5eff1c 100644
--- a/ishtar_common/management/commands/import_geofla_csv.py
+++ b/ishtar_common/management/commands/import_geofla_csv.py
@@ -34,18 +34,25 @@ class Command(BaseCommand):
parser.add_argument(
'--year', type=int, default=2014, dest='year',
help='Default year to affect to the town')
+ parser.add_argument(
+ '--quiet', dest='quiet', action='store_true',
+ help='Quiet output')
def handle(self, *args, **options):
csv_file = options['csv_file']
default_year = options['year']
- sys.stdout.write('* using year {} as a default\n'.format(default_year))
- sys.stdout.write('* Opening file {}\n'.format(csv_file))
+ quiet = options['quiet']
+ if not quiet:
+ sys.stdout.write('* using year {} as a default\n'.format(
+ default_year))
+ sys.stdout.write('* Opening file {}\n'.format(csv_file))
nb_created, nb_changed = 0, 0
with open(csv_file, 'rb') as csvfile:
reader = csv.DictReader(csvfile)
for idx, row in enumerate(reader):
- sys.stdout.write('Processing town %d.\r' % (idx + 1))
- sys.stdout.flush()
+ if not quiet:
+ 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
@@ -79,6 +86,8 @@ class Command(BaseCommand):
if not created:
nb_changed += 1
town.save()
+ if quiet:
+ return
sys.stdout.write('\n* {} town created'.format(nb_created))
sys.stdout.write('\n* {} town changed\n'.format(nb_changed))
sys.stdout.flush()