Skip to content

Commit

Permalink
feat: Add helper method parse_string_to_bool.
Browse files Browse the repository at this point in the history
  • Loading branch information
Delsin Van Grembergen committed Sep 16, 2024
1 parent a341e00 commit 927e562
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/elody/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def mediafile_is_public(mediafile):
] or copyright_color.lower() in ["green", "groen"]


def parse_string_to_bool(value):
if isinstance(value, str):
value_lower = value.strip().lower()
if value_lower in ["true", "yes", "1", "y"]:
return True
elif value_lower in ["false", "no", "0", "n"]:
return False
return value


def read_json_as_dict(filename, logger):
try:
with open(filename) as file:
Expand Down

0 comments on commit 927e562

Please sign in to comment.