# HG changeset patch # User Jeff Hammel # Date 1270570745 25200 # Node ID 2a3f5cdfd60c4f2b078caa7808db0e7952248e8a # Parent ca57920aa223c5a1bdb90681e8220322b3ee3030 flush out helper functions and list directories diff -r ca57920aa223 -r 2a3f5cdfd60c profilemanager/manager.py --- a/profilemanager/manager.py Tue Apr 06 08:04:24 2010 -0700 +++ b/profilemanager/manager.py Tue Apr 06 09:19:05 2010 -0700 @@ -27,15 +27,20 @@ def list(self, directories=False): """ lists the profiles available in the config file + - directories : display the directories """ parser = ConfigParser() parser.read(self.profiles) - names = [] + retval = [] for section in parser.sections(): if section == 'General': continue - names.append((parser.get(section, 'name'),)) - return format_tabular(names) + name = parser.get(section, 'name') + values = [name] + if directories: + values.append(self.path(name)) + retval.append(values) + return format_tabular(retval) def clone(self, source, dest): """ @@ -79,9 +84,17 @@ def path(self, profile): """returns the path to the profile""" + profile = self.profile_dict(profile) + if profile.get('isrelative', None) == '1': + return os.path.join(self.profile_dir, profile['path']) + return profile['path'] def profile_dict(self, profile): parser = ConfigParser() parser.read(self.profiles) for section in parser.sections(): - raise NotImplementedError + if not parser.has_option(section, 'name'): + continue # not a profile + if parser.get(section, 'name') == profile: + return dict(parser.items(section)) + raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles))