~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/utils/config.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
        self.file_path = os.path.join(config_dir, name+'.pickle')
203
203
        self.refresh()
204
204
 
205
 
    def refresh(self):
 
205
    def decouple(self, prefix):
 
206
        self.file_path = os.path.join(os.path.dirname(self.file_path), prefix + os.path.basename(self.file_path))
 
207
        self.refresh(clear_current=False)
 
208
 
 
209
    def refresh(self, clear_current=True):
206
210
        d = {}
207
211
        if os.path.exists(self.file_path):
208
212
            with ExclusiveFile(self.file_path) as f:
216
220
                    print 'Failed to unpickle stored object:'
217
221
                    traceback.print_exc()
218
222
                    d = {}
219
 
        self.clear()
 
223
        if clear_current:
 
224
            self.clear()
220
225
        self.update(d)
221
226
 
222
227
    def __getitem__(self, key):
280
285
    def to_raw(self):
281
286
        return plistlib.writePlistToString(self)
282
287
 
283
 
    def refresh(self):
 
288
    def decouple(self, prefix):
 
289
        self.file_path = os.path.join(os.path.dirname(self.file_path), prefix + os.path.basename(self.file_path))
 
290
        self.refresh(clear_current=False)
 
291
 
 
292
    def refresh(self, clear_current=True):
284
293
        d = {}
285
294
        if os.path.exists(self.file_path):
286
295
            with ExclusiveFile(self.file_path) as f:
293
302
                    import traceback
294
303
                    traceback.print_exc()
295
304
                    d = {}
296
 
        self.clear()
 
305
        if clear_current:
 
306
            self.clear()
297
307
        self.update(d)
298
308
 
299
309
    def __getitem__(self, key):