comparison profilemanager/manager.py @ 21:15484adb9758

note what section a a profile is in
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 May 2010 15:24:50 -0700
parents 49d523a33c89
children 956f5a4c589a
comparison
equal deleted inserted replaced
20:49d523a33c89 21:15484adb9758
75 def remove(self, name, delete=True): 75 def remove(self, name, delete=True):
76 """ 76 """
77 remove a profile from profiles.ini 77 remove a profile from profiles.ini
78 - delete: delete the profile directory as well 78 - delete: delete the profile directory as well
79 """ 79 """
80 raise NotImplementedError 80 section = self.section(name)
81 if section is None:
82 raise ProfileNotFound
81 83
82 def list(self, directories=False): 84 def list(self, directories=False):
83 """ 85 """
84 lists the profiles available in the config file 86 lists the profiles available in the config file
85 - directories : display the directories 87 - directories : display the directories
184 return dict(parser.items(section)) 186 return dict(parser.items(section))
185 raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles)) 187 raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles))
186 188
187 def section(self, profile): 189 def section(self, profile):
188 """ 190 """
189 returns the name of the section that a profile is in 191 returns the name of the section that a profile is in or None
190 """ 192 if not found
193 """
194 parser = ConfigParser()
195 parser.read(self.profiles)
196 for section in parser.section():
197 if not parser.has_option(section, 'name'):
198 continue # not a profile
199 if parser.get(section, 'name') == profile:
200 return section
191 201
192 def profiles_dict(self): 202 def profiles_dict(self):
193 """ 203 """
194 return nested dict of all profiles 204 return nested dict of all profiles
195 """ 205 """