From c08330a7a199c57742ed30d0220ed2f76b361838 Mon Sep 17 00:00:00 2001 From: Sean Greaves <23040351+ribenamaplesyrup@users.noreply.github.com> Date: Sat, 18 Nov 2023 16:44:30 +0000 Subject: [PATCH] Update hop.py --- sugartrail/hop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sugartrail/hop.py b/sugartrail/hop.py index 9863ce0..327621d 100644 --- a/sugartrail/hop.py +++ b/sugartrail/hop.py @@ -31,9 +31,18 @@ class Hop: for officer in officers: new_officer_id = str(officer['links']['officer']['appointments'].split('/')[2]) if new_officer_id not in network.graph: + try: + title = sugartrail.api.get_appointments(new_officer_id)['items'][0]['name'] + except: + print(f"failed to get title for officer: {new_officer_id}") + try: + title = sugartrail.processing.normalise_name(officer['name']) + except: + print(f"failed to get title for officer: {new_officer_id}") + title = new_officer_id network.graph[new_officer_id] = { 'depth': network.n+1, - 'title': sugartrail.api.get_appointments(new_officer_id)['items'][0]['name'], + 'title': title, 'node_type': "Person", 'arcs': [] }