Beispiel #1
0
 source_description['additionalInfo'] += "General comments:\n" + global_cat[indicator_code]['comments'] + "\n" if global_cat[indicator_code]['comments'] else ''
 source_description['additionalInfo'] += "Statistical concept and methodology:\n" + global_cat[indicator_code]['concept'] if global_cat[indicator_code]['concept'] else ''
 source_description['additionalInfo'] += "Related source links:\n" + global_cat[indicator_code]['sourcelinks'] + "\n" if global_cat[indicator_code]['sourcelinks'] else ''
 source_description['additionalInfo'] += "Other web links:\n" + global_cat[indicator_code]['weblinks'] + "\n" if global_cat[indicator_code]['weblinks'] else ''
 source_description['dataPublisherSource'] = global_cat[indicator_code]['source']
 if 'iea.org' in json.dumps(
     source_description).lower() or 'iea stat' in json.dumps(
     source_description).lower() or 'iea 2014' in json.dumps(
     source_description).lower():
     source_description[
         'dataPublishedBy'] = 'International Energy Agency (IEA) via The World Bank'
 else:
     source_description[
         'dataPublishedBy'] = 'World Bank – World Development Indicators'
 newsource.description=json.dumps(source_description)
 newsource.datasetId=newdataset
 newsource.save()
 logger.info("Updating the source %s." % newsource.name.encode('utf8'))
 s_unit = extract_short_unit(global_cat[indicator_code]['unitofmeasure'])
 newvariable = Variable.objects.get(code=indicator_code, datasetId__in=Dataset.objects.filter(namespace=DATASET_NAMESPACE))
 newvariable.name = global_cat[indicator_code]['name']
 newvariable.unit=global_cat[indicator_code]['unitofmeasure'] if global_cat[indicator_code]['unitofmeasure'] else ''
 newvariable.short_unit = s_unit
 newvariable.description=global_cat[indicator_code]['description']
 newvariable.timespan='1960-' + str(last_available_year)
 newvariable.datasetId=newdataset
 newvariable.sourceId=newsource
 newvariable.save()
 global_cat[indicator_code]['variable_object'] = newvariable
 logger.info("Updating the variable %s." % newvariable.name.encode('utf8'))
 global_cat[indicator_code]['saved'] = True
Beispiel #2
0
 if category in existing_sources[source_name]:
     if category not in up_to_date_sources:
         source = existing_sources[source_name][category]
         source_description['additionalInfo'] = qog_sources[
             source_name]['description']
         source_description[
             'link'] = "http://qog.pol.gu.se/data"
         source_description['link'] += ", " + qog_sources[source_name]['url'] if \
         qog_sources[source_name]['url'] else ""
         source_description[
             'dataPublisherSource'] = qog_sources[
                 source_name]['name']
         source.name = '%s via the Quality of Government dataset' % (
             qog_sources[source_name]['name'])
         source.description = json.dumps(source_description)
         source.datasetId = datasets_ref_models[category].pk
         try:
             with transaction.atomic():
                 source.save()
         except django.db.utils.IntegrityError:
             source.name = '%s via the Quality of Government dataset' % (
                 qog_sources[source_name]
                 ['original_dataset'])
             source.save()
         logger.info("Updating the source %s." %
                     source.name.encode('utf8'))
     elif category not in up_to_date_sources[source_name]:
         source = existing_sources[source_name][category]
         source_description['additionalInfo'] = qog_sources[
             source_name]['description']
         source_description[