~ubuntu-branches/ubuntu/wily/python-imaging/wily

« back to all changes in this revision

Viewing changes to PIL/TarIO.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-31 20:49:20 UTC
  • mfrom: (27.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130131204920-b5zshy6vgfvdionl
Tags: 1.1.7+1.7.8-1ubuntu1
Rewrite build dependencies to allow cross builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# See the README file for information on usage and redistribution.
15
15
#
16
16
 
17
 
import ContainerIO
18
 
import string
 
17
from . import ContainerIO
19
18
 
20
19
##
21
20
# A file object that provides read access to a given member of a TAR
33
32
 
34
33
        fh = open(tarfile, "rb")
35
34
 
36
 
        while 1:
 
35
        while True:
37
36
 
38
37
            s = fh.read(512)
39
38
            if len(s) != 512:
40
 
                raise IOError, "unexpected end of tar file"
 
39
                raise IOError("unexpected end of tar file")
41
40
 
42
 
            name = s[:100]
43
 
            i = string.find(name, chr(0))
 
41
            name = s[:100].decode('utf-8')
 
42
            i = name.find('\0')
44
43
            if i == 0:
45
 
                raise IOError, "cannot find subfile"
 
44
                raise IOError("cannot find subfile")
46
45
            if i > 0:
47
46
                name = name[:i]
48
47
 
49
 
            size = string.atoi(s[124:136], 8)
 
48
            size = int(s[124:135], 8)
50
49
 
51
50
            if file == name:
52
51
                break