annotate paint/main.py @ 13:0dd1f8f83be2

moving towards some sort of organization
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 24 Feb 2012 15:39:42 -0800
parents 583f678eb0c9
children 8beffeb750b3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 python PAckage INTrospection
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 import sys
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import optparse
2
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
9 import tempfile
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
10
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
11 class InspectPackages(object):
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
12 def __init__(self):
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
13 pass
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
14
3
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
15 def dependencies(self, *packages):
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
16 if len(packages) > 1:
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
17 retval = set()
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
18 for package in packages:
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
19 retval += self.dependencies(package)
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
20 else:
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
21 raise NotImplementedError
583f678eb0c9 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
22
2
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
23 def cleanup(self):
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
24 pass
4be44827e436 stubbing
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
25 __del__ = cleanup
0
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 def main(args=sys.argv[:]):
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28
1
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
29 # parse command line options
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
30 usage = '%prog [options]'
0
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
31
1
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
32 # description formatter
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
33 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
34 def format_description(self, description):
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
35 if description:
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
36 return description + '\n'
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
37 else:
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
38 return ''
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
39
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
40 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
41 options, args = parser.parse_args(args)
0
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
42
96362e527bd6 initial package
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
43 if __name__ == '__main__':
1
a011af5e765a spacing
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
44 main()