1 |
Author: grobian |
2 |
Date: 2009-08-24 09:38:13 +0000 (Mon, 24 Aug 2009) |
3 |
New Revision: 14143 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/bin/ebuild-helpers/prepstrip |
7 |
main/branches/prefix/bin/ebuild.sh |
8 |
main/branches/prefix/bin/misc-functions.sh |
9 |
main/branches/prefix/man/ebuild.5 |
10 |
main/branches/prefix/man/portage.5 |
11 |
main/branches/prefix/pym/_emerge/JobStatusDisplay.py |
12 |
main/branches/prefix/pym/portage/__init__.py |
13 |
main/branches/prefix/pym/portage/_selinux.py |
14 |
main/branches/prefix/pym/portage/cache/ebuild_xattr.py |
15 |
main/branches/prefix/pym/portage/checksum.py |
16 |
main/branches/prefix/pym/portage/dbapi/bintree.py |
17 |
main/branches/prefix/pym/portage/dbapi/porttree.py |
18 |
main/branches/prefix/pym/portage/dbapi/vartree.py |
19 |
main/branches/prefix/pym/portage/elog/messages.py |
20 |
main/branches/prefix/pym/portage/elog/mod_save.py |
21 |
main/branches/prefix/pym/portage/elog/mod_save_summary.py |
22 |
main/branches/prefix/pym/portage/elog/mod_syslog.py |
23 |
main/branches/prefix/pym/portage/env/loaders.py |
24 |
main/branches/prefix/pym/portage/mail.py |
25 |
main/branches/prefix/pym/portage/manifest.py |
26 |
main/branches/prefix/pym/portage/news.py |
27 |
main/branches/prefix/pym/portage/output.py |
28 |
main/branches/prefix/pym/portage/process.py |
29 |
main/branches/prefix/pym/portage/sets/files.py |
30 |
main/branches/prefix/pym/portage/tests/__init__.py |
31 |
main/branches/prefix/pym/portage/tests/ebuild/test_spawn.py |
32 |
main/branches/prefix/pym/portage/update.py |
33 |
main/branches/prefix/pym/portage/util.py |
34 |
main/branches/prefix/pym/portage/xpak.py |
35 |
Log: |
36 |
Merged from trunk -r14107:14117 |
37 |
|
38 |
| 14108 | Use _encodings where appropriate. | |
39 |
| zmedico | | |
40 |
|
41 |
| 14109 | Use _encodings where appropriate. | |
42 |
| zmedico | | |
43 |
|
44 |
| 14110 | Use _encodings where appropriate. | |
45 |
| zmedico | | |
46 |
|
47 |
| 14111 | Use _encodings where appropriate and add | |
48 |
| zmedico | _encodings['stdio'] for stdout encoding. | |
49 |
|
50 |
| 14112 | Fix typo. | |
51 |
| zmedico | | |
52 |
|
53 |
| 14113 | Replace _content_encoding, _fs_encoding, and | |
54 |
| zmedico | _merge_encoding with direct usage of _encodings. | |
55 |
|
56 |
| 14114 | Support QA_DT_HASH_${ARCH} and QA_PRESTRIPPED_${ARCH} (bug | |
57 |
| arfrever | #271416). | |
58 |
|
59 |
| 14115 | Add support for QA_SONAME variable (bug #281964). Add | |
60 |
| arfrever | support for QA_NEEDED variable. | |
61 |
|
62 |
| 14116 | Improve an example. Patch by Jeremy Olexa. | |
63 |
| arfrever | | |
64 |
|
65 |
| 14117 | Rename QA_NEEDED to QA_DT_NEEDED. | |
66 |
| arfrever | | |
67 |
|
68 |
|
69 |
Modified: main/branches/prefix/bin/ebuild-helpers/prepstrip |
70 |
=================================================================== |
71 |
--- main/branches/prefix/bin/ebuild-helpers/prepstrip 2009-08-24 09:36:42 UTC (rev 14142) |
72 |
+++ main/branches/prefix/bin/ebuild-helpers/prepstrip 2009-08-24 09:38:13 UTC (rev 14143) |
73 |
@@ -100,6 +100,8 @@ |
74 |
if ! hasq binchecks ${RESTRICT} && \ |
75 |
! hasq strip ${RESTRICT} ; then |
76 |
log=$T/scanelf-already-stripped.log |
77 |
+ qa_var="QA_PRESTRIPPED_${ARCH/-/_}" |
78 |
+ [[ -n ${!qa_var} ]] && QA_PRESTRIPPED="${!qa_var}" |
79 |
scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^$D##" > "$log" |
80 |
if [[ -n $QA_PRESTRIPPED && -s $log && \ |
81 |
${QA_STRICT_PRESTRIPPED-unset} = unset ]] ; then |
82 |
|
83 |
Modified: main/branches/prefix/bin/ebuild.sh |
84 |
=================================================================== |
85 |
--- main/branches/prefix/bin/ebuild.sh 2009-08-24 09:36:42 UTC (rev 14142) |
86 |
+++ main/branches/prefix/bin/ebuild.sh 2009-08-24 09:38:13 UTC (rev 14143) |
87 |
@@ -1862,6 +1862,7 @@ |
88 |
|
89 |
# This needs to be exported since prepstrip is a separate shell script. |
90 |
[[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED |
91 |
+ eval "[[ -n \$QA_PRESTRIPPED_$ARCH ]] && export QA_PRESTRIPPED_$ARCH" |
92 |
} |
93 |
|
94 |
if ! hasq "$EBUILD_PHASE" clean cleanrm ; then |
95 |
|
96 |
Modified: main/branches/prefix/bin/misc-functions.sh |
97 |
=================================================================== |
98 |
--- main/branches/prefix/bin/misc-functions.sh 2009-08-24 09:36:42 UTC (rev 14142) |
99 |
+++ main/branches/prefix/bin/misc-functions.sh 2009-08-24 09:38:13 UTC (rev 14143) |
100 |
@@ -167,6 +167,8 @@ |
101 |
|
102 |
# Check for files built without respecting LDFLAGS |
103 |
if [[ "${LDFLAGS}" == *--hash-style=gnu* ]] && [[ "${PN}" != *-bin ]] ; then |
104 |
+ qa_var="QA_DT_HASH_${ARCH/-/_}" |
105 |
+ eval "[[ -n \${!qa_var} ]] && QA_DT_HASH=(\"\${${qa_var}[@]}\")" |
106 |
f=$(scanelf -qyRF '%k %p' -k .hash "${D}" | sed -e "s:\.hash ::") |
107 |
if [[ -n ${f} ]] ; then |
108 |
echo "${f}" > "${T}"/scanelf-ignored-LDFLAGS.log |
109 |
@@ -241,26 +243,71 @@ |
110 |
die "Aborting due to QA concerns: ${die_msg}" |
111 |
fi |
112 |
|
113 |
- # Run some sanity checks on shared libraries |
114 |
- for d in "${D}"lib* "${D}"usr/lib* ; do |
115 |
- f=$(scanelf -ByF '%S %p' "${d}"/lib*.so* | gawk '$2 == "" { print }') |
116 |
+ # Check for shared libraries lacking SONAMEs |
117 |
+ qa_var="QA_SONAME_${ARCH/-/_}" |
118 |
+ eval "[[ -n \${!qa_var} ]] && QA_SONAME=(\"\${${qa_var}[@]}\")" |
119 |
+ f=$(scanelf -ByF '%S %p' "${D}"{,usr/}lib*/lib*.so* | gawk '$2 == "" { print }' | sed -e "s:^[[:space:]]${D}:/:") |
120 |
+ if [[ -n ${f} ]] ; then |
121 |
+ echo "${f}" > "${T}"/scanelf-missing-SONAME.log |
122 |
+ if [[ "${QA_STRICT_SONAME-unset}" == unset ]] ; then |
123 |
+ if [[ ${#QA_SONAME[@]} -gt 1 ]] ; then |
124 |
+ for x in "${QA_SONAME[@]}" ; do |
125 |
+ sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-SONAME.log |
126 |
+ done |
127 |
+ else |
128 |
+ local shopts=$- |
129 |
+ set -o noglob |
130 |
+ for x in ${QA_SONAME} ; do |
131 |
+ sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-SONAME.log |
132 |
+ done |
133 |
+ set +o noglob |
134 |
+ set -${shopts} |
135 |
+ fi |
136 |
+ fi |
137 |
+ f=$(<"${T}"/scanelf-missing-SONAME.log) |
138 |
if [[ -n ${f} ]] ; then |
139 |
vecho -ne '\a\n' |
140 |
eqawarn "QA Notice: The following shared libraries lack a SONAME" |
141 |
eqawarn "${f}" |
142 |
vecho -ne '\a\n' |
143 |
sleep 1 |
144 |
+ else |
145 |
+ rm -f "${T}"/scanelf-missing-SONAME.log |
146 |
fi |
147 |
+ fi |
148 |
|
149 |
- f=$(scanelf -ByF '%n %p' "${d}"/lib*.so* | gawk '$2 == "" { print }') |
150 |
+ # Check for shared libraries lacking NEEDED entries |
151 |
+ qa_var="QA_DT_NEEDED_${ARCH/-/_}" |
152 |
+ eval "[[ -n \${!qa_var} ]] && QA_DT_NEEDED=(\"\${${qa_var}[@]}\")" |
153 |
+ f=$(scanelf -ByF '%n %p' "${D}"{,usr/}lib*.so* | gawk '$2 == "" { print }' | sed -e "s:^[[:space:]]${D}:/:") |
154 |
+ if [[ -n ${f} ]] ; then |
155 |
+ echo "${f}" > "${T}"/scanelf-missing-NEEDED.log |
156 |
+ if [[ "${QA_STRICT_DT_NEEDED-unset}" == unset ]] ; then |
157 |
+ if [[ ${#QA_DT_NEEDED[@]} -gt 1 ]] ; then |
158 |
+ for x in "${QA_DT_NEEDED[@]}" ; do |
159 |
+ sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-NEEDED.log |
160 |
+ done |
161 |
+ else |
162 |
+ local shopts=$- |
163 |
+ set -o noglob |
164 |
+ for x in ${QA_DT_NEEDED} ; do |
165 |
+ sed -e "s#^/${x#/}\$##" -i "${T}"/scanelf-missing-NEEDED.log |
166 |
+ done |
167 |
+ set +o noglob |
168 |
+ set -${shopts} |
169 |
+ fi |
170 |
+ fi |
171 |
+ f=$(<"${T}"/scanelf-missing-NEEDED.log) |
172 |
if [[ -n ${f} ]] ; then |
173 |
vecho -ne '\a\n' |
174 |
eqawarn "QA Notice: The following shared libraries lack NEEDED entries" |
175 |
eqawarn "${f}" |
176 |
vecho -ne '\a\n' |
177 |
sleep 1 |
178 |
+ else |
179 |
+ rm -f "${T}"/scanelf-missing-NEEDED.log |
180 |
fi |
181 |
- done |
182 |
+ fi |
183 |
|
184 |
PORTAGE_QUIET=${tmp_quiet} |
185 |
fi |
186 |
|
187 |
Modified: main/branches/prefix/man/ebuild.5 |
188 |
=================================================================== |
189 |
--- main/branches/prefix/man/ebuild.5 2009-08-24 09:36:42 UTC (rev 14142) |
190 |
+++ main/branches/prefix/man/ebuild.5 2009-08-24 09:38:13 UTC (rev 14143) |
191 |
@@ -510,6 +510,16 @@ |
192 |
This should contain a list of file paths, relative to the image directory, of |
193 |
files that contain pre-stripped binaries. The paths may contain regular |
194 |
expressions with escape\-quoted special characters. |
195 |
+.TP |
196 |
+\fBQA_SONAME\fR |
197 |
+This should contain a list of file paths, relative to the image directory, of |
198 |
+shared libraries that lack SONAMEs. The paths may contain regular expressions |
199 |
+with escape\-quoted special characters. |
200 |
+.TP |
201 |
+\fBQA_DT_NEEDED\fR |
202 |
+This should contain a list of file paths, relative to the image directory, of |
203 |
+shared libraries that lack NEEDED entries. The paths may contain regular |
204 |
+expressions with escape\-quoted special characters. |
205 |
.SH "PORTAGE DECLARATIONS" |
206 |
.TP |
207 |
.B inherit |
208 |
|
209 |
Modified: main/branches/prefix/man/portage.5 |
210 |
=================================================================== |
211 |
--- main/branches/prefix/man/portage.5 2009-08-24 09:36:42 UTC (rev 14142) |
212 |
+++ main/branches/prefix/man/portage.5 2009-08-24 09:38:13 UTC (rev 14143) |
213 |
@@ -152,8 +152,8 @@ |
214 |
|
215 |
.I Example: |
216 |
.nf |
217 |
-/usr/portage/profiles/package.mask/removals |
218 |
-/usr/portage/profiles/package.mask/testing |
219 |
+${PORTDIR}/profiles/package.mask/removals |
220 |
+${PORTDIR}/profiles/package.mask/testing |
221 |
.fi |
222 |
.RS |
223 |
.TP |
224 |
|
225 |
Modified: main/branches/prefix/pym/_emerge/JobStatusDisplay.py |
226 |
=================================================================== |
227 |
--- main/branches/prefix/pym/_emerge/JobStatusDisplay.py 2009-08-24 09:36:42 UTC (rev 14142) |
228 |
+++ main/branches/prefix/pym/_emerge/JobStatusDisplay.py 2009-08-24 09:38:13 UTC (rev 14143) |
229 |
@@ -13,6 +13,7 @@ |
230 |
|
231 |
import portage |
232 |
from portage import os |
233 |
+from portage import _encodings |
234 |
from portage.output import xtermTitle |
235 |
|
236 |
from _emerge.getloadavg import getloadavg |
237 |
@@ -70,7 +71,7 @@ |
238 |
def _write(self, s): |
239 |
if sys.hexversion < 0x3000000 and isinstance(s, unicode): |
240 |
# avoid potential UnicodeEncodeError |
241 |
- s = portage._unicode_encode(s) |
242 |
+ s = s.encode(_encodings['stdio'], 'backslashreplace') |
243 |
self.out.write(s) |
244 |
self.out.flush() |
245 |
|
246 |
|
247 |
Modified: main/branches/prefix/pym/portage/__init__.py |
248 |
=================================================================== |
249 |
--- main/branches/prefix/pym/portage/__init__.py 2009-08-24 09:36:42 UTC (rev 14142) |
250 |
+++ main/branches/prefix/pym/portage/__init__.py 2009-08-24 09:38:13 UTC (rev 14143) |
251 |
@@ -126,17 +126,13 @@ |
252 |
'fs' : 'utf_8', |
253 |
'merge' : sys.getfilesystemencoding(), |
254 |
'repo.content' : 'utf_8', |
255 |
+ 'stdio' : 'utf_8', |
256 |
} |
257 |
|
258 |
# This can happen if python is built with USE=build (stage 1). |
259 |
if _encodings['merge'] is None: |
260 |
_encodings['merge'] = 'ascii' |
261 |
|
262 |
-# Deprecated attributes. Instead use _encodings directly. |
263 |
-_content_encoding = _encodings['content'] |
264 |
-_fs_encoding = _encodings['fs'] |
265 |
-_merge_encoding = _encodings['merge'] |
266 |
- |
267 |
def _unicode_encode(s, encoding=_encodings['content'], |
268 |
errors='backslashreplace'): |
269 |
if isinstance(s, unicode): |
270 |
|
271 |
Modified: main/branches/prefix/pym/portage/_selinux.py |
272 |
=================================================================== |
273 |
--- main/branches/prefix/pym/portage/_selinux.py 2009-08-24 09:36:42 UTC (rev 14142) |
274 |
+++ main/branches/prefix/pym/portage/_selinux.py 2009-08-24 09:38:13 UTC (rev 14143) |
275 |
@@ -7,8 +7,7 @@ |
276 |
import os |
277 |
import shutil |
278 |
|
279 |
-from portage import _content_encoding |
280 |
-from portage import _fs_encoding |
281 |
+from portage import _encodings |
282 |
from portage import _unicode_encode |
283 |
from portage.localization import _ |
284 |
|
285 |
@@ -16,8 +15,8 @@ |
286 |
from selinux import is_selinux_enabled |
287 |
|
288 |
def copyfile(src, dest): |
289 |
- src = _unicode_encode(src, encoding=_fs_encoding, errors='strict') |
290 |
- dest = _unicode_encode(dest, encoding=_fs_encoding, errors='strict') |
291 |
+ src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict') |
292 |
+ dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') |
293 |
(rc, ctx) = selinux.lgetfilecon(src) |
294 |
if rc < 0: |
295 |
raise OSError(_("copyfile: Failed getting context of \"%s\".") % src) |
296 |
@@ -36,8 +35,8 @@ |
297 |
return ctx |
298 |
|
299 |
def mkdir(target, refdir): |
300 |
- target = _unicode_encode(target, encoding=_fs_encoding, errors='strict') |
301 |
- refdir = _unicode_encode(refdir, encoding=_fs_encoding, errors='strict') |
302 |
+ target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict') |
303 |
+ refdir = _unicode_encode(refdir, encoding=_encodings['fs'], errors='strict') |
304 |
(rc, ctx) = selinux.getfilecon(refdir) |
305 |
if rc < 0: |
306 |
raise OSError( |
307 |
@@ -51,8 +50,8 @@ |
308 |
selinux.setfscreatecon() |
309 |
|
310 |
def rename(src, dest): |
311 |
- src = _unicode_encode(src, encoding=_fs_encoding, errors='strict') |
312 |
- dest = _unicode_encode(dest, encoding=_fs_encoding, errors='strict') |
313 |
+ src = _unicode_encode(src, encoding=_encodings['fs'], errors='strict') |
314 |
+ dest = _unicode_encode(dest, encoding=_encodings['fs'], errors='strict') |
315 |
(rc, ctx) = selinux.lgetfilecon(src) |
316 |
if rc < 0: |
317 |
raise OSError(_("rename: Failed getting context of \"%s\".") % src) |
318 |
@@ -69,13 +68,13 @@ |
319 |
return ":".join(ret) |
320 |
|
321 |
def setexec(ctx="\n"): |
322 |
- ctx = _unicode_encode(ctx, encoding=_content_encoding, errors='strict') |
323 |
+ ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict') |
324 |
if selinux.setexeccon(ctx) < 0: |
325 |
raise OSError(_("setexec: Failed setting exec() context \"%s\".") % ctx) |
326 |
|
327 |
def setfscreate(ctx="\n"): |
328 |
ctx = _unicode_encode(ctx, |
329 |
- encoding=_content_encoding, errors='strict') |
330 |
+ encoding=_encodings['content'], errors='strict') |
331 |
if selinux.setfscreatecon(ctx) < 0: |
332 |
raise OSError( |
333 |
_("setfscreate: Failed setting fs create context \"%s\".") % ctx) |
334 |
@@ -83,7 +82,7 @@ |
335 |
def spawn_wrapper(spawn_func, selinux_type): |
336 |
|
337 |
selinux_type = _unicode_encode(selinux_type, |
338 |
- encoding=_content_encoding, errors='strict') |
339 |
+ encoding=_encodings['content'], errors='strict') |
340 |
|
341 |
def wrapper_func(*args, **kwargs): |
342 |
con = settype(selinux_type) |
343 |
@@ -96,9 +95,9 @@ |
344 |
return wrapper_func |
345 |
|
346 |
def symlink(target, link, reflnk): |
347 |
- target = _unicode_encode(target, encoding=_fs_encoding, errors='strict') |
348 |
- link = _unicode_encode(link, encoding=_fs_encoding, errors='strict') |
349 |
- reflnk = _unicode_encode(reflnk, encoding=_fs_encoding, errors='strict') |
350 |
+ target = _unicode_encode(target, encoding=_encodings['fs'], errors='strict') |
351 |
+ link = _unicode_encode(link, encoding=_encodings['fs'], errors='strict') |
352 |
+ reflnk = _unicode_encode(reflnk, encoding=_encodings['fs'], errors='strict') |
353 |
(rc, ctx) = selinux.lgetfilecon(reflnk) |
354 |
if rc < 0: |
355 |
raise OSError( |
356 |
|
357 |
Modified: main/branches/prefix/pym/portage/cache/ebuild_xattr.py |
358 |
=================================================================== |
359 |
--- main/branches/prefix/pym/portage/cache/ebuild_xattr.py 2009-08-24 09:36:42 UTC (rev 14142) |
360 |
+++ main/branches/prefix/pym/portage/cache/ebuild_xattr.py 2009-08-24 09:38:13 UTC (rev 14143) |
361 |
@@ -10,7 +10,7 @@ |
362 |
from portage.versions import catsplit |
363 |
from portage import cpv_getkey |
364 |
from portage import os |
365 |
-from portage import _fs_encoding |
366 |
+from portage import _encoding |
367 |
from portage import _unicode_decode |
368 |
import xattr |
369 |
from errno import ENODATA,ENOSPC,E2BIG |
370 |
@@ -159,7 +159,7 @@ |
371 |
for file in files: |
372 |
try: |
373 |
file = _unicode_decode(file, |
374 |
- encoding=_fs_encoding, errors='strict') |
375 |
+ encoding=_encodings['fs'], errors='strict') |
376 |
except UnicodeDecodeError: |
377 |
continue |
378 |
if file[-7:] == '.ebuild': |
379 |
|
380 |
Modified: main/branches/prefix/pym/portage/checksum.py |
381 |
=================================================================== |
382 |
--- main/branches/prefix/pym/portage/checksum.py 2009-08-24 09:36:42 UTC (rev 14142) |
383 |
+++ main/branches/prefix/pym/portage/checksum.py 2009-08-24 09:38:13 UTC (rev 14143) |
384 |
@@ -7,8 +7,7 @@ |
385 |
from portage.const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE |
386 |
from portage.localization import _ |
387 |
from portage import os |
388 |
-from portage import _fs_encoding |
389 |
-from portage import _merge_encoding |
390 |
+from portage import _encodings |
391 |
from portage import _unicode_encode |
392 |
import errno |
393 |
import stat |
394 |
@@ -29,7 +28,7 @@ |
395 |
@return: The hash and size of the data |
396 |
""" |
397 |
f = open(_unicode_encode(filename, |
398 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
399 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
400 |
blocksize = HASHING_BLOCKSIZE |
401 |
data = f.read(blocksize) |
402 |
size = 0L |
403 |
@@ -123,7 +122,7 @@ |
404 |
|
405 |
def _perform_md5_merge(x, **kwargs): |
406 |
return perform_md5(_unicode_encode(x, |
407 |
- encoding=_merge_encoding, errors='strict'), **kwargs) |
408 |
+ encoding=_encodings['merge'], errors='strict'), **kwargs) |
409 |
|
410 |
def perform_all(x, calc_prelink=0): |
411 |
mydict = {} |
412 |
@@ -221,7 +220,7 @@ |
413 |
# Make sure filename is encoded with the correct encoding before |
414 |
# it is passed to spawn (for prelink) and/or the hash function. |
415 |
filename = _unicode_encode(filename, |
416 |
- encoding=_fs_encoding, errors='strict') |
417 |
+ encoding=_encodings['fs'], errors='strict') |
418 |
myfilename = filename |
419 |
prelink_tmpfile = None |
420 |
try: |
421 |
|
422 |
Modified: main/branches/prefix/pym/portage/dbapi/bintree.py |
423 |
=================================================================== |
424 |
--- main/branches/prefix/pym/portage/dbapi/bintree.py 2009-08-24 09:36:42 UTC (rev 14142) |
425 |
+++ main/branches/prefix/pym/portage/dbapi/bintree.py 2009-08-24 09:38:13 UTC (rev 14143) |
426 |
@@ -22,6 +22,7 @@ |
427 |
|
428 |
from portage import dep_expand, listdir, _check_distfile, _movefile |
429 |
from portage import os |
430 |
+from portage import _encodings |
431 |
from portage import _unicode_decode |
432 |
from portage import _unicode_encode |
433 |
|
434 |
@@ -76,7 +77,8 @@ |
435 |
def getitem(k): |
436 |
v = tbz2.getfile(k) |
437 |
if v is not None: |
438 |
- v = _unicode_decode(v) |
439 |
+ v = _unicode_decode(v, |
440 |
+ encoding=_encodings['repo.content'], errors='replace') |
441 |
return v |
442 |
else: |
443 |
getitem = self.bintree._remotepkgs[mycpv].get |
444 |
@@ -111,8 +113,10 @@ |
445 |
mydata = mytbz2.get_data() |
446 |
|
447 |
for k, v in values.iteritems(): |
448 |
- k = _unicode_encode(k) |
449 |
- v = _unicode_encode(v) |
450 |
+ k = _unicode_encode(k, |
451 |
+ encoding=_encodings['repo.content'], errors='backslashreplace') |
452 |
+ v = _unicode_encode(v, |
453 |
+ encoding=_encodings['repo.content'], errors='backslashreplace') |
454 |
mydata[k] = v |
455 |
|
456 |
for k, v in mydata.items(): |
457 |
@@ -655,8 +659,10 @@ |
458 |
urldata[1] + urldata[2], "Packages") |
459 |
pkgindex = self._new_pkgindex() |
460 |
try: |
461 |
- f = codecs.open(_unicode_encode(pkgindex_file), |
462 |
- encoding='utf_8', errors='replace') |
463 |
+ f = codecs.open(_unicode_encode(pkgindex_file, |
464 |
+ encoding=_encodings['fs'], errors='strict'), |
465 |
+ mode='r', encoding=_encodings['repo.content'], |
466 |
+ errors='replace') |
467 |
try: |
468 |
pkgindex.read(f) |
469 |
finally: |
470 |
@@ -1097,8 +1103,10 @@ |
471 |
def _load_pkgindex(self): |
472 |
pkgindex = self._new_pkgindex() |
473 |
try: |
474 |
- f = codecs.open(_unicode_encode(self._pkgindex_file), |
475 |
- encoding='utf_8', errors='replace') |
476 |
+ f = codecs.open(_unicode_encode(self._pkgindex_file, |
477 |
+ encoding=_encodings['fs'], errors='strict'), |
478 |
+ mode='r', encoding=_encodings['repo.content'], |
479 |
+ errors='replace') |
480 |
except EnvironmentError: |
481 |
pass |
482 |
else: |
483 |
|
484 |
Modified: main/branches/prefix/pym/portage/dbapi/porttree.py |
485 |
=================================================================== |
486 |
--- main/branches/prefix/pym/portage/dbapi/porttree.py 2009-08-24 09:36:42 UTC (rev 14142) |
487 |
+++ main/branches/prefix/pym/portage/dbapi/porttree.py 2009-08-24 09:38:13 UTC (rev 14143) |
488 |
@@ -26,8 +26,9 @@ |
489 |
from portage import eclass_cache, auxdbkeys, doebuild, flatten, \ |
490 |
listdir, dep_expand, eapi_is_supported, key_expand, dep_check, \ |
491 |
_eapi_is_deprecated |
492 |
+from portage import os |
493 |
+from portage import _encodings |
494 |
from portage import _unicode_encode |
495 |
-from portage import os |
496 |
|
497 |
import codecs |
498 |
import logging |
499 |
@@ -172,8 +173,10 @@ |
500 |
repo_name_path = os.path.join(path, REPO_NAME_LOC) |
501 |
try: |
502 |
repo_name = codecs.open( |
503 |
- _unicode_encode(repo_name_path), mode='r', |
504 |
- encoding='utf_8', errors='replace').readline().strip() |
505 |
+ _unicode_encode(repo_name_path, |
506 |
+ encoding=_encodings['fs'], errors='strict'), |
507 |
+ mode='r', encoding=_encodings['repo.content'], |
508 |
+ errors='replace').readline().strip() |
509 |
except EnvironmentError: |
510 |
# warn about missing repo_name at some other time, since we |
511 |
# don't want to see a warning every time the portage module is |
512 |
@@ -621,8 +624,10 @@ |
513 |
if eapi is None and \ |
514 |
'parse-eapi-ebuild-head' in self.doebuild_settings.features: |
515 |
eapi = portage._parse_eapi_ebuild_head(codecs.open( |
516 |
- _unicode_encode(myebuild), mode='r', |
517 |
- encoding='utf_8', errors='replace')) |
518 |
+ _unicode_encode(myebuild, |
519 |
+ encoding=_encodings['fs'], errors='strict'), |
520 |
+ mode='r', encoding=_encodings['repo.content'], |
521 |
+ errors='replace')) |
522 |
|
523 |
if eapi is not None: |
524 |
self.doebuild_settings.configdict['pkg']['EAPI'] = eapi |
525 |
|
526 |
Modified: main/branches/prefix/pym/portage/dbapi/vartree.py |
527 |
=================================================================== |
528 |
--- main/branches/prefix/pym/portage/dbapi/vartree.py 2009-08-24 09:36:42 UTC (rev 14142) |
529 |
+++ main/branches/prefix/pym/portage/dbapi/vartree.py 2009-08-24 09:38:13 UTC (rev 14143) |
530 |
@@ -38,9 +38,7 @@ |
531 |
|
532 |
# This is a special version of the os module, wrapped for unicode support. |
533 |
from portage import os |
534 |
-from portage import _content_encoding |
535 |
-from portage import _fs_encoding |
536 |
-from portage import _merge_encoding |
537 |
+from portage import _encodings |
538 |
from portage import _os_merge |
539 |
from portage import _selinux_merge |
540 |
from portage import _unicode_decode |
541 |
@@ -81,7 +79,8 @@ |
542 |
self._data = None |
543 |
try: |
544 |
self._data = pickle.load( |
545 |
- open(_unicode_encode(self._filename), 'rb')) |
546 |
+ open(_unicode_encode(self._filename, |
547 |
+ encoding=_encodings['fs'], errors='strict'), 'rb')) |
548 |
except (ValueError, pickle.UnpicklingError), e: |
549 |
writemsg_level(_("!!! Error loading '%s': %s\n") % \ |
550 |
(self._filename, e), level=logging.ERROR, noiselevel=-1) |
551 |
@@ -328,7 +327,15 @@ |
552 |
raise CommandNotFound(args[0]) |
553 |
else: |
554 |
for l in proc.stdout: |
555 |
- l = portage._unicode_decode(l) |
556 |
+ try: |
557 |
+ l = _unicode_decode(l, |
558 |
+ encoding=_encodings['content'], errors='strict') |
559 |
+ except UnicodeDecodeError: |
560 |
+ l = _unicode_decode(l, |
561 |
+ encoding=_encodings['content'], errors='replace') |
562 |
+ writemsg_level(_("\nError decoding characters " \ |
563 |
+ "returned from scanelf: %s\n\n") % (l,), |
564 |
+ level=logging.ERROR, noiselevel=-1) |
565 |
l = l[3:].rstrip("\n") |
566 |
if not l: |
567 |
continue |
568 |
@@ -1455,7 +1462,8 @@ |
569 |
now has a categories property that is generated from the |
570 |
available packages. |
571 |
""" |
572 |
- self.root = portage._unicode_decode(root) |
573 |
+ self.root = _unicode_decode(root, |
574 |
+ encoding=_encodings['content'], errors='strict') |
575 |
|
576 |
#cache for category directory mtimes |
577 |
self.mtdircache = {} |
578 |
@@ -1539,7 +1547,8 @@ |
579 |
except KeyError: |
580 |
continue |
581 |
h.update(_unicode_encode(counter, |
582 |
- encoding=_content_encoding, errors='replace')) |
583 |
+ encoding=_encodings['repo.content'], |
584 |
+ errors='backslashreplace')) |
585 |
return h.hexdigest() |
586 |
|
587 |
def cpv_inject(self, mycpv): |
588 |
@@ -1804,7 +1813,8 @@ |
589 |
# python-2.x, but buffering makes it much worse. |
590 |
open_kwargs["buffering"] = 0 |
591 |
try: |
592 |
- f = open(_unicode_encode(self._aux_cache_filename), |
593 |
+ f = open(_unicode_encode(self._aux_cache_filename, |
594 |
+ encoding=_encodings['fs'], errors='strict'), |
595 |
mode='rb', **open_kwargs) |
596 |
mypickle = pickle.Unpickler(f) |
597 |
try: |
598 |
@@ -1906,7 +1916,8 @@ |
599 |
if cache_valid: |
600 |
# Migrate old metadata to unicode. |
601 |
for k, v in metadata.iteritems(): |
602 |
- metadata[k] = portage._unicode_decode(v) |
603 |
+ metadata[k] = _unicode_decode(v, |
604 |
+ encoding=_encodings['repo.content'], errors='replace') |
605 |
|
606 |
mydata.update(metadata) |
607 |
pull_me.difference_update(mydata) |
608 |
@@ -1953,8 +1964,9 @@ |
609 |
try: |
610 |
myf = codecs.open( |
611 |
_unicode_encode(os.path.join(mydir, x), |
612 |
- encoding=_fs_encoding, errors='strict'), |
613 |
- mode='r', encoding=_content_encoding, errors='replace') |
614 |
+ encoding=_encodings['fs'], errors='strict'), |
615 |
+ mode='r', encoding=_encodings['repo.content'], |
616 |
+ errors='replace') |
617 |
try: |
618 |
myd = myf.read() |
619 |
finally: |
620 |
@@ -2024,8 +2036,9 @@ |
621 |
try: |
622 |
cfile = codecs.open( |
623 |
_unicode_encode(self._counter_path, |
624 |
- encoding=_fs_encoding, errors='strict'), |
625 |
- mode='r', encoding=_content_encoding, errors='replace') |
626 |
+ encoding=_encodings['fs'], errors='strict'), |
627 |
+ mode='r', encoding=_encodings['repo.content'], |
628 |
+ errors='replace') |
629 |
except EnvironmentError, e: |
630 |
new_vdb = not bool(self.cpv_all()) |
631 |
if not new_vdb: |
632 |
@@ -2092,7 +2105,8 @@ |
633 |
removed = 0 |
634 |
|
635 |
for filename in paths: |
636 |
- filename = portage._unicode_decode(filename) |
637 |
+ filename = _unicode_decode(filename, |
638 |
+ encoding=_encodings['content'], errors='strict') |
639 |
filename = normalize_path(filename) |
640 |
if relative_paths: |
641 |
relative_filename = filename |
642 |
@@ -2161,7 +2175,8 @@ |
643 |
# Always use a constant utf_8 encoding here, since |
644 |
# the "default" encoding can change. |
645 |
h.update(_unicode_encode(s, |
646 |
- encoding=_content_encoding, errors='replace')) |
647 |
+ encoding=_encodings['repo.content'], |
648 |
+ errors='backslashreplace')) |
649 |
h = h.hexdigest() |
650 |
h = h[-self._hex_chars:] |
651 |
h = int(h, 16) |
652 |
@@ -2610,8 +2625,9 @@ |
653 |
pkgfiles = {} |
654 |
try: |
655 |
myc = codecs.open(_unicode_encode(contents_file, |
656 |
- encoding=_content_encoding, errors='strict'), |
657 |
- mode='r', encoding=_content_encoding, errors='replace') |
658 |
+ encoding=_encodings['fs'], errors='strict'), |
659 |
+ mode='r', encoding=_encodings['repo.content'], |
660 |
+ errors='replace') |
661 |
except EnvironmentError, e: |
662 |
if e.errno != errno.ENOENT: |
663 |
raise |
664 |
@@ -3087,13 +3103,15 @@ |
665 |
obj = normalize_path(objkey) |
666 |
if os is _os_merge: |
667 |
try: |
668 |
- _unicode_encode(obj, encoding=_merge_encoding, errors='strict') |
669 |
+ _unicode_encode(obj, |
670 |
+ encoding=_encodings['merge'], errors='strict') |
671 |
except UnicodeEncodeError: |
672 |
# The package appears to have been merged with a |
673 |
# different value of sys.getfilesystemencoding(), |
674 |
# so fall back to utf_8 if appropriate. |
675 |
try: |
676 |
- _unicode_encode(obj, encoding=_fs_encoding, errors='strict') |
677 |
+ _unicode_encode(obj, |
678 |
+ encoding=_encodings['fs'], errors='strict') |
679 |
except UnicodeEncodeError: |
680 |
pass |
681 |
else: |
682 |
@@ -3290,9 +3308,11 @@ |
683 |
|
684 |
os = _os_merge |
685 |
|
686 |
- filename = portage._unicode_decode(filename) |
687 |
+ filename = _unicode_decode(filename, |
688 |
+ encoding=_encodings['content'], errors='strict') |
689 |
|
690 |
- destroot = portage._unicode_decode(destroot) |
691 |
+ destroot = _unicode_decode(destroot, |
692 |
+ encoding=_encodings['content'], errors='strict') |
693 |
|
694 |
destfile = normalize_path( |
695 |
os.path.join(destroot, filename.lstrip(os.path.sep))) |
696 |
@@ -3484,7 +3504,8 @@ |
697 |
new_contents = self.getcontents().copy() |
698 |
old_contents = self._installed_instance.getcontents() |
699 |
for f in sorted(preserve_paths): |
700 |
- f = portage._unicode_decode(f, encoding=_merge_encoding) |
701 |
+ f = _unicode_decode(f, |
702 |
+ encoding=_encodings['content'], errors='strict') |
703 |
f_abs = os.path.join(root, f.lstrip(os.sep)) |
704 |
contents_entry = old_contents.get(f_abs) |
705 |
if contents_entry is None: |
706 |
@@ -3926,10 +3947,14 @@ |
707 |
|
708 |
os = _os_merge |
709 |
|
710 |
- srcroot = portage._unicode_decode(srcroot) |
711 |
- destroot = portage._unicode_decode(destroot) |
712 |
- inforoot = portage._unicode_decode(inforoot) |
713 |
- myebuild = portage._unicode_decode(myebuild) |
714 |
+ srcroot = _unicode_decode(srcroot, |
715 |
+ encoding=_encodings['content'], errors='strict') |
716 |
+ destroot = _unicode_decode(destroot, |
717 |
+ encoding=_encodings['content'], errors='strict') |
718 |
+ inforoot = _unicode_decode(inforoot, |
719 |
+ encoding=_encodings['content'], errors='strict') |
720 |
+ myebuild = _unicode_decode(myebuild, |
721 |
+ encoding=_encodings['content'], errors='strict') |
722 |
|
723 |
showMessage = self._display_merge |
724 |
scheduler = self._scheduler |
725 |
@@ -3947,9 +3972,9 @@ |
726 |
try: |
727 |
val = codecs.open(_unicode_encode( |
728 |
os.path.join(inforoot, var_name), |
729 |
- encoding=_fs_encoding, errors='strict'), |
730 |
- mode='r', encoding=_content_encoding, errors='replace' |
731 |
- ).readline().strip() |
732 |
+ encoding=_encodings['fs'], errors='strict'), |
733 |
+ mode='r', encoding=_encodings['repo.content'], |
734 |
+ errors='replace').readline().strip() |
735 |
except EnvironmentError, e: |
736 |
if e.errno != errno.ENOENT: |
737 |
raise |
738 |
@@ -4037,14 +4062,14 @@ |
739 |
for parent, dirs, files in os.walk(srcroot, onerror=onerror): |
740 |
try: |
741 |
parent = _unicode_decode(parent, |
742 |
- encoding=_merge_encoding, errors='strict') |
743 |
+ encoding=_encodings['merge'], errors='strict') |
744 |
except UnicodeDecodeError: |
745 |
new_parent = _unicode_decode(parent, |
746 |
- encoding=_merge_encoding, errors='replace') |
747 |
+ encoding=_encodings['merge'], errors='replace') |
748 |
new_parent = _unicode_encode(new_parent, |
749 |
- encoding=_merge_encoding, errors='backslashreplace') |
750 |
+ encoding=_encodings['merge'], errors='backslashreplace') |
751 |
new_parent = _unicode_decode(new_parent, |
752 |
- encoding=_merge_encoding, errors='replace') |
753 |
+ encoding=_encodings['merge'], errors='replace') |
754 |
os.rename(parent, new_parent) |
755 |
unicode_error = True |
756 |
unicode_errors.append(new_parent[srcroot_len:]) |
757 |
@@ -4053,16 +4078,16 @@ |
758 |
for fname in files: |
759 |
try: |
760 |
fname = _unicode_decode(fname, |
761 |
- encoding=_merge_encoding, errors='strict') |
762 |
+ encoding=_encodings['merge'], errors='strict') |
763 |
except UnicodeDecodeError: |
764 |
fpath = portage._os.path.join( |
765 |
- parent.encode(_merge_encoding), fname) |
766 |
+ parent.encode(_encodings['merge']), fname) |
767 |
new_fname = _unicode_decode(fname, |
768 |
- encoding=_merge_encoding, errors='replace') |
769 |
+ encoding=_encodings['merge'], errors='replace') |
770 |
new_fname = _unicode_encode(new_fname, |
771 |
- encoding=_merge_encoding, errors='backslashreplace') |
772 |
+ encoding=_encodings['merge'], errors='backslashreplace') |
773 |
new_fname = _unicode_decode(new_fname, |
774 |
- encoding=_merge_encoding, errors='replace') |
775 |
+ encoding=_encodings['merge'], errors='replace') |
776 |
new_fpath = os.path.join(parent, new_fname) |
777 |
os.rename(fpath, new_fpath) |
778 |
unicode_error = True |
779 |
@@ -4290,14 +4315,17 @@ |
780 |
|
781 |
# write local package counter for recording |
782 |
counter = self.vartree.dbapi.counter_tick(self.myroot, mycpv=self.mycpv) |
783 |
- open(_unicode_encode(os.path.join(self.dbtmpdir, 'COUNTER')), |
784 |
- 'w').write(str(counter)) |
785 |
+ codecs.open(_unicode_encode(os.path.join(self.dbtmpdir, 'COUNTER'), |
786 |
+ encoding=_encodings['fs'], errors='strict'), |
787 |
+ 'w', encoding=_encodings['repo.content'], errors='backslashreplace' |
788 |
+ ).write(str(counter)) |
789 |
|
790 |
# open CONTENTS file (possibly overwriting old one) for recording |
791 |
outfile = codecs.open(_unicode_encode( |
792 |
os.path.join(self.dbtmpdir, 'CONTENTS'), |
793 |
- encoding=_fs_encoding, errors='strict'), |
794 |
- mode='w', encoding=_content_encoding, errors='replace') |
795 |
+ encoding=_encodings['fs'], errors='strict'), |
796 |
+ mode='w', encoding=_encodings['repo.content'], |
797 |
+ errors='backslashreplace') |
798 |
|
799 |
self.updateprotect() |
800 |
|
801 |
@@ -4647,7 +4675,7 @@ |
802 |
# unlinking no longer necessary; "movefile" will overwrite symlinks atomically and correctly |
803 |
mymtime = movefile(mysrc, mydest, newmtime=thismtime, |
804 |
sstat=mystat, mysettings=self.settings, |
805 |
- encoding=_merge_encoding) |
806 |
+ encoding=_encodings['merge']) |
807 |
if mymtime != None: |
808 |
showMessage(">>> %s -> %s\n" % (mydest, myto)) |
809 |
outfile.write("sym "+myrealdest+" -> "+myto+" "+str(mymtime)+"\n") |
810 |
@@ -4687,7 +4715,7 @@ |
811 |
# a non-directory and non-symlink-to-directory. Won't work for us. Move out of the way. |
812 |
if movefile(mydest, mydest+".backup", |
813 |
mysettings=self.settings, |
814 |
- encoding=_merge_encoding) is None: |
815 |
+ encoding=_encodings['merge']) is None: |
816 |
return 1 |
817 |
showMessage(_("bak %s %s.backup\n") % (mydest, mydest), |
818 |
level=logging.ERROR, noiselevel=-1) |
819 |
@@ -4792,7 +4820,7 @@ |
820 |
mymtime = movefile(mysrc, mydest, newmtime=thismtime, |
821 |
sstat=mystat, mysettings=self.settings, |
822 |
hardlink_candidates=hardlink_candidates, |
823 |
- encoding=_merge_encoding) |
824 |
+ encoding=_encodings['merge']) |
825 |
if mymtime is None: |
826 |
return 1 |
827 |
if hardlink_candidates is not None: |
828 |
@@ -4809,7 +4837,7 @@ |
829 |
# destination doesn't exist |
830 |
if movefile(mysrc, mydest, newmtime=thismtime, |
831 |
sstat=mystat, mysettings=self.settings, |
832 |
- encoding=_merge_encoding) is not None: |
833 |
+ encoding=_encodings['merge']) is not None: |
834 |
zing = ">>>" |
835 |
else: |
836 |
return 1 |
837 |
@@ -4897,8 +4925,8 @@ |
838 |
return "" |
839 |
mydata = codecs.open( |
840 |
_unicode_encode(os.path.join(self.dbdir, name), |
841 |
- encoding=_fs_encoding, errors='strict'), |
842 |
- mode='r', encoding=_content_encoding, errors='replace' |
843 |
+ encoding=_encodings['fs'], errors='strict'), |
844 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace' |
845 |
).read().split() |
846 |
return " ".join(mydata) |
847 |
|
848 |
@@ -4909,22 +4937,27 @@ |
849 |
if not os.path.exists(self.dbdir+"/"+fname): |
850 |
return "" |
851 |
return codecs.open(_unicode_encode(os.path.join(self.dbdir, fname), |
852 |
- encoding=_fs_encoding, errors='strict'), |
853 |
- mode='r', encoding=_content_encoding, errors='replace').read() |
854 |
+ encoding=_encodings['fs'], errors='strict'), |
855 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace' |
856 |
+ ).read() |
857 |
|
858 |
def setfile(self,fname,data): |
859 |
- mode = 'w' |
860 |
+ kwargs = {} |
861 |
if fname == 'environment.bz2' or not isinstance(data, basestring): |
862 |
- mode = 'wb' |
863 |
- write_atomic(os.path.join(self.dbdir, fname), data, mode=mode) |
864 |
+ kwargs['mode'] = 'wb' |
865 |
+ else: |
866 |
+ kwargs['mode'] = 'w' |
867 |
+ kwargs['encoding'] = _encodings['repo.content'] |
868 |
+ write_atomic(os.path.join(self.dbdir, fname), data, **kwargs) |
869 |
|
870 |
def getelements(self,ename): |
871 |
if not os.path.exists(self.dbdir+"/"+ename): |
872 |
return [] |
873 |
mylines = codecs.open(_unicode_encode( |
874 |
os.path.join(self.dbdir, ename), |
875 |
- encoding=_fs_encoding, errors='strict'), |
876 |
- mode='r', encoding=_content_encoding, errors='replace').readlines() |
877 |
+ encoding=_encodings['fs'], errors='strict'), |
878 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace' |
879 |
+ ).readlines() |
880 |
myreturn = [] |
881 |
for x in mylines: |
882 |
for y in x[:-1].split(): |
883 |
@@ -4934,8 +4967,9 @@ |
884 |
def setelements(self,mylist,ename): |
885 |
myelement = codecs.open(_unicode_encode( |
886 |
os.path.join(self.dbdir, ename), |
887 |
- encoding=_fs_encoding, errors='strict'), mode='w', |
888 |
- encoding=_content_encoding, errors='replace') |
889 |
+ encoding=_encodings['fs'], errors='strict'), |
890 |
+ mode='w', encoding=_encodings['repo.content'], |
891 |
+ errors='backslashreplace') |
892 |
for x in mylist: |
893 |
myelement.write(x+"\n") |
894 |
myelement.close() |
895 |
@@ -5013,7 +5047,8 @@ |
896 |
tarinfo.size = 0 |
897 |
tar.addfile(tarinfo) |
898 |
else: |
899 |
- f = open(_unicode_encode(path, encoding=_merge_encoding), 'rb') |
900 |
+ f = open(_unicode_encode(path, |
901 |
+ encoding=_encodings['merge'], errors='strict'), 'rb') |
902 |
try: |
903 |
tar.addfile(tarinfo, f) |
904 |
finally: |
905 |
|
906 |
Modified: main/branches/prefix/pym/portage/elog/messages.py |
907 |
=================================================================== |
908 |
--- main/branches/prefix/pym/portage/elog/messages.py 2009-08-24 09:36:42 UTC (rev 14142) |
909 |
+++ main/branches/prefix/pym/portage/elog/messages.py 2009-08-24 09:38:13 UTC (rev 14143) |
910 |
@@ -12,6 +12,9 @@ |
911 |
from portage.const import EBUILD_PHASES |
912 |
from portage.localization import _ |
913 |
from portage import os |
914 |
+from portage import _encodings |
915 |
+from portage import _unicode_encode |
916 |
+from portage import _unicode_decode |
917 |
|
918 |
import codecs |
919 |
import sys |
920 |
@@ -41,8 +44,9 @@ |
921 |
logentries[msgfunction] = [] |
922 |
lastmsgtype = None |
923 |
msgcontent = [] |
924 |
- for l in codecs.open(filename, mode='r', |
925 |
- encoding='utf_8', errors='replace'): |
926 |
+ for l in codecs.open(_unicode_encode(filename, |
927 |
+ encoding=_encodings['fs'], errors='strict'), |
928 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace'): |
929 |
if not l: |
930 |
continue |
931 |
try: |
932 |
@@ -87,15 +91,16 @@ |
933 |
if color is None: |
934 |
color = "GOOD" |
935 |
|
936 |
- if not isinstance(msg, unicode): |
937 |
- msg = unicode(msg, encoding='utf_8', errors='replace') |
938 |
+ msg = _unicode_decode(msg, |
939 |
+ encoding=_encodings['content'], errors='replace') |
940 |
|
941 |
formatted_msg = colorize(color, " * ") + msg + "\n" |
942 |
|
943 |
if sys.hexversion < 0x3000000 and \ |
944 |
out in (sys.stdout, sys.stderr) and isinstance(formatted_msg, unicode): |
945 |
# avoid potential UnicodeEncodeError |
946 |
- formatted_msg = formatted_msg.encode('utf_8', 'replace') |
947 |
+ formatted_msg = formatted_msg.encode( |
948 |
+ _encodings['stdio'], 'backslashreplace') |
949 |
|
950 |
out.write(formatted_msg) |
951 |
|
952 |
|
953 |
Modified: main/branches/prefix/pym/portage/elog/mod_save.py |
954 |
=================================================================== |
955 |
--- main/branches/prefix/pym/portage/elog/mod_save.py 2009-08-24 09:36:42 UTC (rev 14142) |
956 |
+++ main/branches/prefix/pym/portage/elog/mod_save.py 2009-08-24 09:38:13 UTC (rev 14143) |
957 |
@@ -6,6 +6,8 @@ |
958 |
import codecs |
959 |
import time |
960 |
from portage import os |
961 |
+from portage import _encodings |
962 |
+from portage import _unicode_encode |
963 |
from portage.data import portage_uid, portage_gid |
964 |
from portage.util import ensure_dirs |
965 |
from portage.const import EPREFIX |
966 |
@@ -20,8 +22,9 @@ |
967 |
ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) |
968 |
|
969 |
elogfilename = elogdir+"/"+path+":"+time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time()))+".log" |
970 |
- elogfile = codecs.open(elogfilename, mode='w', |
971 |
- encoding='utf_8', errors='replace') |
972 |
+ elogfile = codecs.open(_unicode_encode(elogfilename, |
973 |
+ encoding=_encodings['fs'], errors='strict'), |
974 |
+ mode='w', encoding=_encodings['content'], errors='backslashreplace') |
975 |
elogfile.write(fulltext) |
976 |
elogfile.close() |
977 |
|
978 |
|
979 |
Modified: main/branches/prefix/pym/portage/elog/mod_save_summary.py |
980 |
=================================================================== |
981 |
--- main/branches/prefix/pym/portage/elog/mod_save_summary.py 2009-08-24 09:36:42 UTC (rev 14142) |
982 |
+++ main/branches/prefix/pym/portage/elog/mod_save_summary.py 2009-08-24 09:38:13 UTC (rev 14143) |
983 |
@@ -6,6 +6,8 @@ |
984 |
import codecs |
985 |
import time |
986 |
from portage import os |
987 |
+from portage import _encodings |
988 |
+from portage import _unicode_encode |
989 |
from portage.data import portage_uid, portage_gid |
990 |
from portage.localization import _ |
991 |
from portage.util import ensure_dirs, apply_permissions |
992 |
@@ -20,8 +22,9 @@ |
993 |
|
994 |
# TODO: Locking |
995 |
elogfilename = elogdir+"/summary.log" |
996 |
- elogfile = codecs.open(elogfilename, mode='a', |
997 |
- encoding='utf_8', errors='replace') |
998 |
+ elogfile = codecs.open(_unicode_encode(elogfilename, |
999 |
+ encoding=_encodings['fs'], errors='strict'), |
1000 |
+ mode='a', encoding=_encodings['content'], errors='backslashreplace') |
1001 |
apply_permissions(elogfilename, mode=060, mask=0) |
1002 |
elogfile.write(_(">>> Messages generated by process %(pid)d on %(time)s for package %(pkg)s:\n\n") % |
1003 |
{"pid": os.getpid(), "time": time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())), "pkg": key}) |
1004 |
|
1005 |
Modified: main/branches/prefix/pym/portage/elog/mod_syslog.py |
1006 |
=================================================================== |
1007 |
--- main/branches/prefix/pym/portage/elog/mod_syslog.py 2009-08-24 09:36:42 UTC (rev 14142) |
1008 |
+++ main/branches/prefix/pym/portage/elog/mod_syslog.py 2009-08-24 09:38:13 UTC (rev 14143) |
1009 |
@@ -6,6 +6,7 @@ |
1010 |
import sys |
1011 |
import syslog |
1012 |
from portage.const import EBUILD_PHASES |
1013 |
+from portage import _encodings |
1014 |
|
1015 |
_pri = { |
1016 |
"INFO" : syslog.LOG_INFO, |
1017 |
@@ -25,6 +26,7 @@ |
1018 |
msgtext = "%s: %s: %s" % (key, phase, msgtext) |
1019 |
if sys.hexversion < 0x3000000 and isinstance(msgtext, unicode): |
1020 |
# Avoid TypeError from syslog.syslog() |
1021 |
- msgtext = msgtext.encode('utf_8', 'replace') |
1022 |
+ msgtext = msgtext.encode(_encodings['content'], |
1023 |
+ 'backslashreplace') |
1024 |
syslog.syslog(_pri[msgtype], msgtext) |
1025 |
syslog.closelog() |
1026 |
|
1027 |
Modified: main/branches/prefix/pym/portage/env/loaders.py |
1028 |
=================================================================== |
1029 |
--- main/branches/prefix/pym/portage/env/loaders.py 2009-08-24 09:36:42 UTC (rev 14142) |
1030 |
+++ main/branches/prefix/pym/portage/env/loaders.py 2009-08-24 09:38:13 UTC (rev 14143) |
1031 |
@@ -7,8 +7,7 @@ |
1032 |
import errno |
1033 |
import stat |
1034 |
from portage import os |
1035 |
-from portage import _content_encoding |
1036 |
-from portage import _fs_encoding |
1037 |
+from portage import _encodings |
1038 |
from portage import _unicode_decode |
1039 |
from portage import _unicode_encode |
1040 |
from portage.localization import _ |
1041 |
@@ -57,7 +56,7 @@ |
1042 |
for f in files: |
1043 |
try: |
1044 |
f = _unicode_decode(f, |
1045 |
- encoding=_fs_encoding, errors='strict') |
1046 |
+ encoding=_encodings['fs'], errors='strict') |
1047 |
except UnicodeDecodeError: |
1048 |
continue |
1049 |
if f[:1] == '.' or f[-1:] == '~': |
1050 |
@@ -152,8 +151,8 @@ |
1051 |
for fn in RecursiveFileLoader(self.fname): |
1052 |
try: |
1053 |
f = codecs.open(_unicode_encode(fn, |
1054 |
- encoding=_fs_encoding, errors='strict'), mode='r', |
1055 |
- encoding=_content_encoding, errors='replace') |
1056 |
+ encoding=_encodings['fs'], errors='strict'), mode='r', |
1057 |
+ encoding=_encodings['content'], errors='replace') |
1058 |
except EnvironmentError, e: |
1059 |
if e.errno not in (errno.ENOENT, errno.ESTALE): |
1060 |
raise |
1061 |
|
1062 |
Modified: main/branches/prefix/pym/portage/mail.py |
1063 |
=================================================================== |
1064 |
--- main/branches/prefix/pym/portage/mail.py 2009-08-24 09:36:42 UTC (rev 14142) |
1065 |
+++ main/branches/prefix/pym/portage/mail.py 2009-08-24 09:38:13 UTC (rev 14143) |
1066 |
@@ -13,7 +13,7 @@ |
1067 |
import time |
1068 |
|
1069 |
from portage import os |
1070 |
-from portage import _content_encoding |
1071 |
+from portage import _encodings |
1072 |
from portage import _unicode_encode |
1073 |
from portage.localization import _ |
1074 |
import portage |
1075 |
@@ -22,13 +22,13 @@ |
1076 |
|
1077 |
if sys.hexversion < 0x3000000: |
1078 |
sender = _unicode_encode(sender, |
1079 |
- encoding=_content_encoding, errors='strict') |
1080 |
+ encoding=_encodings['content'], errors='strict') |
1081 |
recipient = _unicode_encode(recipient, |
1082 |
- encoding=_content_encoding, errors='strict') |
1083 |
+ encoding=_encodings['content'], errors='strict') |
1084 |
subject = _unicode_encode(subject, |
1085 |
- encoding=_content_encoding, errors='replace') |
1086 |
+ encoding=_encodings['content'], errors='backslashreplace') |
1087 |
body = _unicode_encode(body, |
1088 |
- encoding=_content_encoding, errors='replace') |
1089 |
+ encoding=_encodings['content'], errors='backslashreplace') |
1090 |
|
1091 |
if attachments == None: |
1092 |
mymessage = TextMessage(body) |
1093 |
@@ -41,7 +41,8 @@ |
1094 |
elif isinstance(x, basestring): |
1095 |
if sys.hexversion < 0x3000000: |
1096 |
x = _unicode_encode(x, |
1097 |
- encoding=_content_encoding, errors='replace') |
1098 |
+ encoding=_encodings['content'], |
1099 |
+ errors='backslashreplace') |
1100 |
mymessage.attach(TextMessage(x)) |
1101 |
else: |
1102 |
raise portage.exception.PortageException(_("Can't handle type of attachment: %s") % type(x)) |
1103 |
@@ -92,17 +93,17 @@ |
1104 |
|
1105 |
if sys.hexversion < 0x3000000: |
1106 |
myrecipient = _unicode_encode(myrecipient, |
1107 |
- encoding=_content_encoding, errors='strict') |
1108 |
+ encoding=_encodings['content'], errors='strict') |
1109 |
mymailhost = _unicode_encode(mymailhost, |
1110 |
- encoding=_content_encoding, errors='strict') |
1111 |
+ encoding=_encodings['content'], errors='strict') |
1112 |
mymailport = _unicode_encode(mymailport, |
1113 |
- encoding=_content_encoding, errors='strict') |
1114 |
+ encoding=_encodings['content'], errors='strict') |
1115 |
myfrom = _unicode_encode(myfrom, |
1116 |
- encoding=_content_encoding, errors='strict') |
1117 |
+ encoding=_encodings['content'], errors='strict') |
1118 |
mymailuser = _unicode_encode(mymailuser, |
1119 |
- encoding=_content_encoding, errors='strict') |
1120 |
+ encoding=_encodings['content'], errors='strict') |
1121 |
mymailpasswd = _unicode_encode(mymailpasswd, |
1122 |
- encoding=_content_encoding, errors='strict') |
1123 |
+ encoding=_encodings['content'], errors='strict') |
1124 |
|
1125 |
# user wants to use a sendmail binary instead of smtp |
1126 |
if mymailhost[0] == os.sep and os.path.exists(mymailhost): |
1127 |
|
1128 |
Modified: main/branches/prefix/pym/portage/manifest.py |
1129 |
=================================================================== |
1130 |
--- main/branches/prefix/pym/portage/manifest.py 2009-08-24 09:36:42 UTC (rev 14142) |
1131 |
+++ main/branches/prefix/pym/portage/manifest.py 2009-08-24 09:38:13 UTC (rev 14143) |
1132 |
@@ -12,8 +12,7 @@ |
1133 |
) |
1134 |
|
1135 |
from portage import os |
1136 |
-from portage import _content_encoding |
1137 |
-from portage import _fs_encoding |
1138 |
+from portage import _encodings |
1139 |
from portage import _unicode_decode |
1140 |
from portage import _unicode_encode |
1141 |
from portage.exception import DigestException, FileNotFound, \ |
1142 |
@@ -145,8 +144,8 @@ |
1143 |
Otherwise, a new dict will be created and returned.""" |
1144 |
try: |
1145 |
fd = codecs.open(_unicode_encode(file_path, |
1146 |
- encoding=_fs_encoding, errors='strict'), mode='r', |
1147 |
- encoding=_content_encoding, errors='replace') |
1148 |
+ encoding=_encodings['fs'], errors='strict'), mode='r', |
1149 |
+ encoding=_encodings['repo.content'], errors='replace') |
1150 |
if myhashdict is None: |
1151 |
myhashdict = {} |
1152 |
self._parseDigests(fd, myhashdict=myhashdict, **kwargs) |
1153 |
@@ -233,8 +232,9 @@ |
1154 |
if not force: |
1155 |
try: |
1156 |
f = codecs.open(_unicode_encode(self.getFullname(), |
1157 |
- encoding=_fs_encoding, errors='strict'), |
1158 |
- mode='r', encoding=_content_encoding, errors='replace') |
1159 |
+ encoding=_encodings['fs'], errors='strict'), |
1160 |
+ mode='r', encoding=_encodings['repo.content'], |
1161 |
+ errors='replace') |
1162 |
oldentries = list(self._parseManifestLines(f)) |
1163 |
f.close() |
1164 |
if len(oldentries) == len(myentries): |
1165 |
@@ -327,7 +327,7 @@ |
1166 |
for f in pkgdir_files: |
1167 |
try: |
1168 |
f = _unicode_decode(f, |
1169 |
- encoding=_fs_encoding, errors='strict') |
1170 |
+ encoding=_encodings['fs'], errors='strict') |
1171 |
except UnicodeDecodeError: |
1172 |
continue |
1173 |
if f[:1] == ".": |
1174 |
@@ -362,7 +362,7 @@ |
1175 |
for f in files: |
1176 |
try: |
1177 |
f = _unicode_decode(f, |
1178 |
- encoding=_fs_encoding, errors='strict') |
1179 |
+ encoding=_encodings['fs'], errors='strict') |
1180 |
except UnicodeDecodeError: |
1181 |
continue |
1182 |
full_path = os.path.join(parentdir, f) |
1183 |
@@ -523,8 +523,8 @@ |
1184 |
if not os.path.exists(mfname): |
1185 |
return rVal |
1186 |
myfile = codecs.open(_unicode_encode(mfname, |
1187 |
- encoding=_fs_encoding, errors='strict'), |
1188 |
- mode='r', encoding=_content_encoding, errors='replace') |
1189 |
+ encoding=_encodings['fs'], errors='strict'), |
1190 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace') |
1191 |
lines = myfile.readlines() |
1192 |
myfile.close() |
1193 |
for l in lines: |
1194 |
|
1195 |
Modified: main/branches/prefix/pym/portage/news.py |
1196 |
=================================================================== |
1197 |
--- main/branches/prefix/pym/portage/news.py 2009-08-24 09:36:42 UTC (rev 14142) |
1198 |
+++ main/branches/prefix/pym/portage/news.py 2009-08-24 09:38:13 UTC (rev 14143) |
1199 |
@@ -12,8 +12,7 @@ |
1200 |
import os as _os |
1201 |
import re |
1202 |
from portage import os |
1203 |
-from portage import _content_encoding |
1204 |
-from portage import _fs_encoding |
1205 |
+from portage import _encodings |
1206 |
from portage import _unicode_decode |
1207 |
from portage import _unicode_encode |
1208 |
from portage.util import apply_secpass_permissions, ensure_dirs, \ |
1209 |
@@ -100,7 +99,7 @@ |
1210 |
news_dir = self._news_dir(repoid) |
1211 |
try: |
1212 |
news = _os.listdir(_unicode_encode(news_dir, |
1213 |
- encoding=_fs_encoding, errors='strict')) |
1214 |
+ encoding=_encodings['fs'], errors='strict')) |
1215 |
except OSError: |
1216 |
return |
1217 |
|
1218 |
@@ -120,10 +119,10 @@ |
1219 |
for itemid in news: |
1220 |
try: |
1221 |
itemid = _unicode_decode(itemid, |
1222 |
- encoding=_fs_encoding, errors='strict') |
1223 |
+ encoding=_encodings['fs'], errors='strict') |
1224 |
except UnicodeDecodeError: |
1225 |
itemid = _unicode_decode(itemid, |
1226 |
- encoding=_fs_encoding, errors='replace') |
1227 |
+ encoding=_encodings['fs'], errors='replace') |
1228 |
writemsg_level( |
1229 |
"!!! Invalid encoding in news item name: '%s'\n" % \ |
1230 |
itemid, level=logging.ERROR, noiselevel=-1) |
1231 |
@@ -253,8 +252,9 @@ |
1232 |
|
1233 |
def parse(self): |
1234 |
lines = codecs.open(_unicode_encode(self.path, |
1235 |
- encoding=_fs_encoding, errors='strict'), |
1236 |
- mode='r', encoding=_content_encoding, errors='replace').readlines() |
1237 |
+ encoding=_encodings['fs'], errors='strict'), |
1238 |
+ mode='r', encoding=_encodings['content'], errors='replace' |
1239 |
+ ).readlines() |
1240 |
self.restrictions = {} |
1241 |
invalids = [] |
1242 |
for i, line in enumerate(lines): |
1243 |
|
1244 |
Modified: main/branches/prefix/pym/portage/output.py |
1245 |
=================================================================== |
1246 |
--- main/branches/prefix/pym/portage/output.py 2009-08-24 09:36:42 UTC (rev 14142) |
1247 |
+++ main/branches/prefix/pym/portage/output.py 2009-08-24 09:38:13 UTC (rev 14143) |
1248 |
@@ -17,8 +17,7 @@ |
1249 |
) |
1250 |
|
1251 |
from portage import os |
1252 |
-from portage import _content_encoding |
1253 |
-from portage import _fs_encoding |
1254 |
+from portage import _encodings |
1255 |
from portage import _unicode_encode |
1256 |
from portage.const import COLOR_MAP_FILE, EPREFIX |
1257 |
from portage.exception import CommandNotFound, FileNotFound, \ |
1258 |
@@ -169,8 +168,8 @@ |
1259 |
try: |
1260 |
lineno=0 |
1261 |
for line in codecs.open(_unicode_encode(myfile, |
1262 |
- encoding=_fs_encoding, errors='strict'), |
1263 |
- mode='r', encoding=_content_encoding, errors='replace'): |
1264 |
+ encoding=_encodings['fs'], errors='strict'), |
1265 |
+ mode='r', encoding=_encodings['content'], errors='replace'): |
1266 |
lineno += 1 |
1267 |
|
1268 |
commenter_pos = line.find("#") |
1269 |
@@ -470,7 +469,7 @@ |
1270 |
def _write(self, f, s): |
1271 |
if sys.hexversion < 0x3000000 and isinstance(s, unicode): |
1272 |
# avoid potential UnicodeEncodeError |
1273 |
- s = s.encode(_content_encoding, 'replace') |
1274 |
+ s = s.encode(_encodings['stdio'], 'backslashreplace') |
1275 |
f.write(s) |
1276 |
f.flush() |
1277 |
|
1278 |
|
1279 |
Modified: main/branches/prefix/pym/portage/process.py |
1280 |
=================================================================== |
1281 |
--- main/branches/prefix/pym/portage/process.py 2009-08-24 09:36:42 UTC (rev 14142) |
1282 |
+++ main/branches/prefix/pym/portage/process.py 2009-08-24 09:38:13 UTC (rev 14143) |
1283 |
@@ -10,7 +10,7 @@ |
1284 |
import traceback |
1285 |
|
1286 |
from portage import os |
1287 |
-from portage import _content_encoding |
1288 |
+from portage import _encodings |
1289 |
from portage import _unicode_encode |
1290 |
import portage |
1291 |
portage.proxy.lazyimport.lazyimport(globals(), |
1292 |
@@ -184,8 +184,8 @@ |
1293 |
# Avoid a potential UnicodeEncodeError from os.execve(). |
1294 |
env_bytes = {} |
1295 |
for k, v in env.iteritems(): |
1296 |
- env_bytes[_unicode_encode(k, encoding=_content_encoding)] = \ |
1297 |
- _unicode_encode(v, encoding=_content_encoding) |
1298 |
+ env_bytes[_unicode_encode(k, encoding=_encodings['content'])] = \ |
1299 |
+ _unicode_encode(v, encoding=_encodings['content']) |
1300 |
env = env_bytes |
1301 |
del env_bytes |
1302 |
|
1303 |
|
1304 |
Modified: main/branches/prefix/pym/portage/sets/files.py |
1305 |
=================================================================== |
1306 |
--- main/branches/prefix/pym/portage/sets/files.py 2009-08-24 09:36:42 UTC (rev 14142) |
1307 |
+++ main/branches/prefix/pym/portage/sets/files.py 2009-08-24 09:38:13 UTC (rev 14143) |
1308 |
@@ -6,7 +6,7 @@ |
1309 |
from itertools import chain |
1310 |
|
1311 |
from portage import os |
1312 |
-from portage import _fs_encoding |
1313 |
+from portage import _encodings |
1314 |
from portage import _unicode_decode |
1315 |
from portage import _unicode_encode |
1316 |
from portage.util import grabfile, write_atomic, ensure_dirs, normalize_path |
1317 |
@@ -130,16 +130,16 @@ |
1318 |
|
1319 |
try: |
1320 |
directory = _unicode_decode(directory, |
1321 |
- encoding=_fs_encoding, errors='strict') |
1322 |
+ encoding=_encodings['fs'], errors='strict') |
1323 |
# Now verify that we can also encode it. |
1324 |
_unicode_encode(directory, |
1325 |
- encoding=_fs_encoding, errors='strict') |
1326 |
+ encoding=_encodings['fs'], errors='strict') |
1327 |
except UnicodeError: |
1328 |
directory = _unicode_decode(directory, |
1329 |
- encoding=_fs_encoding, errors='replace') |
1330 |
+ encoding=_encodings['fs'], errors='replace') |
1331 |
raise SetConfigError( |
1332 |
_("Directory path contains invalid character(s) for encoding '%s': '%s'") \ |
1333 |
- % (_fs_encoding, directory)) |
1334 |
+ % (_encodings['fs'], directory)) |
1335 |
|
1336 |
if os.path.isdir(directory): |
1337 |
directory = normalize_path(directory) |
1338 |
@@ -147,7 +147,7 @@ |
1339 |
for parent, dirs, files in os.walk(directory): |
1340 |
try: |
1341 |
parent = _unicode_decode(parent, |
1342 |
- encoding=_fs_encoding, errors='strict') |
1343 |
+ encoding=_encodings['fs'], errors='strict') |
1344 |
except UnicodeDecodeError: |
1345 |
continue |
1346 |
for d in dirs[:]: |
1347 |
@@ -156,7 +156,7 @@ |
1348 |
for filename in files: |
1349 |
try: |
1350 |
filename = _unicode_decode(filename, |
1351 |
- encoding=_fs_encoding, errors='strict') |
1352 |
+ encoding=_encodings['fs'], errors='strict') |
1353 |
except UnicodeDecodeError: |
1354 |
continue |
1355 |
if filename[:1] == '.': |
1356 |
|
1357 |
Modified: main/branches/prefix/pym/portage/tests/__init__.py |
1358 |
=================================================================== |
1359 |
--- main/branches/prefix/pym/portage/tests/__init__.py 2009-08-24 09:36:42 UTC (rev 14142) |
1360 |
+++ main/branches/prefix/pym/portage/tests/__init__.py 2009-08-24 09:38:13 UTC (rev 14143) |
1361 |
@@ -8,16 +8,16 @@ |
1362 |
import unittest |
1363 |
|
1364 |
from portage import os |
1365 |
-from portage import _fs_encoding |
1366 |
+from portage import _encodings |
1367 |
from portage import _unicode_encode |
1368 |
from portage import _unicode_decode |
1369 |
|
1370 |
def main(): |
1371 |
|
1372 |
TEST_FILE = _unicode_encode('__test__', |
1373 |
- encoding=_fs_encoding, errors='strict') |
1374 |
+ encoding=_encodings['fs'], errors='strict') |
1375 |
svn_dirname = _unicode_encode('.svn', |
1376 |
- encoding=_fs_encoding, errors='strict') |
1377 |
+ encoding=_encodings['fs'], errors='strict') |
1378 |
suite = unittest.TestSuite() |
1379 |
basedir = os.path.dirname(os.path.realpath(__file__)) |
1380 |
testDirs = [] |
1381 |
@@ -30,7 +30,7 @@ |
1382 |
dirs.remove(svn_dirname) |
1383 |
try: |
1384 |
root = _unicode_decode(root, |
1385 |
- encoding=_fs_encoding, errors='strict') |
1386 |
+ encoding=_encodings['fs'], errors='strict') |
1387 |
except UnicodeDecodeError: |
1388 |
continue |
1389 |
|
1390 |
|
1391 |
Modified: main/branches/prefix/pym/portage/tests/ebuild/test_spawn.py |
1392 |
=================================================================== |
1393 |
--- main/branches/prefix/pym/portage/tests/ebuild/test_spawn.py 2009-08-24 09:36:42 UTC (rev 14142) |
1394 |
+++ main/branches/prefix/pym/portage/tests/ebuild/test_spawn.py 2009-08-24 09:38:13 UTC (rev 14143) |
1395 |
@@ -6,8 +6,7 @@ |
1396 |
import errno |
1397 |
import sys |
1398 |
from portage import os |
1399 |
-from portage import _content_encoding |
1400 |
-from portage import _fs_encoding |
1401 |
+from portage import _encodings |
1402 |
from portage import _unicode_encode |
1403 |
from portage.tests import TestCase |
1404 |
|
1405 |
@@ -34,8 +33,8 @@ |
1406 |
free=1, fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd}) |
1407 |
os.close(null_fd) |
1408 |
f = codecs.open(_unicode_encode(logfile, |
1409 |
- encoding=_fs_encoding, errors='strict'), |
1410 |
- mode='r', encoding=_content_encoding, errors='strict') |
1411 |
+ encoding=_encodings['fs'], errors='strict'), |
1412 |
+ mode='r', encoding=_encodings['content'], errors='strict') |
1413 |
log_content = f.read() |
1414 |
f.close() |
1415 |
# When logging passes through a pty, this comparison will fail |
1416 |
|
1417 |
Modified: main/branches/prefix/pym/portage/update.py |
1418 |
=================================================================== |
1419 |
--- main/branches/prefix/pym/portage/update.py 2009-08-24 09:36:42 UTC (rev 14142) |
1420 |
+++ main/branches/prefix/pym/portage/update.py 2009-08-24 09:38:13 UTC (rev 14143) |
1421 |
@@ -8,8 +8,7 @@ |
1422 |
import sys |
1423 |
|
1424 |
from portage import os |
1425 |
-from portage import _content_encoding |
1426 |
-from portage import _fs_encoding |
1427 |
+from portage import _encodings |
1428 |
from portage import _unicode_decode |
1429 |
from portage import _unicode_encode |
1430 |
import portage |
1431 |
@@ -72,8 +71,8 @@ |
1432 |
for myfile in [f for f in os.listdir(dbdir) if f not in ignored_dbentries]: |
1433 |
file_path = os.path.join(dbdir, myfile) |
1434 |
mydata[myfile] = codecs.open(_unicode_encode(file_path, |
1435 |
- encoding=_fs_encoding, errors='strict'), |
1436 |
- mode='r', encoding=_content_encoding, |
1437 |
+ encoding=_encodings['fs'], errors='strict'), |
1438 |
+ mode='r', encoding=_encodings['repo.content'], |
1439 |
errors='replace').read() |
1440 |
updated_items = update_dbentries(update_iter, mydata) |
1441 |
for myfile, mycontent in updated_items.iteritems(): |
1442 |
@@ -110,8 +109,9 @@ |
1443 |
if file_path not in prev_mtimes or \ |
1444 |
long(prev_mtimes[file_path]) != long(mystat.st_mtime): |
1445 |
content = codecs.open(_unicode_encode(file_path, |
1446 |
- encoding=_fs_encoding, errors='strict'), |
1447 |
- mode='r', encoding=_content_encoding, errors='replace').read() |
1448 |
+ encoding=_encodings['fs'], errors='strict'), |
1449 |
+ mode='r', encoding=_encodings['repo.content'], errors='replace' |
1450 |
+ ).read() |
1451 |
update_data.append((file_path, mystat, content)) |
1452 |
return update_data |
1453 |
|
1454 |
@@ -172,7 +172,7 @@ |
1455 |
for y in dirs: |
1456 |
try: |
1457 |
y = _unicode_decode(y, |
1458 |
- encoding=_fs_encoding, errors='strict') |
1459 |
+ encoding=_encodings['fs'], errors='strict') |
1460 |
except UnicodeDecodeError: |
1461 |
dirs.remove(y) |
1462 |
continue |
1463 |
@@ -181,7 +181,7 @@ |
1464 |
for y in files: |
1465 |
try: |
1466 |
y = _unicode_decode(y, |
1467 |
- encoding=_fs_encoding, errors='strict') |
1468 |
+ encoding=_encodings['fs'], errors='strict') |
1469 |
except UnicodeDecodeError: |
1470 |
continue |
1471 |
if y.startswith("."): |
1472 |
@@ -195,8 +195,8 @@ |
1473 |
try: |
1474 |
file_contents[x] = codecs.open( |
1475 |
_unicode_encode(os.path.join(abs_user_config, x), |
1476 |
- encoding=_fs_encoding, errors='strict'), |
1477 |
- mode='r', encoding=_content_encoding, |
1478 |
+ encoding=_encodings['fs'], errors='strict'), |
1479 |
+ mode='r', encoding=_encodings['content'], |
1480 |
errors='replace').readlines() |
1481 |
except IOError: |
1482 |
if file_contents.has_key(x): |
1483 |
|
1484 |
Modified: main/branches/prefix/pym/portage/util.py |
1485 |
=================================================================== |
1486 |
--- main/branches/prefix/pym/portage/util.py 2009-08-24 09:36:42 UTC (rev 14142) |
1487 |
+++ main/branches/prefix/pym/portage/util.py 2009-08-24 09:38:13 UTC (rev 14143) |
1488 |
@@ -23,8 +23,7 @@ |
1489 |
|
1490 |
import portage |
1491 |
from portage import os |
1492 |
-from portage import _content_encoding |
1493 |
-from portage import _fs_encoding |
1494 |
+from portage import _encodings |
1495 |
from portage import _os_merge |
1496 |
from portage import _unicode_encode |
1497 |
from portage import _unicode_decode |
1498 |
@@ -65,7 +64,8 @@ |
1499 |
if noiselevel <= noiselimit: |
1500 |
if sys.hexversion < 0x3000000: |
1501 |
# avoid potential UnicodeEncodeError |
1502 |
- mystr = _unicode_encode(mystr) |
1503 |
+ mystr = _unicode_encode(mystr, |
1504 |
+ encoding=_encodings['stdio'], errors='backslashreplace') |
1505 |
fd.write(mystr) |
1506 |
fd.flush() |
1507 |
|
1508 |
@@ -329,8 +329,8 @@ |
1509 |
else: |
1510 |
try: |
1511 |
myfile = codecs.open(_unicode_encode(myfilename, |
1512 |
- encoding=_fs_encoding, errors='strict'), |
1513 |
- mode='r', encoding=_content_encoding, errors='replace') |
1514 |
+ encoding=_encodings['fs'], errors='strict'), |
1515 |
+ mode='r', encoding=_encodings['content'], errors='replace') |
1516 |
mylines = myfile.readlines() |
1517 |
myfile.close() |
1518 |
except IOError, e: |
1519 |
@@ -397,11 +397,11 @@ |
1520 |
# (produces spurious \0 characters with python-2.6.2) |
1521 |
if sys.hexversion < 0x3000000: |
1522 |
content = open(_unicode_encode(mycfg, |
1523 |
- encoding=_fs_encoding, errors='strict'), 'rb').read() |
1524 |
+ encoding=_encodings['fs'], errors='strict'), 'rb').read() |
1525 |
else: |
1526 |
content = open(_unicode_encode(mycfg, |
1527 |
- encoding=_fs_encoding, errors='strict'), mode='r', |
1528 |
- encoding=_content_encoding, errors='replace').read() |
1529 |
+ encoding=_encodings['fs'], errors='strict'), mode='r', |
1530 |
+ encoding=_encodings['content'], errors='replace').read() |
1531 |
if content and content[-1] != '\n': |
1532 |
content += '\n' |
1533 |
except IOError, e: |
1534 |
@@ -594,7 +594,7 @@ |
1535 |
data = None |
1536 |
try: |
1537 |
myf = open(_unicode_encode(filename, |
1538 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1539 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1540 |
mypickle = pickle.Unpickler(myf) |
1541 |
data = mypickle.load() |
1542 |
myf.close() |
1543 |
@@ -909,8 +909,8 @@ |
1544 |
open_func = open |
1545 |
else: |
1546 |
open_func = codecs.open |
1547 |
- kargs.setdefault('encoding', _content_encoding) |
1548 |
- kargs.setdefault('errors', 'replace') |
1549 |
+ kargs.setdefault('encoding', _encodings['content']) |
1550 |
+ kargs.setdefault('errors', 'backslashreplace') |
1551 |
|
1552 |
if follow_links: |
1553 |
canonical_path = os.path.realpath(filename) |
1554 |
@@ -919,7 +919,7 @@ |
1555 |
try: |
1556 |
object.__setattr__(self, '_file', |
1557 |
open_func(_unicode_encode(tmp_name, |
1558 |
- encoding=_fs_encoding, errors='strict'), |
1559 |
+ encoding=_encodings['fs'], errors='strict'), |
1560 |
mode=mode, **kargs)) |
1561 |
return |
1562 |
except IOError, e: |
1563 |
@@ -933,7 +933,7 @@ |
1564 |
tmp_name = "%s.%i" % (filename, os.getpid()) |
1565 |
object.__setattr__(self, '_file', |
1566 |
open_func(_unicode_encode(tmp_name, |
1567 |
- encoding=_fs_encoding, errors='strict'), |
1568 |
+ encoding=_encodings['fs'], errors='strict'), |
1569 |
mode=mode, **kargs)) |
1570 |
|
1571 |
def _get_target(self): |
1572 |
|
1573 |
Modified: main/branches/prefix/pym/portage/xpak.py |
1574 |
=================================================================== |
1575 |
--- main/branches/prefix/pym/portage/xpak.py 2009-08-24 09:36:42 UTC (rev 14142) |
1576 |
+++ main/branches/prefix/pym/portage/xpak.py 2009-08-24 09:38:13 UTC (rev 14143) |
1577 |
@@ -22,7 +22,7 @@ |
1578 |
|
1579 |
from portage import os |
1580 |
from portage import normalize_path |
1581 |
-from portage import _fs_encoding |
1582 |
+from portage import _encodings |
1583 |
from portage import _unicode_decode |
1584 |
from portage import _unicode_encode |
1585 |
|
1586 |
@@ -30,23 +30,24 @@ |
1587 |
"""(list, dir) --- Takes an array(list) and appends all files from dir down |
1588 |
the directory tree. Returns nothing. list is modified.""" |
1589 |
curdir = normalize_path(_unicode_decode(curdir, |
1590 |
- encoding=_fs_encoding, errors='strict')) |
1591 |
+ encoding=_encodings['fs'], errors='strict')) |
1592 |
for parent, dirs, files in os.walk(curdir): |
1593 |
|
1594 |
parent = _unicode_decode(parent, |
1595 |
- encoding=_fs_encoding, errors='strict') |
1596 |
+ encoding=_encodings['fs'], errors='strict') |
1597 |
if parent != curdir: |
1598 |
mylist.append(parent[len(curdir) + 1:] + os.sep) |
1599 |
|
1600 |
for x in dirs: |
1601 |
try: |
1602 |
- _unicode_decode(x, encoding=_fs_encoding, errors='strict') |
1603 |
+ _unicode_decode(x, encoding=_encodings['fs'], errors='strict') |
1604 |
except UnicodeDecodeError: |
1605 |
dirs.remove(x) |
1606 |
|
1607 |
for x in files: |
1608 |
try: |
1609 |
- x = _unicode_decode(x, encoding=_fs_encoding, errors='strict') |
1610 |
+ x = _unicode_decode(x, |
1611 |
+ encoding=_encodings['fs'], errors='strict') |
1612 |
except UnicodeDecodeError: |
1613 |
continue |
1614 |
mylist.append(os.path.join(parent, x)[len(curdir) + 1:]) |
1615 |
@@ -82,13 +83,13 @@ |
1616 |
mylist.sort() |
1617 |
mydata = {} |
1618 |
for x in mylist: |
1619 |
- x = _unicode_encode(x, encoding=_fs_encoding, errors='strict') |
1620 |
+ x = _unicode_encode(x, encoding=_encodings['fs'], errors='strict') |
1621 |
mydata[x] = open(os.path.join(rootdir, x), 'rb').read() |
1622 |
|
1623 |
xpak_segment = xpak_mem(mydata) |
1624 |
if outfile: |
1625 |
outf = open(_unicode_encode(outfile, |
1626 |
- encoding=_fs_encoding, errors='strict'), 'wb') |
1627 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
1628 |
outf.write(xpak_segment) |
1629 |
outf.close() |
1630 |
else: |
1631 |
@@ -118,9 +119,9 @@ |
1632 |
'infile.index' contains the index segment. |
1633 |
'infile.dat' contails the data segment.""" |
1634 |
infile = _unicode_decode(infile, |
1635 |
- encoding=_fs_encoding, errors='strict') |
1636 |
+ encoding=_encodings['fs'], errors='strict') |
1637 |
myfile = open(_unicode_encode(infile, |
1638 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1639 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1640 |
mydat=myfile.read() |
1641 |
myfile.close() |
1642 |
|
1643 |
@@ -129,11 +130,11 @@ |
1644 |
return False |
1645 |
|
1646 |
myfile = open(_unicode_encode(infile + '.index', |
1647 |
- encoding=_fs_encoding, errors='strict'), 'wb') |
1648 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
1649 |
myfile.write(splits[0]) |
1650 |
myfile.close() |
1651 |
myfile = open(_unicode_encode(infile + '.dat', |
1652 |
- encoding=_fs_encoding, errors='strict'), 'wb') |
1653 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
1654 |
myfile.write(splits[1]) |
1655 |
myfile.close() |
1656 |
return True |
1657 |
@@ -149,7 +150,7 @@ |
1658 |
def getindex(infile): |
1659 |
"""(infile) -- grabs the index segment from the infile and returns it.""" |
1660 |
myfile = open(_unicode_encode(infile, |
1661 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1662 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1663 |
myheader=myfile.read(16) |
1664 |
if myheader[0:8] != _unicode_encode('XPAKPACK'): |
1665 |
myfile.close() |
1666 |
@@ -163,7 +164,7 @@ |
1667 |
"""(infile) -- grabs the index and data segments from the infile. |
1668 |
Returns an array [indexSegment,dataSegment]""" |
1669 |
myfile = open(_unicode_encode(infile, |
1670 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1671 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1672 |
myheader=myfile.read(16) |
1673 |
if myheader[0:8] != _unicode_encode('XPAKPACK'): |
1674 |
myfile.close() |
1675 |
@@ -238,7 +239,7 @@ |
1676 |
if not os.path.exists(dirname): |
1677 |
os.makedirs(dirname) |
1678 |
mydat = open(_unicode_encode(myname, |
1679 |
- encoding=_fs_encoding, errors='strict'), 'wb') |
1680 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
1681 |
mydat.write(mydata[datapos:datapos+datalen]) |
1682 |
mydat.close() |
1683 |
startpos=startpos+namelen+12 |
1684 |
@@ -284,7 +285,7 @@ |
1685 |
def recompose_mem(self, xpdata): |
1686 |
self.scan() # Don't care about condition... We'll rewrite the data anyway. |
1687 |
myfile = open(_unicode_encode(self.file, |
1688 |
- encoding=_fs_encoding, errors='strict'), 'ab+') |
1689 |
+ encoding=_encodings['fs'], errors='strict'), 'ab+') |
1690 |
if not myfile: |
1691 |
raise IOError |
1692 |
myfile.seek(-self.xpaksize,2) # 0,2 or -0,2 just mean EOF. |
1693 |
@@ -322,7 +323,7 @@ |
1694 |
return 1 |
1695 |
self.filestat=mystat |
1696 |
a = open(_unicode_encode(self.file, |
1697 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1698 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1699 |
a.seek(-16,2) |
1700 |
trailer=a.read() |
1701 |
self.infosize=0 |
1702 |
@@ -366,7 +367,7 @@ |
1703 |
if not myresult: |
1704 |
return mydefault |
1705 |
a = open(_unicode_encode(self.file, |
1706 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1707 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1708 |
a.seek(self.datapos+myresult[0],0) |
1709 |
myreturn=a.read(myresult[1]) |
1710 |
a.close() |
1711 |
@@ -391,7 +392,7 @@ |
1712 |
os.chdir("/") |
1713 |
origdir="/" |
1714 |
a = open(_unicode_encode(self.file, |
1715 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1716 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1717 |
if not os.path.exists(mydest): |
1718 |
os.makedirs(mydest) |
1719 |
os.chdir(mydest) |
1720 |
@@ -406,7 +407,7 @@ |
1721 |
if not os.path.exists(dirname): |
1722 |
os.makedirs(dirname) |
1723 |
mydat = open(_unicode_encode(myname, |
1724 |
- encoding=_fs_encoding, errors='strict'), 'wb') |
1725 |
+ encoding=_encodings['fs'], errors='strict'), 'wb') |
1726 |
a.seek(self.datapos+datapos) |
1727 |
mydat.write(a.read(datalen)) |
1728 |
mydat.close() |
1729 |
@@ -420,7 +421,7 @@ |
1730 |
if not self.scan(): |
1731 |
return 0 |
1732 |
a = open(_unicode_encode(self.file, |
1733 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1734 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1735 |
mydata = {} |
1736 |
startpos=0 |
1737 |
while ((startpos+8)<self.indexsize): |
1738 |
@@ -440,7 +441,7 @@ |
1739 |
return None |
1740 |
|
1741 |
a = open(_unicode_encode(self.file, |
1742 |
- encoding=_fs_encoding, errors='strict'), 'rb') |
1743 |
+ encoding=_encodings['fs'], errors='strict'), 'rb') |
1744 |
a.seek(self.datapos) |
1745 |
mydata =a.read(self.datasize) |
1746 |
a.close() |