~krissn/duplicity/xattr-selection-support

« back to all changes in this revision

Viewing changes to duplicity/util.py

  • Committer: Kenneth Loafman
  • Date: 2011-10-05 14:13:31 UTC
  • mfrom: (777.1.9 duplicity.tarfile)
  • Revision ID: kenneth@loafman.com-20111005141331-1butbl95nwt5czon
MergedĀ inĀ lp:~mterry/duplicity/tarfile

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import string
29
29
import traceback
30
30
 
 
31
from duplicity import tarfile
 
32
 
31
33
import duplicity.globals as globals
32
34
import duplicity.log as log
33
35
 
69
71
        else:
70
72
            raise
71
73
 
 
74
class FakeTarFile:
 
75
    debug = 0
 
76
    def __iter__(self):
 
77
        return iter([])
 
78
    def close(self):
 
79
        pass
 
80
 
 
81
def make_tarfile(mode, fp):
 
82
    # We often use 'empty' tarfiles for signatures that haven't been filled out
 
83
    # yet.  So we want to ignore ReadError exceptions, which are used to signal
 
84
    # this.
 
85
    try:
 
86
        return tarfile.TarFile("arbitrary", mode, fp)
 
87
    except tarfile.ReadError:
 
88
        return FakeTarFile()
 
89
 
 
90
def get_tarinfo_name(ti):
 
91
    # Python versions before 2.6 ensure that directories end with /, but 2.6
 
92
    # and later ensure they they *don't* have /.  ::shrug::  Internally, we
 
93
    # continue to use pre-2.6 method.
 
94
    if ti.isdir() and not ti.name.endswith("/"):
 
95
        return ti.name + "/"
 
96
    else:
 
97
        return ti.name
 
98
 
72
99
def ignore_missing(fn, filename):
73
100
    """
74
101
    Execute fn on filename.  Ignore ENOENT errors, otherwise raise exception.