-
Notifications
You must be signed in to change notification settings - Fork 1
/
parms.py
37 lines (30 loc) · 1012 Bytes
/
parms.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
31
32
33
34
35
36
37
import os
import pickle
import string
peakrec_fraction = 2
home_dir = '/home/deaconjs/Desktop/SPADE/'
parms_dat = os.path.join(home_dir, 'parms.dat')
def get(query_parm=None):
execfile(parms_dat, globals())
if query_parm == None:
return parms_list.keys()
else:
return parms_list[query_parm]
def set(query_parm, value):
parms_file = open(parms_dat, 'r')
lines = parms_file.readlines()
for lind in range(len(lines)):
line = string.strip(lines[lind])
if query_parm in line: # if already present, modify, else, append at the end
lines[lind:lind+1] = ' \'%s\':%s,\n'%(query_parm, repr(value))
break
else:
lineslen = len(lines)
lines[lineslen-1:lineslen-1] = ' \'%s\':%s,\n'%(query_parm, repr(value))
parms_file.close()
parms_file = open(parms_dat, 'w')
parms_file.writelines(lines)
parms_file.close()
def what():
execfile(parms_dat, globals())
print parms_list.keys()