summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-11 08:32:14 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-11 08:32:14 +0000
commit4f464c6cb06493b49e8475a09d3d9815c97a7d96 (patch)
tree518210f51cba0c7234e108663a1de717ac59feaf
parentf1131534819bcd66c34b738be2e9e57d901c40d4 (diff)
downloadportage-4f464c6cb06493b49e8475a09d3d9815c97a7d96.tar.gz
portage-4f464c6cb06493b49e8475a09d3d9815c97a7d96.tar.bz2
portage-4f464c6cb06493b49e8475a09d3d9815c97a7d96.zip
Update imports to import portage.os (with unicode wrappers), and use
_unicode_encode() and _unicode_decode() where appropriate. svn path=/main/trunk/; revision=13995
-rw-r--r--pym/_emerge/actions.py10
-rw-r--r--pym/_emerge/changelog.py14
-rw-r--r--pym/_emerge/clear_caches.py9
-rw-r--r--pym/_emerge/create_world_atom.py8
-rw-r--r--pym/_emerge/depgraph.py10
-rw-r--r--pym/_emerge/emergelog.py21
-rw-r--r--pym/_emerge/getloadavg.py2
-rw-r--r--pym/_emerge/is_valid_package_atom.py9
-rw-r--r--pym/_emerge/main.py13
-rw-r--r--pym/_emerge/search.py12
-rw-r--r--pym/_emerge/show_invalid_depstring_notice.py12
-rw-r--r--pym/_emerge/unmerge.py11
-rw-r--r--pym/_emerge/visible.py8
13 files changed, 29 insertions, 110 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 5bd789c1f..25c82323e 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -5,7 +5,6 @@
import commands
import errno
import logging
-import os
import platform
import pwd
import re
@@ -17,13 +16,8 @@ import textwrap
import time
from itertools import chain, 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 import digraph
from portage.cache.cache_errors import CacheError
from portage.const import NEWS_LIB_PATH
diff --git a/pym/_emerge/changelog.py b/pym/_emerge/changelog.py
index 762cae024..4adb8b25b 100644
--- a/pym/_emerge/changelog.py
+++ b/pym/_emerge/changelog.py
@@ -3,16 +3,10 @@
# $Id$
import codecs
-import os
import re
-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
def calc_changelog(ebuildpath,current,next):
if ebuildpath == None or not os.path.exists(ebuildpath):
@@ -25,8 +19,8 @@ def calc_changelog(ebuildpath,current,next):
next = next[:-3]
changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog')
try:
- changelog = codecs.open(changelogpath, mode='r',
- encoding='utf_8', errors='replace').read()
+ changelog = codecs.open(portage._unicode_encode(changelogpath),
+ mode='r', encoding='utf_8', errors='replace').read()
except SystemExit, e:
raise # Needed else can't exit
except:
diff --git a/pym/_emerge/clear_caches.py b/pym/_emerge/clear_caches.py
index 1c82b6e2f..1fd667f36 100644
--- a/pym/_emerge/clear_caches.py
+++ b/pym/_emerge/clear_caches.py
@@ -3,14 +3,7 @@
# $Id$
import gc
-
-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
def clear_caches(trees):
for d in trees.itervalues():
diff --git a/pym/_emerge/create_world_atom.py b/pym/_emerge/create_world_atom.py
index b2e7d151d..30ade0acf 100644
--- a/pym/_emerge/create_world_atom.py
+++ b/pym/_emerge/create_world_atom.py
@@ -2,13 +2,7 @@
# 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
def create_world_atom(pkg, args_set, root_config):
"""Create a new atom for the world file if one does not exist. If the
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 7de993464..9010fddfa 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3,19 +3,13 @@
# $Id$
import gc
-import os
import re
import sys
import textwrap
from itertools import chain, 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 import digraph
from portage.output import bold, blue, colorize, create_color_func, darkblue, \
darkgreen, green, nc_len, red, teal, turquoise, yellow
diff --git a/pym/_emerge/emergelog.py b/pym/_emerge/emergelog.py
index 1a26cc9fa..01de27a4a 100644
--- a/pym/_emerge/emergelog.py
+++ b/pym/_emerge/emergelog.py
@@ -3,28 +3,21 @@
# $Id$
import codecs
-import os
import sys
import time
-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.data import secpass
from portage.output import xtermTitle
-
+
_emerge_log_dir = '/var/log'
def emergelog(xterm_titles, mystr, short_msg=None):
- if not isinstance(mystr, unicode):
- mystr = unicode(mystr, encoding='utf_8', errors='replace')
+ mystr = portage._unicode_decode(mystr)
- if short_msg is not None and not isinstance(short_msg, unicode):
- short_msg = unicode(short_msg, encoding='utf_8', errors='replace')
+ if short_msg is not None:
+ short_msg = portage._unicode_decode(short_msg)
if xterm_titles and short_msg:
if "HOSTNAME" in os.environ:
@@ -32,7 +25,7 @@ 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(file_path, mode='a',
+ mylogfile = codecs.open(portage._unicode_encode(file_path), mode='a',
encoding='utf_8', errors='replace')
portage.util.apply_secpass_permissions(file_path,
uid=portage.portage_uid, gid=portage.portage_gid,
diff --git a/pym/_emerge/getloadavg.py b/pym/_emerge/getloadavg.py
index 81265d500..d252e8c0a 100644
--- a/pym/_emerge/getloadavg.py
+++ b/pym/_emerge/getloadavg.py
@@ -2,7 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
+from portage import os
getloadavg = getattr(os, "getloadavg", None)
if getloadavg is None:
diff --git a/pym/_emerge/is_valid_package_atom.py b/pym/_emerge/is_valid_package_atom.py
index 0dd3e9b44..11920be30 100644
--- a/pym/_emerge/is_valid_package_atom.py
+++ b/pym/_emerge/is_valid_package_atom.py
@@ -3,14 +3,7 @@
# $Id$
import re
-
-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
def is_valid_package_atom(x):
if "/" not in x:
diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py
index 909cb5eae..8e9a8a22a 100644
--- a/pym/_emerge/main.py
+++ b/pym/_emerge/main.py
@@ -6,16 +6,9 @@ import logging
import signal
import sys
import textwrap
-import os
import platform
-
-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
import _emerge.help
import portage.xpak, commands, errno, re, time
from portage.output import colorize, xtermTitle, xtermTitleReset
@@ -750,7 +743,7 @@ def parse_opts(tmpcmdline, silent=False):
if myargs and not isinstance(myargs[0], unicode):
for i in xrange(len(myargs)):
- myargs[i] = unicode(myargs[i], encoding='utf_8', errors='replace')
+ myargs[i] = portage._unicode_decode(myargs[i])
myfiles += myargs
diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index afbd1d557..1f276b47e 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -2,18 +2,10 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
import re
from itertools import izip
-
-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 portage.output import bold, bold as white, darkgreen, green, red
from portage.util import writemsg_stdout
diff --git a/pym/_emerge/show_invalid_depstring_notice.py b/pym/_emerge/show_invalid_depstring_notice.py
index 6ffcc81f5..4d374fcd0 100644
--- a/pym/_emerge/show_invalid_depstring_notice.py
+++ b/pym/_emerge/show_invalid_depstring_notice.py
@@ -3,17 +3,9 @@
# $Id$
import logging
-import os
import textwrap
-
-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 portage.util import writemsg_level
def show_invalid_depstring_notice(parent_node, depstring, error_msg):
diff --git a/pym/_emerge/unmerge.py b/pym/_emerge/unmerge.py
index 667e5a517..25c3e4e4f 100644
--- a/pym/_emerge/unmerge.py
+++ b/pym/_emerge/unmerge.py
@@ -3,18 +3,11 @@
# $Id$
import logging
-import os
import sys
import textwrap
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.output import bold, colorize, darkgreen, green
from portage.sets import SETPREFIX
from portage.util import cmp_sort_key
diff --git a/pym/_emerge/visible.py b/pym/_emerge/visible.py
index 6b013b4a4..f2af7c5c1 100644
--- a/pym/_emerge/visible.py
+++ b/pym/_emerge/visible.py
@@ -2,13 +2,7 @@
# 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
def visible(pkgsettings, pkg):
"""