Skip to content

Commit

Permalink
making beacon setting typesafe
Browse files Browse the repository at this point in the history
  • Loading branch information
Paprikant committed Nov 21, 2022
1 parent b14edcd commit d453592
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion files/beacon-import.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ def set_up_logging(verbosity: int):
logging.basicConfig(level=logging.WARN)


def string_as_bool(string: Any) -> bool:
"""
Returns the bool value corresponding to the given value
used to typesave the api responses
"""
if str(string).lower() in ("true", "yes", "on", "1"):
return True
else:
return False

def set_up_galaxy_instance(galaxy_url: str, galaxy_key: str) -> GalaxyInstance:
"""
Returns a galaxy instance with the given URL and api key.
Expand Down Expand Up @@ -254,7 +265,7 @@ def get_beacon_histories(gi: GalaxyInstance) -> List[str]:

# skip adding the history if beacon_enabled is not set for the owner account
history_user_preferences: Dict[str, str] = user_details["preferences"]
if "beacon_enabled" not in history_user_preferences or history_user_preferences["beacon_enabled"] != True:
if "beacon_enabled" not in history_user_preferences or not string_as_bool(history_user_preferences["beacon_enabled"]):
continue

history_ids.append(history["id"])
Expand Down

0 comments on commit d453592

Please sign in to comment.