comparison profilemanager/manager.py @ 5:ca57920aa223

adding better formatting for list
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 06 Apr 2010 08:04:24 -0700
parents 35dc297efa25
children 2a3f5cdfd60c
comparison
equal deleted inserted replaced
4:35dc297efa25 5:ca57920aa223
2 manage Mozilla/Firefox profiles 2 manage Mozilla/Firefox profiles
3 """ 3 """
4 4
5 import os 5 import os
6 import shutil 6 import shutil
7 from utils import format_tabular
8 from ConfigParser import SafeConfigParser as ConfigParser
7 9
8 class ProfileNotFound(Exception): 10 class ProfileNotFound(Exception):
9 """ 11 """
10 exception when a profile is specified but is not present in a given 12 exception when a profile is specified but is not present in a given
11 .ini file 13 .ini file
24 26
25 def list(self, directories=False): 27 def list(self, directories=False):
26 """ 28 """
27 lists the profiles available in the config file 29 lists the profiles available in the config file
28 """ 30 """
29 from ConfigParser import SafeConfigParser as ConfigParser
30 parser = ConfigParser() 31 parser = ConfigParser()
31 parser.read(self.profiles) 32 parser.read(self.profiles)
32 names = [] 33 names = []
33 for section in parser.sections(): 34 for section in parser.sections():
34 if section == 'General': 35 if section == 'General':
35 continue 36 continue
36 names.append(parser.get(section, 'name')) 37 names.append((parser.get(section, 'name'),))
37 return '\n'.join(names) 38 return format_tabular(names)
38 39
39 def clone(self, source, dest): 40 def clone(self, source, dest):
40 """ 41 """
41 clones the profile `source` and output to `dest` 42 clones the profile `source` and output to `dest`
42 """ 43 """
68 """ 69 """
69 if delete: 70 if delete:
70 # delete the backup 71 # delete the backup
71 pass 72 pass
72 73
73 def merge(self, *profiles): 74 def merge(self, output, *profiles):
74 """merge a set of profiles (not trivial!)""" 75 """merge a set of profiles (not trivial!)"""
75 raise NotImplementedError 76 raise NotImplementedError
76 77
77 ### internal functions 78 ### internal functions
78 79
79 def path(self, profile): 80 def path(self, profile):
80 """returns the path to the profile""" 81 """returns the path to the profile"""
81 82
83 def profile_dict(self, profile):
84 parser = ConfigParser()
85 parser.read(self.profiles)
86 for section in parser.sections():
87 raise NotImplementedError