# HG changeset patch # User Jeff Hammel # Date 1273197353 25200 # Node ID 769447f8cd080ffdddf5d91c3f42a57b53a9fe80 # Parent 34c740d1962dd732d8954519c7838f7b1bfd1b36 cleanup diff -r 34c740d1962d -r 769447f8cd08 profilemanager/manager.py --- a/profilemanager/manager.py Thu May 06 18:53:24 2010 -0700 +++ b/profilemanager/manager.py Thu May 06 18:55:53 2010 -0700 @@ -104,7 +104,7 @@ dest = '%s.%s' % (self.hash(), dest) dest = os.path.join(self.profile_dir, dest) - # ensure name is not already present + assert name not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) # update profiles.ini @@ -171,19 +171,27 @@ """ add a profile entry to profiles.ini """ - assert name not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) + + # ensure name is not already present + assert profile not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) parser = self.parser() + + # find and add the section ctr = 0 section = 'Profile%d' % ctr # unsure of this naming convention while section in parser.sections(): ctr += 1 section = 'Profile%d' % ctr parser.add_section(section) + + # add metadata parser.set(section, 'Name', profile) parser.set(section, 'IsRelative', '%d' % int(relative)) parser.set(section, 'Path', relative and dirname or path) if not ctr: parser.set(section, 'Default', '1') + + # write the file parser.write(file(self.profiles, 'w'))