Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13912 - main/trunk/pym/portage
Date: Tue, 04 Aug 2009 23:19:49
Message-Id: E1MYTIH-0007oq-QI@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-08-04 23:19:45 +0000 (Tue, 04 Aug 2009)
3 New Revision: 13912
4
5 Modified:
6 main/trunk/pym/portage/xpak.py
7 Log:
8 Open all files in binary mode for py3k compatibility.
9
10
11 Modified: main/trunk/pym/portage/xpak.py
12 ===================================================================
13 --- main/trunk/pym/portage/xpak.py 2009-08-04 23:07:57 UTC (rev 13911)
14 +++ main/trunk/pym/portage/xpak.py 2009-08-04 23:19:45 UTC (rev 13912)
15 @@ -68,14 +68,14 @@
16 mylist.sort()
17 mydata = {}
18 for x in mylist:
19 - a = open(x, "r")
20 + a = open(x, 'rb')
21 mydata[x] = a.read()
22 a.close()
23 os.chdir(origdir)
24
25 xpak_segment = xpak_mem(mydata)
26 if outfile:
27 - outf = open(outfile, "w")
28 + outf = open(outfile, 'wb')
29 outf.write(xpak_segment)
30 outf.close()
31 else:
32 @@ -104,7 +104,7 @@
33 """(infile) -- Splits the infile into two files.
34 'infile.index' contains the index segment.
35 'infile.dat' contails the data segment."""
36 - myfile=open(infile,"r")
37 + myfile = open(infile, 'rb')
38 mydat=myfile.read()
39 myfile.close()
40
41 @@ -112,10 +112,10 @@
42 if not splits:
43 return False
44
45 - myfile=open(infile+".index","w")
46 + myfile = open(infile + '.index', 'wb')
47 myfile.write(splits[0])
48 myfile.close()
49 - myfile=open(infile+".dat","w")
50 + myfile = open(infile + '.dat', 'wb')
51 myfile.write(splits[1])
52 myfile.close()
53 return True
54 @@ -130,7 +130,7 @@
55
56 def getindex(infile):
57 """(infile) -- grabs the index segment from the infile and returns it."""
58 - myfile=open(infile,"r")
59 + myfile = open(infile, 'rb')
60 myheader=myfile.read(16)
61 if myheader[0:8]!="XPAKPACK":
62 myfile.close()
63 @@ -143,7 +143,7 @@
64 def getboth(infile):
65 """(infile) -- grabs the index and data segments from the infile.
66 Returns an array [indexSegment,dataSegment]"""
67 - myfile=open(infile,"r")
68 + myfile = open(infile, 'rb')
69 myheader=myfile.read(16)
70 if myheader[0:8]!="XPAKPACK":
71 myfile.close()
72 @@ -217,7 +217,7 @@
73 if dirname:
74 if not os.path.exists(dirname):
75 os.makedirs(dirname)
76 - mydat=open(myname,"w")
77 + mydat = open(myname, 'wb')
78 mydat.write(mydata[datapos:datapos+datalen])
79 mydat.close()
80 startpos=startpos+namelen+12
81 @@ -262,7 +262,7 @@
82
83 def recompose_mem(self, xpdata):
84 self.scan() # Don't care about condition... We'll rewrite the data anyway.
85 - myfile=open(self.file,"a+")
86 + myfile = open(self.file, 'ab+')
87 if not myfile:
88 raise IOError
89 myfile.seek(-self.xpaksize,2) # 0,2 or -0,2 just mean EOF.
90 @@ -298,7 +298,7 @@
91 if not changed:
92 return 1
93 self.filestat=mystat
94 - a=open(self.file,"r")
95 + a = open(self.file, 'rb')
96 a.seek(-16,2)
97 trailer=a.read()
98 self.infosize=0
99 @@ -341,7 +341,7 @@
100 myresult=searchindex(self.index,myfile)
101 if not myresult:
102 return mydefault
103 - a=open(self.file,"r")
104 + a = open(self.file, 'rb')
105 a.seek(self.datapos+myresult[0],0)
106 myreturn=a.read(myresult[1])
107 a.close()
108 @@ -365,7 +365,7 @@
109 except:
110 os.chdir("/")
111 origdir="/"
112 - a=open(self.file,"r")
113 + a = open(self.file, 'rb')
114 if not os.path.exists(mydest):
115 os.makedirs(mydest)
116 os.chdir(mydest)
117 @@ -379,7 +379,7 @@
118 if dirname:
119 if not os.path.exists(dirname):
120 os.makedirs(dirname)
121 - mydat=open(myname,"w")
122 + mydat = open(myname, 'wb')
123 a.seek(self.datapos+datapos)
124 mydat.write(a.read(datalen))
125 mydat.close()
126 @@ -392,7 +392,7 @@
127 """Returns all the files from the dataSegment as a map object."""
128 if not self.scan():
129 return 0
130 - a = open(self.file, "r")
131 + a = open(self.file, 'rb')
132 mydata = {}
133 startpos=0
134 while ((startpos+8)<self.indexsize):
135 @@ -411,7 +411,7 @@
136 if not self.scan():
137 return None
138
139 - a = open(self.file,"r")
140 + a = open(self.file, 'rb')
141 a.seek(self.datapos)
142 mydata =a.read(self.datasize)
143 a.close()