Mercurial > mozilla > hg > ProfileManager
comparison profilemanager/manager.py @ 10:c77e9bef78d6
* update list of public API functions
* further flushing out of profile manager
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 05 May 2010 17:08:47 -0700 |
parents | b1274abd1206 |
children | 543d08958b67 |
comparison
equal
deleted
inserted
replaced
9:b1274abd1206 | 10:c77e9bef78d6 |
---|---|
5 import os | 5 import os |
6 import shutil | 6 import shutil |
7 import ConfigParser | 7 import ConfigParser |
8 from utils import format_tabular | 8 from utils import format_tabular |
9 from ConfigParser import SafeConfigParser as ConfigParser | 9 from ConfigParser import SafeConfigParser as ConfigParser |
10 | |
11 # Changes to profiles.ini: | |
12 # - add a ``backups`` field for each profile: | |
13 # Backups = /path/to/backup:1273104310 /path/to/other/backup:1273104355 | |
10 | 14 |
11 class ProfileNotFound(Exception): | 15 class ProfileNotFound(Exception): |
12 """ | 16 """ |
13 exception when a profile is specified but is not present in a given | 17 exception when a profile is specified but is not present in a given |
14 .ini file | 18 .ini file |
44 if directories: | 48 if directories: |
45 values.append(self.path(name)) | 49 values.append(self.path(name)) |
46 retval.append(values) | 50 retval.append(values) |
47 return format_tabular(retval) | 51 return format_tabular(retval) |
48 | 52 |
49 def backups(self, profile=None): | |
50 """ | |
51 list backups for a given profile, or all profiles if the | |
52 profile is not given; returns a list of backups if | |
53 profile is given or a dictionary of lists otherwise | |
54 """ | |
55 if profile is None: | |
56 # all profiles | |
57 retval = {} | |
58 return retval | |
59 # TODO | |
60 | |
61 def clone(self, source, dest, hash=True): | 53 def clone(self, source, dest, hash=True): |
62 """ | 54 """ |
63 clones the profile `source` and output to `dest` | 55 clones the profile `source` and output to `dest` |
64 """ | 56 """ |
65 source_path = self.path(source) # fs path of the `from` profile | 57 source_path = self.path(source) # fs path of the `from` profile |
88 self.clone(profile, dest, hash=False) | 80 self.clone(profile, dest, hash=False) |
89 # TODO: add something like | 81 # TODO: add something like |
90 # `Backup=$(profile)s.$(datestamp)s.bak` | 82 # `Backup=$(profile)s.$(datestamp)s.bak` |
91 # to self.profiles | 83 # to self.profiles |
92 | 84 |
85 def backups(self, profile=None): | |
86 """ | |
87 list backups for a given profile, or all profiles if the | |
88 profile is not given; returns a list of backups if | |
89 profile is given or a dictionary of lists otherwise | |
90 """ | |
91 if profile is None: | |
92 # all profiles | |
93 retval = {} | |
94 return retval | |
95 # TODO | |
96 | |
93 def restore(self, profile, date=None, delete=False): | 97 def restore(self, profile, date=None, delete=False): |
94 """ | 98 """ |
95 restore the profile from a backup | 99 restore the profile from a backup |
96 the most recent backup is used unless `date` is given | 100 the most recent backup is used unless `date` is given |
97 - date : date to restore from | 101 - date : date to restore from |
98 - delete : delete the backup after restoration | 102 - delete : delete the backup after restoration |
99 """ | 103 """ |
100 | 104 |
101 # get the possible backups | 105 # get the possible backups |
102 # TODO | 106 backups = self.backups(profile) |
107 # TODO: check to see if these all exist (print warnings if not) | |
103 | 108 |
104 # restore the backup over ``profile`` | 109 # restore the backup over ``profile`` |
105 | 110 |
106 if delete: # delete the backup | 111 if delete: # delete the backup |
107 pass | 112 # delete the directory |
113 # delete the entry from ``profiles.ini`` | |
114 # if there are no backups, delete the ``backups`` line | |
115 pass #TODO | |
116 | |
108 | 117 |
109 def merge(self, output, *profiles): | 118 def merge(self, output, *profiles): |
110 """merge a set of profiles (not trivial!)""" | 119 """merge a set of profiles (not trivial!)""" |
111 raise NotImplementedError | 120 raise NotImplementedError |
112 | 121 |