Go to the documentation of this file.00001
00002
00003
00004
00005
00006 import sys
00007 import re
00008 import Parameters
00009 import operator
00010 import string
00011
00012 def runme2(fid,infile,outfile):
00013 fin = open(infile,'r')
00014 fout = open(outfile,'w')
00015 sub = ' ' + fid + '[ $]'
00016 r = re.compile(sub)
00017
00018 for line in fin.xreadlines():
00019 i = line.index(' ')+1
00020 s = r.search(line[i:])
00021 if s != None:
00022 print >>fout,line[0:i+s.end()-1]
00023
00024 def runme(fid,infile,outfile):
00025 fin = open(infile,'r')
00026 fout = open(outfile,'w')
00027 tot_up = Parameters.parameters['view']['levels_up']
00028 tot_down = Parameters.parameters['view']['levels_down']
00029 print "up=",tot_up," down=",tot_down
00030
00031 trigger = Parameters.parameters['find']['immediate_children_threshold']
00032
00033 for line in fin.xreadlines():
00034 a=line.split()
00035 b=a[2:]
00036
00037 try:
00038 i=operator.indexOf(b,fid)
00039
00040 if i < tot_up: c = i
00041 else: c = tot_up
00042 print >>fout,"%s %s %s"%(a[0],a[1],string.join(b[i-c:i+1+tot_down]))
00043 except ValueError:
00044 pass
00045
00046 if __name__ == "__main__":
00047 if len(sys.argv) < 3:
00048 print "usage: ", sys.argv[0], " function_id input_file_prefix"
00049 sys.exit(1)
00050
00051 fid = sys.argv[1]
00052 infile = sys.argv[2]
00053 outfile = fid + Parameters.parameters['view']['out_file_suffix']
00054 runme(fid, infile, outfile)
00055