Mercurial > mozilla > hg > ProfileManager
comparison profilemanager/manager.py @ 45:6feee8d04db4
even more cleanup
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 06 May 2010 19:02:30 -0700 |
parents | 49cc40572f46 |
children | df1b2e48dddb |
comparison
equal
deleted
inserted
replaced
44:8eb997fd6e79 | 45:6feee8d04db4 |
---|---|
86 def clone(self, source, dest, add=True): | 86 def clone(self, source, dest, add=True): |
87 """ | 87 """ |
88 clones the profile `source` and output to `dest` | 88 clones the profile `source` and output to `dest` |
89 - add: add the profile to the profiles.ini file | 89 - add: add the profile to the profiles.ini file |
90 """ | 90 """ |
91 source_path = self.path(source) # fs path of the `from` profile | 91 |
92 # filesystem path of the `from` profile | |
93 source_path = self.path(source) | |
92 | 94 |
93 # dest: fs path to back up to | 95 # dest: fs path to back up to |
94 relative = False | 96 relative = False |
95 if os.path.sep in dest: | 97 if os.path.sep in dest: |
96 if not os.path.isabs(dest): | 98 if not os.path.isabs(dest): |
102 relative = True | 104 relative = True |
103 if not os.path.dirname(dest): | 105 if not os.path.dirname(dest): |
104 dest = '%s.%s' % (self.hash(), dest) | 106 dest = '%s.%s' % (self.hash(), dest) |
105 dest = os.path.join(self.profile_dir, dest) | 107 dest = os.path.join(self.profile_dir, dest) |
106 | 108 |
107 | |
108 assert name not in self.profiles_dict(), 'Profile "%s" already in %s' % (name, self.profiles) | |
109 | |
110 # update profiles.ini | 109 # update profiles.ini |
111 if add: | 110 if add: |
112 self.add(name, dirname, relative) | 111 self.add(name, dirname, relative) |
113 | 112 |
114 # copy the files | 113 # copy the files |
122 - profile: name of the profile to be backed up | 121 - profile: name of the profile to be backed up |
123 - dest: name of the destination (optional) | 122 - dest: name of the destination (optional) |
124 """ | 123 """ |
125 if dest is None: | 124 if dest is None: |
126 dest = '%s.%d.bak' % (profile, int(time.time())) | 125 dest = '%s.%d.bak' % (profile, int(time.time())) |
127 self.clone(profile, dest, hash=False) | 126 self.clone(profile, dest, add=False) |
128 # TODO: add something like | 127 # TODO: add something like |
129 # `Backup=$(profile)s.$(datestamp)s.bak` | 128 # `Backup=$(profile)s.$(datestamp)s.bak` |
130 # to self.profiles | 129 # to self.profiles |
131 | 130 |
132 def backups(self, profile=None): | 131 def backups(self, profile=None): |