annotate profilemanager/main.py @ 5:ca57920aa223

adding better formatting for list
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 06 Apr 2010 08:04:24 -0700
parents 35dc297efa25
children c77e9bef78d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 import os
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 import sys
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 from manager import ProfileManager
1
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
7 from command import CommandParser
0
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8
1
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
9 def create_profilemanager(parser, options):
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
10 """create the profile manager from parsed arguments"""
0
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 if options.config is None:
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 # XXX unix-specific
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 options.config = os.path.join(os.environ['HOME'], '.mozilla/firefox/profiles.ini')
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 if not os.path.exists(options.config):
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 parser.error('%s does not exist' % options.config)
1
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
16 return ProfileManager(options.config)
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
17
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
18 def main(args=sys.argv[1:]):
0
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19
1
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
20 # global option parsing
4
35dc297efa25 adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
21 commands = [ ProfileManager.backup,
35dc297efa25 adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
22 ProfileManager.clone,
35dc297efa25 adding listing function and other cleanup
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
23 ProfileManager.list,
1
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
24 ProfileManager.restore,
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
25 ProfileManager.merge ]
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
26 parser = CommandParser(commands, setup=create_profilemanager)
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
27 parser.add_option('-c', '--config', dest='config',
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
28 help="specify a profile.ini [default: $HOME/.mozilla/firefox/profiles.ini]")
979315ed0816 mucho cleanup on optionparser stuff
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
29 parser.invoke(args)
0
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 if __name__ == '__main__':
7301d534bc6c initial messy and incomplete strawman prototype for Mozilla (Firefox) profile management
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
32 main()