519
|
1 #!/usr/bin/env python
|
|
2
|
|
3 # XXX STUB
|
|
4
|
|
5 """
|
|
6 http://code.google.com/p/python-patch/
|
|
7 """
|
|
8
|
|
9 import difflib
|
|
10 import optparse
|
|
11 import os
|
|
12 import subprocess
|
|
13 import sys
|
|
14 from which import which
|
|
15
|
|
16 here = os.path.dirname(os.path.realpath(__file__))
|
|
17
|
|
18 wiggle = which('wiggle')
|
|
19
|
|
20 def find(directory, pattern):
|
|
21 # TODO: -> python
|
520
|
22 return [i for i in subprocess.check_output(['find', directory, '-iname', pattern]).splitlines() if i.strip()]
|
|
23
|
519
|
24 def rejects(directory):
|
|
25 """all rejects in directory"""
|
|
26 # TODO: not call out to find
|
520
|
27 return find(directory, '*.rej')
|
519
|
28
|
|
29 def main(args=sys.argv[1:]):
|
|
30
|
|
31 usage = '%prog [options]'
|
|
32 parser = optparse.OptionParser(usage=usage, description=__doc__)
|
|
33 parser.add_option('-d', '--directory', default=os.getcwd())
|
|
34 options, args = parser.parse_args(args)
|
|
35
|
520
|
36 # get rejects
|
|
37 rej = rejects(options.directory)
|
|
38 if not rej:
|
|
39 parser.error("No rejects")
|
|
40 print 'rej:\n%s\n' % '\n'.join([' %s' % r for r in rej])
|
|
41
|
|
42 for r in rej:
|
|
43 # find the corresponding file
|
|
44 pass
|
519
|
45
|
|
46 if __name__ == '__main__':
|
|
47 main()
|