mtimedbfile = os.path.join("/", portage.CACHE_PATH.lstrip(os.path.sep), "mtimedb")
mtimedb = portage.MtimeDB(mtimedbfile)
-
+ portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
return settings, trees, mtimedb
def chk_updated_cfg_files(target_root, config_protect):
sys.stderr.write(" "+str(e)+"\n\n")
raise
-# Assume utf_8 encoding for content of all files.
-_content_encoding = 'utf_8'
-
-# Assume utf_8 fs encoding everywhere except in merge code.
-_fs_encoding = 'utf_8'
+# Assume utf_8 fs encoding everywhere except in merge code, where the
+# user's locale is respected.
+_encodings = {
+ 'content' : 'utf_8',
+ 'fs' : 'utf_8',
+ 'merge' : sys.getfilesystemencoding(),
+}
-_merge_encoding = sys.getfilesystemencoding()
+# Deprecated attributes. Instead use _encodings directly.
+_content_encoding = _encodings['content']
+_fs_encoding = _encodings['fs']
+_merge_encoding = _encodings['merge']
-def _unicode_encode(s, encoding=_content_encoding, errors='replace'):
+def _unicode_encode(s, encoding=_encodings['content'],
+ errors='backslashreplace'):
if isinstance(s, unicode):
s = s.encode(encoding, errors)
return s
-def _unicode_decode(s, encoding=_content_encoding, errors='replace'):
+def _unicode_decode(s, encoding=_encodings['content'], errors='replace'):
if not isinstance(s, unicode):
if sys.hexversion < 0x3000000:
if isinstance(s, basestring):
"""
__slots__ = ('_func', '_encoding')
- def __init__(self, func, encoding='utf_8'):
+ def __init__(self, func, encoding=_encodings['fs']):
self._func = func
self._encoding = encoding
"""
__slots__ = ('_mod', '_encoding', '_overrides')
- def __init__(self, mod, encoding='utf_8', overrides=None):
+ def __init__(self, mod, encoding=_encodings['fs'], overrides=None):
object.__setattr__(self, '_mod', mod)
object.__setattr__(self, '_encoding', encoding)
object.__setattr__(self, '_overrides', overrides)
}
os = _unicode_module_wrapper(_os, overrides=_os_overrides,
- encoding=_fs_encoding)
+ encoding=_encodings['fs'])
_os_merge = _unicode_module_wrapper(_os,
- encoding=_merge_encoding, overrides=_os_overrides)
+ encoding=_encodings['merge'], overrides=_os_overrides)
import shutil as _shutil
-shutil = _unicode_module_wrapper(_shutil, encoding=_fs_encoding)
+shutil = _unicode_module_wrapper(_shutil, encoding=_encodings['fs'])
# Imports below this point rely on the above unicode wrapper definitions.
_selinux = None
_selinux_merge = None
try:
import portage._selinux
- selinux = _unicode_module_wrapper(_selinux, encoding=_fs_encoding)
- _selinux_merge = _unicode_module_wrapper(_selinux, encoding=_merge_encoding)
+ selinux = _unicode_module_wrapper(_selinux,
+ encoding=_encodings['fs'])
+ _selinux_merge = _unicode_module_wrapper(_selinux,
+ encoding=_encodings['merge'])
except OSError, e:
sys.stderr.write("!!! SELinux not loaded: %s\n" % str(e))
del e
ldsoconf_path = os.path.join(target_root, EPREFIX_LSTRIP, "etc", "ld.so.conf")
try:
- myld = codecs.open(_unicode_encode(ldsoconf_path), mode='r',
- encoding='utf_8', errors='replace')
+ myld = codecs.open(_unicode_encode(ldsoconf_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace')
myldlines=myld.readlines()
myld.close()
oldld=[]
lines = []
pathname = os.path.join(base_dir, 'Makefile')
try:
- f = codecs.open(_unicode_encode(pathname), mode='r',
- encoding='utf_8', errors='replace')
+ f = codecs.open(_unicode_encode(pathname,
+ encoding=_encodings['fs'], errors='strict'), mode='r',
+ encoding=_encodings['content'], errors='replace')
except OSError, details:
return (None, str(details))
except IOError, details:
parentsFile = os.path.join(currentPath, "parent")
eapi_file = os.path.join(currentPath, "eapi")
try:
- eapi = codecs.open(_unicode_encode(eapi_file),
- mode='r', encoding='utf_8', errors='replace'
+ eapi = codecs.open(_unicode_encode(eapi_file,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace'
).readline().strip()
except IOError:
pass
try:
repo_conf_parser.readfp(
codecs.open(
- _unicode_encode(self._local_repo_conf_path), mode='r',
- encoding='utf_8', errors='replace'))
+ _unicode_encode(self._local_repo_conf_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace')
+ )
except EnvironmentError, e:
if e.errno != errno.ENOENT:
raise
if (mystat[stat.ST_SIZE]<100000) and (len(myfile)>4) and not ((myfile[-5:]==".html") or (myfile[-4:]==".htm")):
html404=re.compile("<title>.*(not found|404).*</title>",re.I|re.M)
if html404.search(codecs.open(
- _unicode_encode(myfile_path), mode='r',
- encoding='utf_8', errors='replace'
+ _unicode_encode(myfile_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace'
).read()):
try:
os.unlink(mysettings["DISTDIR"]+"/"+myfile)
for parent, dirs, files in os.walk(filesdir):
try:
parent = _unicode_decode(parent,
- encoding=_fs_encoding, errors='strict')
+ encoding=_encodings['fs'], errors='strict')
except UnicodeDecodeError:
parent = _unicode_decode(parent,
- encoding=_fs_encoding, errors='replace')
+ encoding=_encodings['fs'], errors='replace')
writemsg(_("!!! Path contains invalid "
"character(s) for encoding '%s': '%s'") \
- % (_fs_encoding, parent), noiselevel=-1)
+ % (_encodings['fs'], parent), noiselevel=-1)
if strict:
return 0
continue
for f in files:
try:
f = _unicode_decode(f,
- encoding=_fs_encoding, errors='strict')
+ encoding=_encodings['fs'], errors='strict')
except UnicodeDecodeError:
f = _unicode_decode(f,
- encoding=_fs_encoding, errors='replace')
+ encoding=_encodings['fs'], errors='replace')
if f.startswith("."):
continue
f = os.path.join(parent, f)[len(filesdir) + 1:]
writemsg(_("!!! File name contains invalid "
"character(s) for encoding '%s': '%s'") \
- % (_fs_encoding, f), noiselevel=-1)
+ % (_encodings['fs'], f), noiselevel=-1)
if strict:
return 0
continue
if logfile is None:
return
try:
- f = codecs.open(_unicode_encode(logfile), mode='r',
- encoding='utf_8', errors='replace')
+ f = codecs.open(_unicode_encode(logfile,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace')
except EnvironmentError:
return
for parent, dirs, files in os.walk(destdir):
try:
parent = _unicode_decode(parent,
- encoding=_merge_encoding, errors='strict')
+ encoding=_encodings['merge'], errors='strict')
except UnicodeDecodeError:
new_parent = _unicode_decode(parent,
- encoding=_merge_encoding, errors='replace')
+ encoding=_encodings['merge'], errors='replace')
new_parent = _unicode_encode(new_parent,
- encoding=_merge_encoding, errors='backslashreplace')
+ encoding=_encodings['merge'], errors='backslashreplace')
new_parent = _unicode_decode(new_parent,
- encoding=_merge_encoding, errors='replace')
+ encoding=_encodings['merge'], errors='replace')
os.rename(parent, new_parent)
unicode_error = True
unicode_errors.append(new_parent[len(destdir):])
for fname in chain(dirs, files):
try:
fname = _unicode_decode(fname,
- encoding=_merge_encoding, errors='strict')
+ encoding=_encodings['merge'], errors='strict')
except UnicodeDecodeError:
fpath = _os.path.join(
- parent.encode(_merge_encoding), fname)
+ parent.encode(_encodings['merge']), fname)
new_fname = _unicode_decode(fname,
- encoding=_merge_encoding, errors='replace')
+ encoding=_encodings['merge'], errors='replace')
new_fname = _unicode_encode(new_fname,
- encoding=_merge_encoding, errors='backslashreplace')
+ encoding=_encodings['merge'], errors='backslashreplace')
new_fname = _unicode_decode(new_fname,
- encoding=_merge_encoding, errors='replace')
+ encoding=_encodings['merge'], errors='replace')
new_fpath = os.path.join(parent, new_fname)
os.rename(fpath, new_fpath)
unicode_error = True
if mystat.st_gid == portage_gid:
mygid = inst_gid
apply_secpass_permissions(
- _unicode_encode(fpath, encoding=_merge_encoding),
+ _unicode_encode(fpath, encoding=_encodings['merge']),
uid=myuid, gid=mygid,
mode=mystat.st_mode, stat_cached=mystat,
follow_links=False)
msg = _("This package installs one or more file names containing "
"characters that do not match your current locale "
"settings. The current setting for filesystem encoding is '%s'.") \
- % _merge_encoding
+ % _encodings['merge']
lines.extend(wrap(msg, 72))
lines.append("")
lines.extend("\t" + x for x in errors)
lines.append("")
- if _merge_encoding.lower().replace('_', '').replace('-', '') != 'utf8':
+ if _encodings['merge'].lower().replace('_', '').replace('-', '') != 'utf8':
msg = _("For best results, UTF-8 encoding is recommended. See "
"the Gentoo Linux Localization Guide for instructions "
"about how to configure your locale for UTF-8 encoding:")
pass
elif 'parse-eapi-ebuild-head' in mysettings.features:
eapi = _parse_eapi_ebuild_head(
- codecs.open(_unicode_encode(ebuild_path),
- mode='r', encoding='utf_8', errors='replace'))
+ codecs.open(_unicode_encode(ebuild_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace'))
if eapi is not None:
if not eapi_is_supported(eapi):
if background and log_path is not None:
try:
- log_file = codecs.open(_unicode_encode(log_path), mode='a',
- encoding='utf_8', errors='replace')
+ log_file = codecs.open(_unicode_encode(log_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='a', encoding=_encodings['content'], errors='replace')
except IOError:
def write(msg):
pass
"mv '%s' '%s'" % (src, dest))
def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
- hardlink_candidates=None, encoding=_fs_encoding):
+ hardlink_candidates=None, encoding=_encodings['fs']):
"""moves a file from src to dest, preserving all permissions and attributes; mtime will
be preserved even when moving across filesystems. Returns true on success and false on
failure. Move is atomic."""
DEPRECATED_PROFILE_FILE.lstrip(os.sep))
if not os.access(deprecated_profile_file, os.R_OK):
return False
- dcontent = codecs.open(_unicode_encode(deprecated_profile_file),
- mode='r', encoding='utf_8', errors='replace').readlines()
+ dcontent = codecs.open(_unicode_encode(deprecated_profile_file,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace').readlines()
writemsg(colorize("BAD", _("\n!!! Your current profile is "
"deprecated and not supported anymore.")) + "\n", noiselevel=-1)
if not dcontent:
break
root = settings["ROOT"]
+ output._init(config_root=settings['PORTAGE_CONFIGROOT'])
# ========================================================================
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import codecs
+import re
+import time
-import os,time,sys,re
-from stat import *
+from portage import os
+from portage import _encodings
+from portage import _unicode_encode
# [D]/Name/Version/Date/Flags/Tags
filename=os.path.basename(path)
try:
- myfile=open(basedir+"/CVS/Entries","r")
+ myfile = codecs.open(
+ _unicode_encode(os.path.join(basedir, 'CVS', 'Entries'),
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='strict')
except IOError:
return 0
mylines=myfile.readlines()
if not os.path.exists(mydir):
return entries
try:
- myfile=open(myfn, "r")
+ myfile = codecs.open(_unicode_encode(myfn,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='strict')
mylines=myfile.readlines()
myfile.close()
except SystemExit, e:
if file=="digest-framerd-2.4.3":
print "stat'ing"
mystat=os.stat(mydir+"/"+file)
- mytime=time.asctime(time.gmtime(mystat[ST_MTIME]))
+ mytime = time.asctime(time.gmtime(long(mystat.st_mtime)))
if "status" not in entries["files"][file]:
if file=="digest-framerd-2.4.3":
print "status not set"
# This is a special version of the os module, wrapped for unicode support.
from portage import os
+from portage import _content_encoding
from portage import _fs_encoding
from portage import _merge_encoding
from portage import _os_merge
counter, = self.aux_get(cpv, aux_keys)
except KeyError:
continue
- h.update(counter)
+ h.update(_unicode_encode(counter,
+ encoding=_content_encoding, errors='replace'))
return h.hexdigest()
def cpv_inject(self, mycpv):
results.append(long(st.st_mtime))
continue
try:
- myf = codecs.open(_unicode_encode(os.path.join(mydir, x)),
- mode='r', encoding='utf_8', errors='replace')
+ myf = codecs.open(
+ _unicode_encode(os.path.join(mydir, x),
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace')
try:
myd = myf.read()
finally:
new_vdb = False
counter = -1
try:
- cfile = codecs.open(_unicode_encode(self._counter_path), mode='r',
- encoding='utf_8', errors='replace')
+ cfile = codecs.open(
+ _unicode_encode(self._counter_path,
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace')
except EnvironmentError, e:
new_vdb = not bool(self.cpv_all())
if not new_vdb:
h = self._new_hash()
# Always use a constant utf_8 encoding here, since
# the "default" encoding can change.
- h.update(portage._unicode_encode(s))
+ h.update(_unicode_encode(s,
+ encoding=_content_encoding, errors='replace'))
h = h.hexdigest()
h = h[-self._hex_chars:]
h = int(h, 16)
return self.contentscache
pkgfiles = {}
try:
- myc = codecs.open(_unicode_encode(contents_file), mode='r',
- encoding='utf_8', errors='replace')
+ myc = codecs.open(_unicode_encode(contents_file,
+ encoding=_content_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace')
except EnvironmentError, e:
if e.errno != errno.ENOENT:
raise
for var_name in ('CHOST', 'SLOT'):
try:
val = codecs.open(_unicode_encode(
- os.path.join(inforoot, var_name)), mode='r',
- encoding='utf_8', errors='replace').readline().strip()
+ os.path.join(inforoot, var_name),
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace'
+ ).readline().strip()
except EnvironmentError, e:
if e.errno != errno.ENOENT:
raise
# open CONTENTS file (possibly overwriting old one) for recording
outfile = codecs.open(_unicode_encode(
- os.path.join(self.dbtmpdir, 'CONTENTS')),
- mode='w', encoding='utf_8', errors='replace')
+ os.path.join(self.dbtmpdir, 'CONTENTS'),
+ encoding=_fs_encoding, errors='strict'),
+ mode='w', encoding=_content_encoding, errors='replace')
self.updateprotect()
"returns contents of a file with whitespace converted to spaces"
if not os.path.exists(self.dbdir+"/"+name):
return ""
- mydata = codecs.open(_unicode_encode(os.path.join(self.dbdir, name)),
- mode='r', encoding='utf_8', errors='replace').read().split()
+ mydata = codecs.open(
+ _unicode_encode(os.path.join(self.dbdir, name),
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace'
+ ).read().split()
return " ".join(mydata)
def copyfile(self,fname):
def getfile(self,fname):
if not os.path.exists(self.dbdir+"/"+fname):
return ""
- return codecs.open(_unicode_encode(os.path.join(self.dbdir, fname)),
- mode='r', encoding='utf_8', errors='replace').read()
+ return codecs.open(_unicode_encode(os.path.join(self.dbdir, fname),
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace').read()
def setfile(self,fname,data):
mode = 'w'
if not os.path.exists(self.dbdir+"/"+ename):
return []
mylines = codecs.open(_unicode_encode(
- os.path.join(self.dbdir, ename)), mode='r',
- encoding='utf_8', errors='replace').readlines()
+ os.path.join(self.dbdir, ename),
+ encoding=_fs_encoding, errors='strict'),
+ mode='r', encoding=_content_encoding, errors='replace').readlines()
myreturn = []
for x in mylines:
for y in x[:-1].split():
def setelements(self,mylist,ename):
myelement = codecs.open(_unicode_encode(
- os.path.join(self.dbdir, ename)), mode='w',
- encoding='utf_8', errors='replace')
+ os.path.join(self.dbdir, ename),
+ encoding=_fs_encoding, errors='strict'), mode='w',
+ encoding=_content_encoding, errors='replace')
for x in mylist:
myelement.write(x+"\n")
myelement.close()
from portage.cache.mappings import slot_dict_class
from portage.localization import _
import portage
+from portage import os
+from portage import _encodings
+from portage import _unicode_encode
+
import HTMLParser
import sys
-import os
import socket
import time
import tempfile
out = sys.stdout
try:
- metadatafile = open(metadatafilename, 'rb')
+ metadatafile = open(_unicode_encode(metadatafilename,
+ encoding=_encodings['fs'], errors='strict'), 'rb')
mypickle = pickle.Unpickler(metadatafile)
try:
mypickle.find_global = None
sys.stderr.write("!!! "+str(e)+"\n")
sys.stderr.flush()
try:
- metadatafile = open(metadatafilename, 'wb')
+ metadatafile = open(_unicode_encode(metadatafilename,
+ encoding=_encodings['fs'], errors='strict'), 'wb')
pickle.dump(metadata, metadatafile, protocol=2)
metadatafile.close()
except SystemExit, e:
try:
if "modified" in metadata[baseurl] and metadata[baseurl]["modified"]:
metadata[baseurl]["timestamp"] = int(time.time())
- metadatafile = open(metadatafilename, 'wb')
+ metadatafile = open(_unicode_encode(metadatafilename,
+ encoding=_encodings['fs'], errors='strict'), 'wb')
pickle.dump(metadata, metadatafile, protocol=2)
metadatafile.close()
if makepickle:
- metadatafile = open(makepickle, 'wb')
+ metadatafile = open(_unicode_encode(makepickle,
+ encoding=_encodings['fs'], errors='strict'), 'wb')
pickle.dump(metadata[baseurl]["data"], metadatafile, protocol=2)
metadatafile.close()
except SystemExit, e:
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
+import codecs
import sys
import urllib
import re
import xml.dom.minidom
+from portage import os
+from portage import _encodings
+from portage import _unicode_decode
+from portage import _unicode_encode
from portage.versions import pkgsplit, catpkgsplit, pkgcmp, best
from portage.util import grabfile
from portage.const import CACHE_PATH
@type portdbapi: portage.dbapi.porttree.portdbapi
@param portdbapi: ebuild repository
"""
+ myid = _unicode_decode(myid,
+ encoding=_encodings['content'], errors='strict')
if re.match(r'\d{6}-\d{2}', myid):
self.type = "id"
elif os.path.exists(myid):
@returns: None
"""
if not self.isApplied():
- checkfile = open(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"), "a+")
+ checkfile = codecs.open(
+ _unicode_encode(os.path.join(os.sep, self.config["ROOT"],
+ CACHE_PATH.lstrip(os.sep), "glsa"),
+ encoding=_encodings['fs'], errors='strict'),
+ mode='a+', encoding=_encodings['content'], errors='strict')
checkfile.write(self.nr+"\n")
checkfile.close()
return None
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import portage.exception, socket, smtplib, os, sys, time
from email.MIMEText import MIMEText as TextMessage
from email.MIMEMultipart import MIMEMultipart as MultipartMessage
from email.MIMEBase import MIMEBase as BaseMessage
from email.header import Header
+import smtplib
+import socket
+import sys
+import time
+
+from portage import os
+from portage import _content_encoding
+from portage import _unicode_encode
from portage.localization import _
+import portage
def create_message(sender, recipient, subject, body, attachments=None):
if sys.hexversion < 0x3000000:
- if isinstance(sender, unicode):
- sender = sender.encode('utf_8', 'replace')
- if isinstance(recipient, unicode):
- recipient = recipient.encode('utf_8', 'replace')
- if isinstance(subject, unicode):
- subject = subject.encode('utf_8', 'replace')
- if isinstance(body, unicode):
- body = body.encode('utf_8', 'replace')
+ sender = _unicode_encode(sender,
+ encoding=_content_encoding, errors='strict')
+ recipient = _unicode_encode(recipient,
+ encoding=_content_encoding, errors='strict')
+ subject = _unicode_encode(subject,
+ encoding=_content_encoding, errors='replace')
+ body = _unicode_encode(body,
+ encoding=_content_encoding, errors='replace')
if attachments == None:
mymessage = TextMessage(body)
if isinstance(x, BaseMessage):
mymessage.attach(x)
elif isinstance(x, basestring):
- if sys.hexversion < 0x3000000 and isinstance(x, unicode):
- x = x.encode('utf_8', 'replace')
+ if sys.hexversion < 0x3000000:
+ x = _unicode_encode(x,
+ encoding=_content_encoding, errors='replace')
mymessage.attach(TextMessage(x))
else:
raise portage.exception.PortageException(_("Can't handle type of attachment: %s") % type(x))
myfrom = message.get("From")
if sys.hexversion < 0x3000000:
- if isinstance(myrecipient, unicode):
- myrecipient = myrecipient.encode('utf_8', 'replace')
- if isinstance(mymailhost, unicode):
- mymailhost = mymailhost.encode('utf_8', 'replace')
- if isinstance(mymailport, unicode):
- mymailport = mymailport.encode('utf_8', 'replace')
- if isinstance(myfrom, unicode):
- myfrom = myfrom.encode('utf_8', 'replace')
- if isinstance(mymailuser, unicode):
- mymailuser = mymailuser.encode('utf_8', 'replace')
- if isinstance(mymailpasswd, unicode):
- mymailpasswd = mymailpasswd.encode('utf_8', 'replace')
+ myrecipient = _unicode_encode(myrecipient,
+ encoding=_content_encoding, errors='strict')
+ mymailhost = _unicode_encode(mymailhost,
+ encoding=_content_encoding, errors='strict')
+ mymailport = _unicode_encode(mymailport,
+ encoding=_content_encoding, errors='strict')
+ myfrom = _unicode_encode(myfrom,
+ encoding=_content_encoding, errors='strict')
+ mymailuser = _unicode_encode(mymailuser,
+ encoding=_content_encoding, errors='strict')
+ mymailpasswd = _unicode_encode(mymailpasswd,
+ encoding=_content_encoding, errors='strict')
# user wants to use a sendmail binary instead of smtp
if mymailhost[0] == os.sep and os.path.exists(mymailhost):
"""This module contains functions used in Repoman to ascertain the quality
and correctness of an ebuild."""
-import os
import re
import time
import repoman.errors as errors
"parse_metadata_use"
]
+import codecs
import commands
import errno
import itertools
import logging
-import os
import sys
from xml.dom import minidom
from xml.dom import NotFoundErr
from xml.parsers.expat import ExpatError
+from portage import os
+from portage import _encodings
+from portage import _unicode_encode
from portage import output
from portage.output import red, green
from portage.process import find_binary
if not (os.WIFEXITED(retval) and os.WEXITSTATUS(retval) == os.EX_OK):
return None
try:
- mylines = open(filename).readlines()
+ mylines = codecs.open(_unicode_encode(filename,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['content'], errors='replace'
+ ).readlines()
except OSError, e:
if e.errno != errno.ENOENT:
raise