Commit b0d86558 authored by Zenon Mousmoulas's avatar Zenon Mousmoulas

Apply the same management command output verbosity enhancements from aff0d789

to parse_institution_xml
parent f81c223b
...@@ -42,6 +42,11 @@ class Command(BaseCommand): ...@@ -42,6 +42,11 @@ class Command(BaseCommand):
if args is None or len(args) != 1: if args is None or len(args) != 1:
raise CommandError('You must supply a file name') raise CommandError('You must supply a file name')
if int(options['verbosity']) > 0:
write = self.stdout.write
else:
write = lambda *args: None
self.parse_and_create(args[0]) self.parse_and_create(args[0])
def parse_and_create(self, instxmlfile): def parse_and_create(self, instxmlfile):
...@@ -54,7 +59,7 @@ class Command(BaseCommand): ...@@ -54,7 +59,7 @@ class Command(BaseCommand):
created_inst_details = False created_inst_details = False
instcontactslist = [] instcontactslist = []
for instdetails in institution: for instdetails in institution:
self.stdout.write('Parsing: %s\n' % (instdetails.tag)) write('Parsing: %s\n' % (instdetails.tag))
if instdetails.tag == 'country': if instdetails.tag == 'country':
continue continue
if instdetails.tag == 'type': if instdetails.tag == 'type':
...@@ -64,7 +69,7 @@ class Command(BaseCommand): ...@@ -64,7 +69,7 @@ class Command(BaseCommand):
ertype=int(type) ertype=int(type)
) )
institution_obj.save() institution_obj.save()
self.stdout.write('Created inst %s\n' % institution_obj.pk) write('Created inst %s\n' % institution_obj.pk)
continue continue
if instdetails.tag == 'inst_realm': if instdetails.tag == 'inst_realm':
inst_realm = instdetails.text inst_realm = instdetails.text
...@@ -218,7 +223,7 @@ class Command(BaseCommand): ...@@ -218,7 +223,7 @@ class Command(BaseCommand):
if loc_wired_txt in ('true', '1'): if loc_wired_txt in ('true', '1'):
loc_wired = True loc_wired = True
if not parsedLocation: if not parsedLocation:
self.stdout.write('Creating location:\n') write('Creating location:\n')
try: try:
serviceloc = ServiceLoc( serviceloc = ServiceLoc(
institutionid=institution_obj, institutionid=institution_obj,
...@@ -244,6 +249,6 @@ class Command(BaseCommand): ...@@ -244,6 +249,6 @@ class Command(BaseCommand):
) )
t.save() t.save()
except Exception as e: except Exception as e:
self.stdout.write('ERROR: %s\n' % e) write('ERROR: %s\n' % e)
continue continue
return True return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment