0
|
1
|
|
2
|
|
3 from Config import subs
|
|
4 import Patch
|
|
5
|
|
6 Patch.reload_data(0)
|
|
7
|
|
8 def print_tsv(filename,allchans,subs):
|
|
9 f=open(filename,"w")
|
|
10 print >>f,"\t"+"\t".join(allchans)
|
|
11
|
|
12 for name,levels in subs.items():
|
|
13 normd={}
|
|
14 # nrmalize the names in the sub
|
|
15 for k,v in levels.items():
|
|
16 normd[Patch.resolve_name(k)]=v
|
|
17
|
|
18 print >>f,"%s\t%s" % (name, "\t".join([str(normd.get(c,"")) for c in allchans]))
|
|
19
|
|
20
|
|
21 def read_tsv(filename,outname):
|
|
22 """converts from tsv filename to a config file (python) named outname"""
|
|
23 f=open(filename,'r')
|
|
24 out=open(outname,'w')
|
|
25 allchans=f.readline().split("\t")[1:]
|
|
26 for line in f.xreadlines():
|
|
27 spl=line.split("\t")
|
|
28 subname=spl[0]
|
|
29 print >>out,"subs['%s']={" % subname,
|
|
30 for channame,level in zip(allchans,spl[1:]):
|
|
31 try:
|
|
32 if level!="" and int(level)>0:
|
|
33 print >>out,"'%s': %s," %(channame,level),
|
|
34 except ValueError:
|
|
35 pass
|
|
36 print >>out,"}\n"
|
|
37
|
|
38
|
101
|
39 #print_tsv(filename="sublevs.txt",allchans=Patch.get_all_channels(),subs=subs)
|
|
40 read_tsv(filename="sublevs-fixed",outname="Configsubs-fixed.py")
|
0
|
41
|
|
42
|