def get_awarding_agency(row): if row.txn: # We found a matching transaction, so grab its awarding agency info and pass it get_or_create_summary_award return Agency.objects.get(id=int(row.txn)) else: # No matching transaction found, so find/create Award by using toptier agency only, since CGAC code is the only # piece of awarding agency info that we have. return Agency.get_by_toptier(row.agency_identifier)