Skip to content

Commit

Permalink
Use string comparison in parse_boolean instead of the (simple)json mo…
Browse files Browse the repository at this point in the history
…dule.
  • Loading branch information
jezdez committed Oct 9, 2018
1 parent 155a9d3 commit a5de5bd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions redash/settings/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import simplejson


def fix_assets_path(path):
Expand All @@ -19,8 +18,15 @@ def set_from_string(s):
return set(array_from_string(s))


def parse_boolean(str):
return simplejson.loads(str.lower())
def parse_boolean(s):
"""Takes a string and returns the equivalent as a boolean value."""
s = s.strip().lower()
if s in ('yes', 'true', 'on', '1'):
return True
elif s in ('no', 'false', 'off', '0', 'none'):
return False
else:
raise ValueError('Invalid boolean value %r' % s)


def int_or_none(value):
Expand Down

0 comments on commit a5de5bd

Please sign in to comment.