~ubuntu-branches/ubuntu/raring/duplicity/raring-updates

« back to all changes in this revision

Viewing changes to src/tarfile.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-04-03 20:40:34 UTC
  • mfrom: (1.9.1 upstream) (16.2.6 natty)
  • Revision ID: james.westby@ubuntu.com-20110403204034-5m1eri4z5qr0nyrr
Tags: 0.6.13-0ubuntu1
* Resync with Debian, no remaining changes
* New upstream release
  - silent data corruption with checkpoint/restore (LP: #613244)
  - Assertion error "time not moving forward at appropriate pace"
    (LP: #579958)
* debian/patches/04future.dpatch:
  - Dropped, applied upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
 
187
187
    BUFSIZE = 16 * 1024
188
188
    blocks, remainder = divmod(length, BUFSIZE)
189
 
    for b in range(blocks):
 
189
    for b in range(blocks): #@UnusedVariable
190
190
        buf = src.read(BUFSIZE)
191
191
        if len(buf) < BUFSIZE:
192
192
            raise IOError, "end of file reached"
332
332
        self.devmajor = 0          #-
333
333
        self.devminor = 0          #-for use with CHRTYPE and BLKTYPE
334
334
        self.prefix   = ""         # prefix, holding information
335
 
                                   # about sparse files
 
335
#                                  # about sparse files
336
336
 
337
337
        self.offset   = 0          # the tar header starts here
338
338
        self.offset_data = 0       # the optional file's data starts here
378
378
        turned to relative paths.
379
379
        """
380
380
        arcname = normpath(name)
381
 
        drv, arcname = os.path.splitdrive(arcname)
 
381
        drv, arcname = os.path.splitdrive(arcname) #@UnusedVariable
382
382
        while arcname[0:1] == "/":
383
383
            arcname = arcname[1:]
384
384
        self.name = arcname
504
504
            if self._mode in "aw":
505
505
                # fill up the end with zero-blocks
506
506
                # (like option -b20 for tar does)
507
 
                blocks, remainder = divmod(self.offset, RECORDSIZE)
 
507
                blocks, remainder = divmod(self.offset, RECORDSIZE) #@UnusedVariable
508
508
                if remainder > 0:
509
509
                    self.fileobj.write("\0" * (RECORDSIZE - remainder))
510
510
 
975
975
            linkpath = normpath(linkpath)
976
976
            try:
977
977
                self._extract_member(self.getmember(linkpath), targetpath)
978
 
            except (IOError, OSError, KeyError), e:
 
978
            except (IOError, OSError, KeyError), e: #@UnusedVariable
979
979
                linkpath = os.path.normpath(linkpath)
980
980
                try:
981
981
                    shutil.copy2(linkpath, targetpath)
982
 
                except EnvironmentError, e:
 
982
                except EnvironmentError, e: #@UnusedVariable
983
983
                    raise TarError, "Link could not be created"
984
984
 
985
985
    def _chown(self, tarinfo, targetpath):
1084
1084
        if tarinfo.chksum != calc_chksum(buf):
1085
1085
            self._dbg(1, "tarfile: Bad Checksum\n")
1086
1086
        return tarinfo
1087
 
        
 
1087
 
1088
1088
    def _proc_gnulong(self, tarinfo, type):
1089
1089
        """Evaluate the blocks that hold a GNU longname
1090
1090
           or longlink member.
1147
1147
        try:
1148
1148
            # There are 4 possible sparse structs in the
1149
1149
            # first header.
1150
 
            for i in range(4):
 
1150
            for i in range(4): #@UnusedVariable
1151
1151
                offset = int(buf[pos:pos + 12], 8)
1152
1152
                numbytes = int(buf[pos + 12:pos + 24], 8)
1153
1153
                if offset > lastpos:
1166
1166
                buf = self.fileobj.read(BLOCKSIZE)
1167
1167
                self.offset += BLOCKSIZE
1168
1168
                pos = 0
1169
 
                for i in range(21):
 
1169
                for i in range(21): #@UnusedVariable
1170
1170
                    offset = int(buf[pos:pos + 12], 8)
1171
1171
                    numbytes = int(buf[pos + 12:pos + 24], 8)
1172
1172
                    if offset > lastpos:
1419
1419
        else:
1420
1420
            raise ValueError, "unknown compression constant"
1421
1421
        if mode[0:1] == "r":
1422
 
            import time
1423
1422
            members = self.tarfile.getmembers()
1424
1423
            for i in range(len(members)):
1425
1424
                m = members[i]
1518
1517
        # If under Win32, set stdout to binary.
1519
1518
        try:
1520
1519
            import msvcrt
1521
 
            msvcrt.setmode(1, os.O_BINARY)
 
1520
            msvcrt.setmode(1, os.O_BINARY) #@UndefinedVariable
1522
1521
        except ImportError:
1523
1522
            pass
1524
1523
        tarfile = func("sys.stdout.tar", mode, 9, sys.stdout)
1604
1603
            self.buffer = self.buffer[length:]
1605
1604
        self.tar_iter_offset += len(result)
1606
1605
        return result
1607
 
        
 
1606
 
1608
1607
    def _addtobuffer(self):
1609
1608
        """Write more data into the buffer.  Return None if at end"""
1610
1609
        if self.status == self.BEGIN:
1662
1661
 
1663
1662
    def _add_final(self):
1664
1663
        """Add closing footer to buffer"""
1665
 
        blocks, remainder = divmod(self.offset, RECORDSIZE)
 
1664
        blocks, remainder = divmod(self.offset, RECORDSIZE) #@UnusedVariable
1666
1665
        if remainder > 0: self.buffer += "\0" * (RECORDSIZE - remainder)
1667
1666
 
1668
1667
    def close(self):