Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created October 2, 2017 22:24
Show Gist options
  • Save joffilyfe/5486066b63f860b8129491a722899bb3 to your computer and use it in GitHub Desktop.
Save joffilyfe/5486066b63f860b8129491a722899bb3 to your computer and use it in GitHub Desktop.
def get_setting_by_name(name, settings):
res = list(filter(myfilter(name), settings))
if not res:
return None
if isinstance(res[0].setting_value, str):
try:
value = res[0].setting_value.encode("latin1").decode("utf8")
except:
value = res[0].setting_value
else:
value = res[0].setting_value
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment