# HG changeset patch # User Jeff Hammel # Date 1273189632 25200 # Node ID 5988a15da3b4b4b0958d9d1a39422fc4f0ad27c9 # Parent d260de170ccacf36a9655597787078f0bbfe9cc8 things are being awful; checking in anyway diff -r d260de170cca -r 5988a15da3b4 profilemanager/manager.py --- a/profilemanager/manager.py Thu May 06 15:48:20 2010 -0700 +++ b/profilemanager/manager.py Thu May 06 16:47:12 2010 -0700 @@ -184,16 +184,6 @@ return os.path.join(self.profile_dir, profile['path']) return profile['path'] - def profile_dict(self, profile): - """ - return option dictionary for a single profile - """ - parser = self.parser() - section = self.section(profile, parser) - if section is None: - raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles)) - return dict(parser.items(section)) - def section(self, profile, parser=None): """ returns the name of the section that a profile is in or None @@ -207,6 +197,16 @@ if parser.get(section, 'name') == profile: return section + def profile_dict(self, profile): + """ + return option dictionary for a single profile + """ + parser = self.parser() + section = self.section(profile, parser) + if section is None: + raise ProfileNotFound('Profile %s not found in %s' % (profile, self.profiles)) + return dict(parser.items(section)) + def profiles_dict(self): """ return nested dict of all profiles diff -r d260de170cca -r 5988a15da3b4 profilemanager/tests/test.py --- a/profilemanager/tests/test.py Thu May 06 15:48:20 2010 -0700 +++ b/profilemanager/tests/test.py Thu May 06 16:47:12 2010 -0700 @@ -13,7 +13,8 @@ if test.endswith('.txt') ] for test in tests: - doctest.testfile(test) + doctest.testfile(test, raise_on_error=True) if __name__ == '__main__': run_tests() + diff -r d260de170cca -r 5988a15da3b4 profilemanager/tests/test_profilemanager.txt --- a/profilemanager/tests/test_profilemanager.txt Thu May 06 15:48:20 2010 -0700 +++ b/profilemanager/tests/test_profilemanager.txt Thu May 06 16:47:12 2010 -0700 @@ -9,15 +9,29 @@ Get the path to the test profiles.ini file: >>> from pkg_resources import resource_filename - >>> path = os.path.join('tests', 'profiles', 'profiles.ini') + >>> profiles_dir = os.path.join('test', 'profiles') + >>> path = os.path.join(profiles_dir, 'profiles.ini') >>> profiles = resource_filename('profilemanager', path) + >>> print profiles + >>> profiles_dir = resource_filename('profilemanager', profiles_dir) + >>> os.path.exists(profiles) + True + >>> os.path.exists(profiles_dir) + True Instatiate a ProfileManager: >>> manager = ProfileManager(profiles) -(I should delete any existing profiles at this point, but instead I'll -defer this to later.) +Remove any profiles that didn't get cleaned up: + + >>> profiles_dict = manager.profiles_dict() + >>> for profile in profiles_dict: + ... manager.remove(profile) + >>> os.listdir(profiles_dir) + ['profiles.ini'] + >>> file(profiles).read().strip() + '[General]' Create a new profile: