Mercurial > mozilla > hg > ProfileManager
comparison profilemanager/manager.py @ 4:35dc297efa25
adding listing function and other cleanup
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 05 Apr 2010 13:53:22 -0700 |
parents | 4d1cd60dd2a1 |
children | ca57920aa223 |
comparison
equal
deleted
inserted
replaced
3:4d1cd60dd2a1 | 4:35dc297efa25 |
---|---|
13 | 13 |
14 class ProfileManager(object): | 14 class ProfileManager(object): |
15 | 15 |
16 def __init__(self, profiles): | 16 def __init__(self, profiles): |
17 """ | 17 """ |
18 - profiles: profiles.ini file | 18 - profiles: filesystem path to profiles.ini file |
19 """ | 19 """ |
20 self.profiles = profiles | 20 self.profiles = profiles |
21 self.profile_dir = '' | 21 self.profile_dir = os.path.abspath(os.path.dirname(profiles)) |
22 | 22 |
23 ### (public) API | 23 ### (public) API |
24 | |
25 def list(self, directories=False): | |
26 """ | |
27 lists the profiles available in the config file | |
28 """ | |
29 from ConfigParser import SafeConfigParser as ConfigParser | |
30 parser = ConfigParser() | |
31 parser.read(self.profiles) | |
32 names = [] | |
33 for section in parser.sections(): | |
34 if section == 'General': | |
35 continue | |
36 names.append(parser.get(section, 'name')) | |
37 return '\n'.join(names) | |
24 | 38 |
25 def clone(self, source, dest): | 39 def clone(self, source, dest): |
26 """ | 40 """ |
27 clones the profile `source` and output to `dest` | 41 clones the profile `source` and output to `dest` |
28 """ | 42 """ |