Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where a reporting-org does not exist #26

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading