1 |
sping 10/01/02 03:36:48 |
2 |
|
3 |
Added: layman-1.2.4-non-ascii-backport.patch |
4 |
Log: |
5 |
app-portage/layman: Integrate patch for bug #286290 |
6 |
(Portage version: 2.2_rc61/cvs/Linux i686) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-portage/layman/files/layman-1.2.4-non-ascii-backport.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-portage/layman/files/layman-1.2.4-non-ascii-backport.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-portage/layman/files/layman-1.2.4-non-ascii-backport.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: layman-1.2.4-non-ascii-backport.patch |
15 |
=================================================================== |
16 |
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py |
17 |
index e10f562..99aadad 100644 |
18 |
--- a/layman/overlays/overlay.py |
19 |
+++ b/layman/overlays/overlay.py |
20 |
@@ -29,5 +29,6 @@ __version__ = "$Id: layman-1.2.4-non-ascii-backport.patch,v 1.1 2010/01/02 03:36:47 sping Exp $" |
21 |
#------------------------------------------------------------------------------- |
22 |
|
23 |
import sys, types, re, os, os.path, shutil, subprocess |
24 |
+import codecs |
25 |
|
26 |
from layman.utils import node_to_dict, dict_to_node, path |
27 |
@@ -226,6 +227,15 @@ class Overlay: |
28 |
result = cmd.wait() |
29 |
return result |
30 |
|
31 |
+ def _get_encoding(self): |
32 |
+ if hasattr(sys.stdout, 'encoding'): |
33 |
+ return sys.stdout.encoding |
34 |
+ else: |
35 |
+ return 'ascii' |
36 |
+ |
37 |
+ def _encode(self, unicode_text): |
38 |
+ return codecs.encode(unicode_text, self._get_encoding(), 'replace') |
39 |
+ |
40 |
def __str__(self): |
41 |
''' |
42 |
>>> here = os.path.dirname(os.path.realpath(__file__)) |
43 |
@@ -272,7 +282,7 @@ class Overlay: |
44 |
result += u'\n '.join((u'\n' + link).split(u'\n')) |
45 |
result += u'\n' |
46 |
|
47 |
- return result |
48 |
+ return self._encode(result) |
49 |
|
50 |
def short_list(self, width = 0): |
51 |
''' |
52 |
@@ -321,7 +331,7 @@ class Overlay: |
53 |
source = source.replace("overlays.gentoo.org", "o.g.o") |
54 |
source = ' (' + pad(source, srclen) + ')' |
55 |
|
56 |
- return name + mtype + source |
57 |
+ return self._encode(name + mtype + source) |
58 |
|
59 |
def supported(self, binaries = []): |
60 |
'''Is the overlay type supported?''' |