annotate python/applyrealhard.py @ 519:8b990efa4648

python/applyrealhard.py
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 20 Sep 2013 08:23:41 -0700
parents
children 3281b9fe4433
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
519
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 # XXX STUB
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 http://code.google.com/p/python-patch/
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 """
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 import difflib
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 import optparse
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import os
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 import subprocess
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 import sys
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 from which import which
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 here = os.path.dirname(os.path.realpath(__file__))
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 wiggle = which('wiggle')
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 def find(directory, pattern):
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 # TODO: -> python
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 return [i for i in subprocess.check_output(['find', directory, '-iname', patten]).splitlines() if i.strip()]
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 def rejects(directory):
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 """all rejects in directory"""
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 # TODO: not call out to find
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 def main(args=sys.argv[1:]):
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31 usage = '%prog [options]'
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 parser = optparse.OptionParser(usage=usage, description=__doc__)
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33 parser.add_option('-d', '--directory', default=os.getcwd())
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
34 options, args = parser.parse_args(args)
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
37
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
38 if __name__ == '__main__':
8b990efa4648 python/applyrealhard.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
39 main()