~mterry/duplicity/list-old-chains-0.6

« back to all changes in this revision

Viewing changes to duplicity/path.py

  • Committer: loafman
  • Date: 2008-12-22 17:22:44 UTC
  • Revision ID: vcs-imports@canonical.com-20081222172244-cjurdc0mt5d41n6d
patch #6700: Make duplicity translatable
https://savannah.nongnu.org/patch/?6700

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
            ti.mode = self.mode
257
257
            ti.uid, ti.gid = self.stat.st_uid, self.stat.st_gid
258
258
            if self.stat.st_mtime < 0:
259
 
                log.Warn("Warning: %s has negative mtime, treating as 0."
 
259
                log.Warn(_("Warning: %s has negative mtime, treating as 0.")
260
260
                         % (self.get_relative_path(),))
261
261
                ti.mtime = 0
262
262
            else:
321
321
 
322
322
        """
323
323
        def log_diff(log_string):
324
 
            log_str = "Difference found: " + log_string
 
324
            log_str = _("Difference found:") + " " + log_string
325
325
            log.Log(log_str % (self.get_relative_path(),), 4)
326
326
 
327
327
        if not self.type and not other.type:
328
328
            return 1
329
329
        if not self.stat and other.stat:
330
 
            log_diff("New file %s")
 
330
            log_diff(_("New file %s"))
331
331
            return 0
332
332
        if not other.stat and self.stat:
333
 
            log_diff("File %s is missing")
 
333
            log_diff(_("File %s is missing"))
334
334
            return 0
335
335
        if self.type != other.type:
336
 
            log_diff("File %%s has type %s, expected %s" %
 
336
            log_diff(_("File %%s has type %s, expected %s") %
337
337
                     (other.type, self.type))
338
338
            return 0
339
339
 
340
340
        if self.isreg() or self.isdir() or self.isfifo():
341
341
            if not self.perms_equal(other):
342
 
                log_diff("File %%s has permissions %o, expected %o" %
 
342
                log_diff(_("File %%s has permissions %o, expected %o") %
343
343
                         (other.getperms(), self.getperms()))
344
344
                return 0
345
345
            if ((int(self.stat.st_mtime) != int(other.stat.st_mtime)) and
346
346
                (self.stat.st_mtime > 0 or other.stat.st_mtime > 0)):
347
 
                log_diff("File %%s has mtime %s, expected %s" %
 
347
                log_diff(_("File %%s has mtime %s, expected %s") %
348
348
                         (dup_time.timetopretty(int(other.stat.st_mtime)),
349
349
                          dup_time.timetopretty(int(self.stat.st_mtime))))
350
350
                return 0
352
352
                if self.compare_data(other):
353
353
                    return 1
354
354
                else:
355
 
                    log_diff("Data for file %s is different")
 
355
                    log_diff(_("Data for file %s is different"))
356
356
                    return 0
357
357
            else:
358
358
                return 1
360
360
            if self.symtext == other.symtext:
361
361
                return 1
362
362
            else:
363
 
                log_diff("Symlink %%s points to %s, expected %s" %
 
363
                log_diff(_("Symlink %%s points to %s, expected %s") %
364
364
                         (other.symtext, self.symtext))
365
365
                return 0
366
366
        elif self.isdev():
367
367
            if not self.perms_equal(other):
368
 
                log_diff("File %%s has permissions %o, expected %o" %
 
368
                log_diff(_("File %%s has permissions %o, expected %o") %
369
369
                         (other.getperms(), self.getperms()))
370
370
                return 0
371
371
            if self.devnums != other.devnums:
372
 
                log_diff("Device file %%s has numbers %s, expected %s"
 
372
                log_diff(_("Device file %%s has numbers %s, expected %s")
373
373
                         % (other.devnums, self.devnums))
374
374
                return 0
375
375
            return 1
515
515
 
516
516
    def mkdir(self):
517
517
        """Make a directory at specified path"""
518
 
        log.Log("Making directory %s" % (self.name,), 7)
 
518
        log.Log(_("Making directory %s") % (self.name,), 7)
519
519
        try:
520
520
            os.mkdir(self.name)
521
521
        except OSError:
525
525
 
526
526
    def delete(self):
527
527
        """Remove this file"""
528
 
        log.Log("Deleting %s" % (self.name,), 7)
 
528
        log.Log(_("Deleting %s") % (self.name,), 7)
529
529
        if self.isdir():
530
530
            os.rmdir(self.name)
531
531
        else:
534
534
 
535
535
    def touch(self):
536
536
        """Open the file, write 0 bytes, close"""
537
 
        log.Log("Touching %s" % (self.name,), 7)
 
537
        log.Log(_("Touching %s") % (self.name,), 7)
538
538
        fp = self.open("wb")
539
539
        fp.close()
540
540
 
541
541
    def deltree(self):
542
542
        """Remove self by recursively deleting files under it"""
543
543
        import duplicity.selection as selection # todo: avoid circ. dep. issue
544
 
        log.Log("Deleting tree %s" % (self.name,), 7)
 
544
        log.Log(_("Deleting tree %s") % (self.name,), 7)
545
545
        itr = IterTreeReducer(PathDeleter, [])
546
546
        for path in selection.Select(self).set_iter():
547
547
            itr(path.index, path)