Skip to content

Commit

Permalink
Merge pull request #26 from codeforIATI/fix-reporting-org-missing
Browse files Browse the repository at this point in the history
Fix bug where a reporting-org does not exist
  • Loading branch information
andylolz authored Mar 27, 2024
2 parents aab13de + d35c64c commit 10c9ade
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion orgidfinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def get_text(el, path, default_lang):

def parse_org(organisation):
org_id = organisation.id
reporting_org_id = organisation.etree.find('reporting-org').get('ref')
reporting_org = organisation.etree.find('reporting-org')
if not reporting_org:
return None
reporting_org_id = reporting_org.get('ref')
if not reporting_org_id or org_id != reporting_org_id:
return None

Expand Down
1 change: 1 addition & 0 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def zip_discard_compr(*iterables, sentinel=None):
for dataset in iatikit.data().datasets.where(filetype='organisation'):
org_infos = orgidfinder.parse_org_file(dataset)
for org_info in org_infos:
if org_info is None: continue
org_info['org_type'] = guide._org_types.get(org_info['org_type_code'])
id_ = quote_plus(org_info['org_id'])
with open(Path(f'{output_dir}/data/{id_}.json'), 'w') as f:
Expand Down

0 comments on commit 10c9ade

Please sign in to comment.