Use _encodings where appropriate.
authorZac Medico <zmedico@gentoo.org>
Thu, 20 Aug 2009 23:09:43 +0000 (23:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 Aug 2009 23:09:43 +0000 (23:09 -0000)
svn path=/main/trunk/; revision=14106

pym/_emerge/changelog.py
pym/_emerge/emergelog.py

index 4adb8b25bafecb7c566651f89b472d0b96d19264..0fdf5880a9458075c20554fc4b47a763c7ece94c 100644 (file)
@@ -7,6 +7,8 @@ import re
 
 import portage
 from portage import os
+from portage import _encodings
+from portage import _unicode_encode
 
 def calc_changelog(ebuildpath,current,next):
        if ebuildpath == None or not os.path.exists(ebuildpath):
@@ -19,8 +21,10 @@ def calc_changelog(ebuildpath,current,next):
                next = next[:-3]
        changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog')
        try:
-               changelog = codecs.open(portage._unicode_encode(changelogpath),
-                       mode='r', encoding='utf_8', errors='replace').read()
+               changelog = codecs.open(_unicode_encode(changelogpath,
+                       encoding=_encodings['fs'], errors='strict'),
+                       mode='r', encoding=_encodings['repo.content'], errors='replace'
+               ).read()
        except SystemExit, e:
                raise # Needed else can't exit
        except:
index 01de27a4a884c43facc48086b6050813ba0837f2..cdc60767b7705f93610ad2daa86b55b70400743e 100644 (file)
@@ -7,6 +7,8 @@ import sys
 import time
 import portage
 from portage import os
+from portage import _encodings
+from portage import _unicode_encode
 from portage.data import secpass
 from portage.output import xtermTitle
 
@@ -25,8 +27,10 @@ def emergelog(xterm_titles, mystr, short_msg=None):
                xtermTitle(short_msg)
        try:
                file_path = os.path.join(_emerge_log_dir, 'emerge.log')
-               mylogfile = codecs.open(portage._unicode_encode(file_path), mode='a',
-                       encoding='utf_8', errors='replace')
+               mylogfile = codecs.open(_unicode_encode(file_path,
+                       encoding=_encodings['fs'], errors='strict'),
+                       mode='a', encoding=_encodings['content'],
+                       errors='backslashreplace')
                portage.util.apply_secpass_permissions(file_path,
                        uid=portage.portage_uid, gid=portage.portage_gid,
                        mode=0660)