Exemple #1
0
def include_extra(masterdata, year):
    md_list = []

    if year != get_cur_year():
        print "SWITCHING years from ", get_cur_year(), " to ", year, ".\n"
        set_regions(year)
        set_cur_year(year)

    for mdrec in masterdata:
        md = OrderedDict()
        md['Country_Name'] = mdrec['Country_Name']
        md['Country_ISO2'] = str(
            ISO_countries.ISO2_from_name(md['Country_Name'], csl))
        md['Country_ISO3'] = str(
            ISO_countries.ISO3_from_name(md['Country_Name'], csl))
        md['Country_Region'] = str(
            regions.find_region_from_ISO3(md['Country_ISO3'], regs))
        mdreckeys = mdrec.keys()
        for n in range(1, len(mdrec)):
            currentkey = mdreckeys[n]
            md[currentkey] = mdrec[currentkey]
            #print "new ", currentkey, " value is ", md[currentkey]
        md_list.append(md)
        if (md['Country_ISO2'] == "-1"):
            print " No ISO2 code found for ", md['Country_Name']
        if (md['Country_ISO3'] == "-1"):
            print " No ISO3 code found for ", md['Country_Name']
        #if (mdrec['Country_Region'].strip().upper() != md['Country_Region'].strip().upper()):
        #print "Region mismatch between region information in Tab 5 and Tab 1 for ", mdrec['Country_Name']
        #print "Region info from Tab 5 is '", mdrec['Country_Region'],"' and Region info from Tab 1 is '", md['Country_Region'],"'.\n"
    return md_list
Exemple #2
0
def include_extra(masterdata, yr):
	md_list = []
	if (yr != get_current_year()) :
		print "SWITCHING years from ", get_current_year(), " to ", yr, ".\n"
		set_regions(yr)
		set_current_year(yr)
	for mdrec in masterdata:
	    md = OrderedDict()
	    md['Country_Name'] = mdrec['Country_Name']
	    md['Country_ISO2'] = ISO_countries.ISO2_from_name(md['Country_Name'], csl)
	    md['Country_ISO3'] = ISO_countries.ISO3_from_name(md['Country_Name'], csl)

	    if ( md['Country_ISO2'] == utility.get_default_error() ):
	    	print "There is no ISO2 for ", md['Country_Name']
	    if ( md['Country_ISO3'] == utility.get_default_error() ):
	    	print "There is no ISO3 for ", md['Country_Name']

	    md['Country_Region'] = regions.find_region_from_ISO3(md['Country_ISO3'], regs)
	    md[CWS+'_Age_Range'] = mdrec[CWS+'_Age_Range']
	    md[CWS+'_Total_Percentage_of_Working_Children'] = mdrec[CWS+'_Total_Percentage_of_Working_Children']
	    md[CWS+'_Total_Working_Population'] = mdrec[CWS+'_Total_Working_Population']
	    md[CWS+'_Agriculture'] = mdrec[CWS+'_Agriculture']
	    md[CWS+'_Services'] = mdrec[CWS+'_Services']
	    md[CWS+'_Industry'] = mdrec[CWS+'_Industry']
	    md[ESAS+'_Year'] = mdrec[ESAS+'_Year']
	    md[ESAS+'_Age_Range'] = mdrec[ESAS+'_Age_Range']
	    md[ESAS+'_Percentage'] = mdrec[ESAS+'_Percentage']
	    md[CWAS+'_Year'] = mdrec[CWAS+'_Year']
	    md[CWAS+'_Age_Range'] = mdrec[CWAS+'_Age_Range']
	    md[CWAS+'_Total'] = mdrec[CWAS+'_Total']
	    md[UPCR+'_Year'] = mdrec[UPCR+'_Year']
	    md[UPCR+'_Rate'] = mdrec[UPCR+'_Rate']
	    md_list.append(md)
	return md_list
Exemple #3
0
def include_extra(goods_list, yer):
    result = []
    if yer != get_base_year():
        set_sectors(yer)
        set_regions(yer)
        set_base_year(yer)
    for good in goods_list:
        g = OrderedDict()
        g['Country_Name'] = good['Country_Name']
        g['Country_ISO2'] = ISO_countries.ISO2_from_name(
            g['Country_Name'], csl)
        g['Country_ISO3'] = ISO_countries.ISO3_from_name(
            g['Country_Name'], csl)
        if (g['Country_ISO2'] == utility.get_default_error()):
            print " No ISO2 was found for ", g['Country_Name']
        if (g['Country_ISO3'] == utility.get_default_error()):
            print " No ISO3 was found for ", g['Country_Name']
        g['Country_Region'] = regions.find_region_from_ISO3(
            g['Country_ISO3'], regs)
        g['Good_Name'] = good['Good_Name']
        g['Good_Sector'] = sectors.find_sector_from_name(g['Good_Name'], secs)
        g['Child_Labor'] = ("Yes" if
                            (good['Child_Labor'] == present) else "No")
        g['Forced_Labor'] = ("Yes" if
                             (good['Forced_Labor'] == present) else "No")
        g['Forced_Child_Labor'] = ("Yes" if (good['Forced_Child_Labor']
                                             == present) else "No")
        result.append(g)
    return result
Exemple #4
0
def include_extra(masterdata, yr):
    md_list = []
    if (yr != get_current_year()):
        print "SWITCHING years from ", get_current_year(), " to ", yr, ".\n"
        set_regions(yr)
        set_current_year(yr)
    for mdrec in masterdata:
        md = OrderedDict()
        md['Country_Name'] = mdrec['Country_Name']
        md['Country_ISO2'] = ISO_countries.ISO2_from_name(
            md['Country_Name'], csl)
        md['Country_ISO3'] = ISO_countries.ISO3_from_name(
            md['Country_Name'], csl)

        if (md['Country_ISO2'] == utility.get_default_error()):
            print "There is no ISO2 for ", md['Country_Name']
        if (md['Country_ISO3'] == utility.get_default_error()):
            print "There is no ISO3 for ", md['Country_Name']

        md['Country_Region'] = regions.find_region_from_ISO3(
            md['Country_ISO3'], regs)
        md[CWS + '_Age_Range'] = mdrec[CWS + '_Age_Range']
        md[CWS + '_Total_Percentage_of_Working_Children'] = mdrec[
            CWS + '_Total_Percentage_of_Working_Children']
        md[CWS +
           '_Total_Working_Population'] = mdrec[CWS +
                                                '_Total_Working_Population']
        md[CWS + '_Agriculture'] = mdrec[CWS + '_Agriculture']
        md[CWS + '_Services'] = mdrec[CWS + '_Services']
        md[CWS + '_Industry'] = mdrec[CWS + '_Industry']
        md[ESAS + '_Year'] = mdrec[ESAS + '_Year']
        md[ESAS + '_Age_Range'] = mdrec[ESAS + '_Age_Range']
        md[ESAS + '_Percentage'] = mdrec[ESAS + '_Percentage']
        md[CWAS + '_Year'] = mdrec[CWAS + '_Year']
        md[CWAS + '_Age_Range'] = mdrec[CWAS + '_Age_Range']
        md[CWAS + '_Total'] = mdrec[CWAS + '_Total']
        md[UPCR + '_Year'] = mdrec[UPCR + '_Year']
        md[UPCR + '_Rate'] = mdrec[UPCR + '_Rate']
        md_list.append(md)
    return md_list
Exemple #5
0
def include_extra(goods_list, yer):
	result = []
	if yer != get_base_year():
		set_sectors(yer)
		set_regions(yer)
		set_base_year(yer)
	for good in goods_list:
		g = OrderedDict()
		g['Country_Name'] = good['Country_Name']
		g['Country_ISO2'] = ISO_countries.ISO2_from_name(g['Country_Name'], csl)
		g['Country_ISO3'] = ISO_countries.ISO3_from_name(g['Country_Name'], csl)		
		if (g['Country_ISO2'] == utility.get_default_error()):
			print " No ISO2 was found for ", g['Country_Name']
		if (g['Country_ISO3'] == utility.get_default_error()):
			print " No ISO3 was found for ", g['Country_Name']
		g['Country_Region'] = regions.find_region_from_ISO3(g['Country_ISO3'], regs)
		g['Good_Name'] = good['Good_Name']
		g['Good_Sector'] = sectors.find_sector_from_name(g['Good_Name'], secs)
		g['Child_Labor'] = ( "Yes" if (good['Child_Labor'] == present) else "No" )
		g['Forced_Labor'] = ( "Yes" if (good['Forced_Labor'] == present) else "No" )
		g['Forced_Child_Labor'] = ( "Yes" if (good['Forced_Child_Labor'] == present) else "No" )
		result.append(g)
	return result