Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbontyes authored Jun 22, 2024
1 parent e9ad7ee commit 1c979e1
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions update_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ def is_valid_36_char_uuid(ext_id):
return False
return True

def update_concept_external_id(url, concept_info, ext_id):
def update_concept_external_id(url, concept_details, ext_id):
"""Update the external ID of a concept."""
if not is_valid_36_char_uuid(ext_id):
new_ext_id = generate_new_uuid()
update_payload = json.dumps({"external_id": new_ext_id})
if not DRY_RUN:
response_update = requests.put(url, headers=HEADERS, data=update_payload, timeout=10)
response_update = requests.put(
url, headers=HEADERS, data=update_payload, timeout=10
)
response_update.raise_for_status()
else:
response_update = None
Expand All @@ -83,8 +85,8 @@ def update_concept_external_id(url, concept_info, ext_id):
'Timestamp': datetime.now().isoformat(),
'Status': 'Updated',
'Valid External ID': ext_id,
'Concept ID': concept_info['id'],
'Name': concept_info['display_name'],
'Concept ID': concept_details['id'],
'Name': concept_details['display_name'],
'URL': url,
'Current External ID': ext_id,
'New External ID': new_ext_id,
Expand All @@ -98,9 +100,9 @@ def get_all_concepts(url):
"""Retrieve all concepts from the given URL."""
all_concepts = []
while url:
response_get = requests.get(url, headers=HEADERS, timeout=10)
response_get.raise_for_status()
data = response_get.json()
response = requests.get(url, headers=HEADERS, timeout=10)
response.raise_for_status()
data = response.json()
if isinstance(data, dict):
all_concepts.extend(data.get('results', []))
url = data.get('next')
Expand All @@ -121,9 +123,9 @@ def get_all_concepts(url):
# Iterate over the concepts and update external IDs based on the conditions
for concept in concepts:
concept_url = f"{OCL_API_URL}{concept['url']}"
response_get = requests.get(concept_url, headers=HEADERS, timeout=10)
response_get.raise_for_status()
concept_info = response_get.json()
response = requests.get(concept_url, headers=HEADERS, timeout=10)
response.raise_for_status()
concept_info = response.json()
concept_name = concept['display_name']
external_id = concept.get('external_id', '')
update_concept_external_id(concept_url, concept_info, external_id)
Expand Down

0 comments on commit 1c979e1

Please sign in to comment.