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

Simplify w/ dict.get() default value, ternary if

This commit is contained in:
cclauss
2017-10-22 07:41:07 +02:00
committed by GitHub
parent aacd9b5db8
commit 6e9275edc3

View File

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