1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-17 11:10:20 +01:00

Merge pull request #3 from cclauss/patch-1

Simplify w/ dict.get() default value, ternary if
This commit is contained in:
Zach Dwiel
2017-10-22 20:46:36 -04:00
committed by GitHub

View File

@@ -63,11 +63,7 @@ def list_all_classes_in_module(module):
def parse_bool(value):
if value.lower() == 'true':
return True
elif value.lower() == 'false':
return False
return value
return {'true': True, 'false': False}.get(value.strip().lower(), value)
def convert_to_ascii(data):
@@ -90,13 +86,7 @@ def break_file_path(path):
def is_empty(str):
if str == 0:
return True
str = str.replace("'", "")
str = str.replace("\"", "")
if len(str) == 0:
return True
return False
return str == 0 or len(str.replace("'", "").replace("\"", "")) == 0
def read_json(filename):
@@ -128,10 +118,7 @@ def parse_int(value):
import ast
try:
int_value = int(value)
if int_value != value:
return value
else:
return int_value
return int_value if int_value == value else value
except:
pass