Mercurial > mozilla > hg > ProfileManager
diff 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 |
line wrap: on
line diff
--- a/profilemanager/manager.py Mon Apr 05 13:10:31 2010 -0700 +++ b/profilemanager/manager.py Mon Apr 05 13:53:22 2010 -0700 @@ -15,13 +15,27 @@ def __init__(self, profiles): """ - - profiles: profiles.ini file + - profiles: filesystem path to profiles.ini file """ self.profiles = profiles - self.profile_dir = '' + self.profile_dir = os.path.abspath(os.path.dirname(profiles)) ### (public) API + def list(self, directories=False): + """ + lists the profiles available in the config file + """ + from ConfigParser import SafeConfigParser as ConfigParser + parser = ConfigParser() + parser.read(self.profiles) + names = [] + for section in parser.sections(): + if section == 'General': + continue + names.append(parser.get(section, 'name')) + return '\n'.join(names) + def clone(self, source, dest): """ clones the profile `source` and output to `dest`