Skip to content

Commit

Permalink
reworked validate_organ_code to accept only a single argument to go a…
Browse files Browse the repository at this point in the history
…long with other changes to get_organ_types
  • Loading branch information
DerekFurstPitt committed Aug 27, 2024
1 parent 7e206bb commit 0f133b7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3273,7 +3273,7 @@ def get_prov_info():
distinct_organ_uuid_list.append(item['uuid'])

organ_code = item['organ'].upper()
validate_organ_code(organ_code, organ_types_dict)
validate_organ_code(organ_code)

distinct_organ_type_list.append(organ_types_dict[organ_code].lower())
internal_dict[HEADER_ORGAN_HUBMAP_ID] = distinct_organ_hubmap_id_list
Expand Down Expand Up @@ -3593,7 +3593,7 @@ def get_prov_info_for_dataset(id):
distinct_organ_uuid_list.append(item['uuid'])

organ_code = item['organ'].upper()
validate_organ_code(organ_code, organ_types_dict )
validate_organ_code(organ_code)

distinct_organ_type_list.append(organ_types_dict[organ_code].lower())
internal_dict[HEADER_ORGAN_HUBMAP_ID] = distinct_organ_hubmap_id_list
Expand Down Expand Up @@ -3789,7 +3789,7 @@ def sankey_data():
internal_dict[HEADER_DATASET_GROUP_NAME] = dataset[HEADER_DATASET_GROUP_NAME]

organ_code = dataset[HEADER_ORGAN_TYPE].upper()
validate_organ_code(organ_code, organ_types_dict)
validate_organ_code(organ_code)

internal_dict[HEADER_ORGAN_TYPE] = organ_types_dict[organ_code].lower()

Expand Down Expand Up @@ -5456,9 +5456,8 @@ def access_level_prefix_dir(dir_name):
----------
organ_code : str
"""
def validate_organ_code(organ_code, organ_types_dict=None):
if organ_types_dict is None:
organ_types_dict = schema_manager.get_organ_types()
def validate_organ_code(organ_code):
organ_types_dict = schema_manager.get_organ_types()
if not organ_code.isalpha() or not len(organ_code) == 2:
internal_server_error(f"Invalid organ code {organ_code}. Must be 2-letter alphabetic code")

Expand Down

0 comments on commit 0f133b7

Please sign in to comment.