embed.sanitizer: use try/except instead of key membership check

This commit is contained in:
Luna 2019-04-25 22:17:15 -03:00
parent ff9d421a3c
commit b6da5ad9d3
1 changed files with 4 additions and 4 deletions

View File

@ -70,10 +70,10 @@ def path_exists(embed: Embed, components_in: Union[List[str], str]):
# if it exists, then we go down a level inside the dict # if it exists, then we go down a level inside the dict
# (via recursion) # (via recursion)
if current in embed: try:
return path_exists(embed[current], components[1:]) return path_exists(embed[current], components[1:])
except KeyError:
# if it doesn't exist, return False # if the current component doesn't exist, return False
return False return False