summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-11 08:07:04 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-11 08:07:04 +0000
commitf1131534819bcd66c34b738be2e9e57d901c40d4 (patch)
tree92739615504533cc0443e5252202708f5ca5087c
parent05e04a148b0f3dac7fc484334a2d89b6f9624827 (diff)
downloadportage-f1131534819bcd66c34b738be2e9e57d901c40d4.tar.gz
portage-f1131534819bcd66c34b738be2e9e57d901c40d4.tar.bz2
portage-f1131534819bcd66c34b738be2e9e57d901c40d4.zip
Update imports to import portage.os (with unicode wrappers), and use
_unicode_encode() and _unicode_decode() where appropriate. svn path=/main/trunk/; revision=13994
-rw-r--r--pym/_emerge/Package.py10
-rw-r--r--pym/_emerge/PackageArg.py10
-rw-r--r--pym/_emerge/PackageUninstall.py12
-rw-r--r--pym/_emerge/PackageVirtualDbapi.py9
-rw-r--r--pym/_emerge/PipeReader.py3
-rw-r--r--pym/_emerge/RepoDisplay.py3
-rw-r--r--pym/_emerge/Scheduler.py24
-rw-r--r--pym/_emerge/SpawnProcess.py11
-rw-r--r--pym/_emerge/SubProcess.py3
-rw-r--r--pym/_emerge/TaskSequence.py3
-rw-r--r--pym/_emerge/UninstallFailure.py10
11 files changed, 27 insertions, 71 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index c2eaf0ee6..96d5176ed 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -4,15 +4,7 @@
import re
from itertools import chain
-
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
-
+import portage
from portage.cache.mappings import slot_dict_class
from portage.dep import paren_reduce, use_reduce, \
paren_normalize, paren_enclose
diff --git a/pym/_emerge/PackageArg.py b/pym/_emerge/PackageArg.py
index 0813442fd..f64430e14 100644
--- a/pym/_emerge/PackageArg.py
+++ b/pym/_emerge/PackageArg.py
@@ -3,17 +3,11 @@
# $Id$
from _emerge.DependencyArg import DependencyArg
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
+import portage
+
class PackageArg(DependencyArg):
def __init__(self, package=None, **kwargs):
DependencyArg.__init__(self, **kwargs)
self.package = package
self.atom = portage.dep.Atom("=" + package.cpv)
self.set = (self.atom, )
-
diff --git a/pym/_emerge/PackageUninstall.py b/pym/_emerge/PackageUninstall.py
index 948bae82b..ff1b5e189 100644
--- a/pym/_emerge/PackageUninstall.py
+++ b/pym/_emerge/PackageUninstall.py
@@ -4,16 +4,8 @@
import codecs
import logging
-import os
-
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
-
+import portage
+from portage import os
from _emerge.AsynchronousTask import AsynchronousTask
from _emerge.unmerge import unmerge
from _emerge.UninstallFailure import UninstallFailure
diff --git a/pym/_emerge/PackageVirtualDbapi.py b/pym/_emerge/PackageVirtualDbapi.py
index 86d150fa3..f041e1d8c 100644
--- a/pym/_emerge/PackageVirtualDbapi.py
+++ b/pym/_emerge/PackageVirtualDbapi.py
@@ -2,13 +2,8 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
+import portage
+
class PackageVirtualDbapi(portage.dbapi):
"""
A dbapi-like interface class that represents the state of the installed
diff --git a/pym/_emerge/PipeReader.py b/pym/_emerge/PipeReader.py
index d3cc18425..5b64306e7 100644
--- a/pym/_emerge/PipeReader.py
+++ b/pym/_emerge/PipeReader.py
@@ -2,12 +2,13 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
from _emerge.PollConstants import PollConstants
import sys
-import os
import fcntl
import array
+
class PipeReader(AbstractPollTask):
"""
diff --git a/pym/_emerge/RepoDisplay.py b/pym/_emerge/RepoDisplay.py
index 420569770..a954aebfa 100644
--- a/pym/_emerge/RepoDisplay.py
+++ b/pym/_emerge/RepoDisplay.py
@@ -3,7 +3,8 @@
# $Id$
from portage.output import teal
-import os
+from portage import os
+
class RepoDisplay(object):
def __init__(self, roots):
self._shown_repos = {}
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index ec6135d32..cef4ee6ca 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -4,20 +4,13 @@
import codecs
import logging
-import os
import sys
import textwrap
import time
import weakref
from itertools import izip
-
-try:
- import portage
-except ImportError:
- from os import path as osp
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
-
+import portage
+from portage import os
from portage.cache.mappings import slot_dict_class
from portage.elog.messages import eerror
from portage.output import colorize, create_color_func, darkgreen, red
@@ -478,13 +471,10 @@ class Scheduler(PollScheduler):
def _append_to_log_path(self, log_path, msg):
- if not isinstance(msg, unicode):
- msg = unicode(msg, encoding='utf_8', errors='replace')
-
- f = codecs.open(log_path, mode='a',
+ f = codecs.open(portage._unicode_encode(log_path), mode='a',
encoding='utf_8', errors='replace')
try:
- f.write(msg)
+ f.write(portage._unicode_decode(msg))
finally:
f.close()
@@ -496,7 +486,7 @@ class Scheduler(PollScheduler):
background = self._background
if background and log_path is not None:
- log_file = codecs.open(log_path, mode='a',
+ log_file = codecs.open(portage._unicode_encode(log_path), mode='a',
encoding='utf_8', errors='replace')
out = log_file
@@ -872,8 +862,8 @@ class Scheduler(PollScheduler):
log_path = self._locate_failure_log(failed_pkg)
if log_path is not None:
try:
- log_file = codecs.open(log_path, mode='r',
- encoding='utf_8', errors='replace')
+ log_file = codecs.open(portage._unicode_encode(log_path),
+ mode='r', encoding='utf_8', errors='replace')
except IOError:
pass
diff --git a/pym/_emerge/SpawnProcess.py b/pym/_emerge/SpawnProcess.py
index 4c6065ed1..e6b3cc7a0 100644
--- a/pym/_emerge/SpawnProcess.py
+++ b/pym/_emerge/SpawnProcess.py
@@ -6,17 +6,12 @@ from _emerge.SubProcess import SubProcess
from _emerge.PollConstants import PollConstants
import sys
from portage.cache.mappings import slot_dict_class
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
-import os
+import portage
+from portage import os
import fcntl
import errno
import array
+
class SpawnProcess(SubProcess):
"""
diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py
index 37957c394..6bd4562d4 100644
--- a/pym/_emerge/SubProcess.py
+++ b/pym/_emerge/SubProcess.py
@@ -2,10 +2,11 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
import signal
-import os
import errno
+
class SubProcess(AbstractPollTask):
__slots__ = ("pid",) + \
diff --git a/pym/_emerge/TaskSequence.py b/pym/_emerge/TaskSequence.py
index 3d54d90ac..44eaa332c 100644
--- a/pym/_emerge/TaskSequence.py
+++ b/pym/_emerge/TaskSequence.py
@@ -2,10 +2,11 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.CompositeTask import CompositeTask
from _emerge.AsynchronousTask import AsynchronousTask
-import os
from collections import deque
+
class TaskSequence(CompositeTask):
"""
A collection of tasks that executes sequentially. Each task
diff --git a/pym/_emerge/UninstallFailure.py b/pym/_emerge/UninstallFailure.py
index 7dbf1c1c5..ceb5a58e2 100644
--- a/pym/_emerge/UninstallFailure.py
+++ b/pym/_emerge/UninstallFailure.py
@@ -2,14 +2,8 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-try:
- import portage
-except ImportError:
- from os import path as osp
- import sys
- sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
- import portage
-
+import portage
+
class UninstallFailure(portage.exception.PortageException):
"""
An instance of this class is raised by unmerge() when