annotate python/diffex.py @ 449:f39d37973d4b

python/setup_repo.py
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 10 Aug 2013 15:52:22 -0700
parents 95afeaf9c42d
children be91c9fb3147
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
446
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 """
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 diff before v after of executables (requires http://k0s.org/hg/config/file/f71f6ffa731a/python/lsex.py)
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 """
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import difflib
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 import lsex
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 import optparse
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import os
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 import subprocess
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 import sys
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 def add_options(parser):
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 """add options to the OptionParser instance"""
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 def main(args=sys.argv[1:]):
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 # parse command line options
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 usage = '%prog [options] ...'
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 """description formatter for console script entry point"""
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 def format_description(self, description):
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 if description:
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 return description.strip() + '\n'
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 else:
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 return ''
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 options, args = parser.parse_args(args)
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
32 # STUB
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
33 # before = lsex... # get executables before
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
34 # raw_input("Press [Enter] to continue")
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
35 # after = lsex... # get executables after
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
36 # difflib.diff() # get difference
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
37
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
38 if __name__ == '__main__':
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
39 main()
95afeaf9c42d -> http://k0s.org/portfolio/ideas/install_software_trifecta.txt
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
40