aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:55:51 +0600
committerAlexander Bersenev <bay@hackerdom.ru>2014-02-17 17:55:51 +0600
commit5a3f506c9ef1cfd78940b0509f10ef94b4434e29 (patch)
tree147c35a17a8bcd8ff467bb3063adab623da51fac /portage_with_autodep/pym/portage/_sets/__init__.py
parentfixed a deadlock (diff)
downloadautodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.tar.gz
autodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.tar.bz2
autodep-5a3f506c9ef1cfd78940b0509f10ef94b4434e29.zip
updated portage to 2.2.8-r1
Diffstat (limited to 'portage_with_autodep/pym/portage/_sets/__init__.py')
-rw-r--r--portage_with_autodep/pym/portage/_sets/__init__.py45
1 files changed, 40 insertions, 5 deletions
diff --git a/portage_with_autodep/pym/portage/_sets/__init__.py b/portage_with_autodep/pym/portage/_sets/__init__.py
index 1b3484e..88a4b3b 100644
--- a/portage_with_autodep/pym/portage/_sets/__init__.py
+++ b/portage_with_autodep/pym/portage/_sets/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2007 Gentoo Foundation
+# Copyright 2007-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from __future__ import print_function
@@ -6,16 +6,27 @@ from __future__ import print_function
__all__ = ["SETPREFIX", "get_boolean", "SetConfigError",
"SetConfig", "load_default_config"]
+import io
+import logging
+import sys
try:
- from configparser import SafeConfigParser, NoOptionError
+ from configparser import NoOptionError, ParsingError
+ if sys.hexversion >= 0x3020000:
+ from configparser import ConfigParser as SafeConfigParser
+ else:
+ from configparser import SafeConfigParser
except ImportError:
- from ConfigParser import SafeConfigParser, NoOptionError
+ from ConfigParser import SafeConfigParser, NoOptionError, ParsingError
from portage import os
from portage import load_mod
+from portage import _unicode_decode
+from portage import _unicode_encode
+from portage import _encodings
from portage.const import USER_CONFIG_PATH, GLOBAL_CONFIG_PATH
from portage.const import _ENABLE_SET_CONFIG
from portage.exception import PackageSetNotFound
from portage.localization import _
+from portage.util import writemsg_level
SETPREFIX = "@"
@@ -43,7 +54,32 @@ class SetConfig(object):
})
if _ENABLE_SET_CONFIG:
- self._parser.read(paths)
+ # use read_file/readfp in order to control decoding of unicode
+ try:
+ # Python >=3.2
+ read_file = self._parser.read_file
+ except AttributeError:
+ read_file = self._parser.readfp
+
+ for p in paths:
+ f = None
+ try:
+ f = io.open(_unicode_encode(p,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='r', encoding=_encodings['repo.content'],
+ errors='replace')
+ except EnvironmentError:
+ pass
+ else:
+ try:
+ read_file(f)
+ except ParsingError as e:
+ writemsg_level(_unicode_decode(
+ _("!!! Error while reading sets config file: %s\n")
+ ) % e, level=logging.ERROR, noiselevel=-1)
+ finally:
+ if f is not None:
+ f.close()
else:
self._create_default_config()
@@ -201,7 +237,6 @@ class SetConfig(object):
except KeyError:
raise PackageSetNotFound(setname)
myatoms = myset.getAtoms()
- parser = self._parser
if ignorelist is None:
ignorelist = set()