Debian Codegraph @

commissioning/extrap/ins_inputs/parse_lengthy.py

raw symbols SCIP
1 import re
2 def run(inname):
3 f=open(inname)
4 f2=open(inname.replace('.txt','_key.txt'),'w')
5 d={}
6 dshort={}
7 lookup={}
8 namepat=re.compile('(acs[^ ]*fits)')
9 compat = re.compile('"(.*)"')
10 space = re.compile(r'\s+')
11 count=0
12 for nextline in f:
13 line=space.sub(' ',nextline)
14 x=re.search(namepat,line)
15 fname=x.group(1)
16 x=re.search(compat,line)
17 comment=x.group(1)
18 try:
19 d[comment.strip()].append(fname)
20 except KeyError:
21 d[comment.strip()]=[fname]
22 count+=1
23 dshort[count]=comment.strip()
24 lookup[comment.strip()]=count
25 f2.write("%s %d\n"%(fname,lookup[comment.strip()]))
26 f.close()
27 f2.close()
28 out=open(inname.replace('.txt','_code.txt'),'w')
29 for k in dshort:
30 out.write('%s\t%s\n'%(k,dshort[k]))
31 out.close()
32
33 return d,dshort