-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathutils_log.py
executable file
·30 lines (27 loc) · 919 Bytes
/
utils_log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def save_logging(dictionary, log_name):
with open(log_name, 'w') as f:
for key, value in dictionary.items():
f.write('%s:%s\n' % (key, value))
def load_logging(filename):
data = dict()
with open(filename) as f:
def is_float(input):
try:
num = float(input)
except ValueError:
return False
return True
for line in f.readlines():
if ':' in line:
key,value = line.strip().split(':', 1)
if value.isdigit():
data[key] = int(value)
elif is_float(value):
data[key] = float(value)
elif value == 'None':
data[key] = None
else:
data[key] = value
else:
pass # deal with bad lines of text here
return data