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 Sep 14, 2018
1 parent e211ecc commit 08c20db
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
Expand Up @@ -2,7 +2,6 @@
import urlparse
import urllib

import simplejson

def parse_db_url(url):
url_parts = urlparse.urlparse(url)
Expand Down Expand Up @@ -38,8 +37,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 08c20db

Please sign in to comment.