add debug
[kps.git] / kps_web / trimother.py
blobac7772fefc8ad1a1802ba95cafe84c8a6f57e5df
1 #!/usr/bin/python
3 import sys, os
4 if len(sys.argv) != 3:
5 print "./a.py [Filename] [keyword]"
6 sys.exit(1)
8 if not os.path.isfile(sys.argv[1]):
9 print 'File "'+sys.argv[1]+'" is not existent.'
10 sys.exit(1)
12 allfile=file(sys.argv[1], "r").read().splitlines()
14 report=[
15 'reported-by',
16 'reported-and-',
17 'requested-by',
18 'bisected-by',
19 'pointed-out-by',
20 'debugged-by',
21 'noticed-by',
22 'found-by',
23 'spotted-by',
24 'noted-by',
25 'diagnosed-by',
26 'inspired-by',
27 'report-by',
28 'pointed-to-by',
29 'located-by',
30 'idea-by',
31 'discovered-by',
32 'sight-catched-by',
33 'requested-and-'
36 review=[
37 'reviewed-by',
38 'reviewd-by',
39 'rewieved-by',
40 'reviewed-off-by',
41 'reveiewed-by'
44 ack=[
45 'acked-by',
46 'acked-off-by',
47 'acked-and-',
48 'ackde-by',
49 'ack-by'
52 test=[
53 'tested-by',
54 'tested-and-',
55 'testted-by',
56 'verified-by',
57 'test-by',
58 'reproduced-by'
61 sof=[
62 'signed-off-by',
63 'signed-of-by',
64 'singed-off-by',
65 'fixed-by',
66 'submitted-by',
67 'written-by',
68 'sighed-off-by',
69 'signed-by',
70 'modified-by',
71 'signed_off-by',
72 'sigend-off-by',
73 'ssigned-off-by',
74 'sogned-off-by',
75 'sign-off-by',
76 'signe-off-by',
77 'signen-off-by',
78 'signef-off-by',
79 'signed-pff-by',
80 'signed-ff-by',
81 'siged-off-by'
84 keyset= [report, review, ack, test, sof]
85 wordkey = ["report","review","ack","test","sof"]
87 import re
88 def istime(ist):
89 p=re.compile('[1-2][0-9]{2}[0-9]-[0-9]{2}-[0-9]{2}')
90 m = p.match(ist)
91 if m != None and (m.end() - m.start()) == len(ist):
92 return True
93 else:
94 return False
96 def isstart(iss,ist):
97 p=re.compile('^'+r'[^\s]*'+ist+'.*'+":", re.IGNORECASE)
98 if p.match(iss) != None:
99 return True
100 else:
101 return False
103 time = ''
104 if wordkey.count(sys.argv[2]) > 0:
105 for i in allfile:
106 tmp = i.strip()
107 if istime(tmp):
108 time = tmp
109 continue
110 if i.count('by:') == 0:
111 continue
112 for key in keyset[wordkey.index(sys.argv[2])]:
113 if len(time) > 0 and isstart(i, key):
114 print i+'; '+'Date: '+time
115 break