diff --git a/data.py b/data.py index 55c4e32d1a..00567724e4 100644 --- a/data.py +++ b/data.py @@ -211,7 +211,13 @@ def transform_codelist_mapping_keys(codelist_mapping): return codelist_mapping def create_codelist_mapping(major_version): - codelist_mapping = {x['path']:x['codelist'] for x in json.load(open('data/IATI-Codelists-{}/out/clv2/mapping.json'.format(major_version)))} + codelist_mapping = {} + for x in json.load(open('data/IATI-Codelists-{}/out/clv2/mapping.json'.format(major_version))): + if 'condition' in x \ + and x['path'] in codelist_mapping \ + and not re.search(r'not\([^)]+\)', x['condition']): + continue + codelist_mapping[x['path']] = x['codelist'] return transform_codelist_mapping_keys(codelist_mapping) MAJOR_VERSIONS = ['2', '1']