comparison profilemanager/manager.py @ 29:105ecbac0928

fix some test failures
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 06 May 2010 16:51:21 -0700
parents 5988a15da3b4
children d9886a7e8df7
comparison
equal deleted inserted replaced
28:d4f0c1c4d0eb 29:105ecbac0928
64 parser.set(section, 'Name', name) 64 parser.set(section, 'Name', name)
65 parser.set(section, 'IsRelative', '%d' % int(relative)) 65 parser.set(section, 'IsRelative', '%d' % int(relative))
66 parser.set(section, 'Path', relative and dirname or path) 66 parser.set(section, 'Path', relative and dirname or path)
67 if len(parser.sections()) == 1: 67 if len(parser.sections()) == 1:
68 parser.set(section, 'Default', '1') 68 parser.set(section, 'Default', '1')
69 parser.write(self.profiles) 69 parser.write(file(self.profiles, 'w'))
70 70
71 # return the directory name 71 # return the directory name
72 return dirname 72 return dirname
73 73
74 def remove(self, name, delete=True): 74 def remove(self, name, delete=True):
80 if section is None: 80 if section is None:
81 raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles)) 81 raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles))
82 if delete: # remove the profile from disk 82 if delete: # remove the profile from disk
83 shutil.rmtree(self.path(name)) 83 shutil.rmtree(self.path(name))
84 parser.remove_section(section) 84 parser.remove_section(section)
85 parser.write(self.profiles) 85 parser.write(file(self.profiles, 'w'))
86 86
87 def list(self, directories=False): 87 def list(self, directories=False):
88 """ 88 """
89 lists the profiles available in the config file 89 lists the profiles available in the config file
90 - directories : display the directories 90 - directories : display the directories
188 """ 188 """
189 returns the name of the section that a profile is in or None 189 returns the name of the section that a profile is in or None
190 if not found 190 if not found
191 """ 191 """
192 if parser is None: 192 if parser is None:
193 self.parser() 193 parser = self.parser()
194 for section in parser.section(): 194 for section in parser.section():
195 if not parser.has_option(section, 'name'): 195 if not parser.has_option(section, 'name'):
196 continue # not a profile 196 continue # not a profile
197 if parser.get(section, 'name') == profile: 197 if parser.get(section, 'name') == profile:
198 return section 198 return section