From: Zac Medico Date: Tue, 11 Aug 2009 07:47:27 +0000 (-0000) Subject: Update imports to import portage.os (with unicode wrappers), and use X-Git-Tag: v2.2_rc39~112 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=05e04a148b0f3dac7fc484334a2d89b6f9624827;p=portage.git Update imports to import portage.os (with unicode wrappers), and use _unicode_encode() and _unicode_decode() where appropriate. svn path=/main/trunk/; revision=13993 --- diff --git a/bin/archive-conf b/bin/archive-conf index 04c6ce414..aca8d285c 100755 --- a/bin/archive-conf +++ b/bin/archive-conf @@ -10,7 +10,7 @@ # Jeremy Wohl's dispatch-conf script and the portage chkcontents script. # -import os, sys +import sys try: import portage except ImportError: @@ -18,6 +18,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os import dispatch_conf FIND_EXTANT_CONTENTS = "find %s -name CONTENTS" diff --git a/bin/clean_locks b/bin/clean_locks index 89473bd81..9799ad999 100755 --- a/bin/clean_locks +++ b/bin/clean_locks @@ -3,13 +3,15 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os,sys,errno +import sys, errno try: - import portage.locks + 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.locks + import portage + +from portage import os if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: import portage diff --git a/bin/dispatch-conf b/bin/dispatch-conf index 0b96ee54a..68fd3e899 100755 --- a/bin/dispatch-conf +++ b/bin/dispatch-conf @@ -17,7 +17,7 @@ if not hasattr(__builtins__, "set"): from stat import * from random import * -import atexit, commands, os, re, shutil, stat, sys +import atexit, commands, re, shutil, stat, sys try: import portage except ImportError: @@ -25,6 +25,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os from portage import dispatch_conf from portage.process import find_binary diff --git a/bin/ebuild b/bin/ebuild index 8e1d4432f..3362dff4c 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -62,6 +62,8 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os + if not opts.ignore_default_opts: default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split() opts, pargs = parser.parse_args(default_opts + sys.argv[1:]) diff --git a/bin/egencache b/bin/egencache index f5c644be9..db0eb622d 100755 --- a/bin/egencache +++ b/bin/egencache @@ -21,7 +21,6 @@ except KeyboardInterrupt: import logging import optparse -import os try: import portage @@ -30,6 +29,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision from portage.util import writemsg_level diff --git a/bin/emaint b/bin/emaint index 0bfc88de5..6652b6ed5 100755 --- a/bin/emaint +++ b/bin/emaint @@ -1,6 +1,5 @@ #!/usr/bin/python -O # vim: noet : -import os import re import signal import sys @@ -15,7 +14,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage -import portage.const, portage.exception, portage.output +from portage import os class WorldHandler(object): diff --git a/bin/env-update b/bin/env-update index 294876808..30e25d0b2 100755 --- a/bin/env-update +++ b/bin/env-update @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os, sys, errno +import sys, errno def usage(status): print "Usage: env-update [--no-ldconfig]" diff --git a/bin/fixpackages b/bin/fixpackages index 39b813662..a5f24a7e5 100755 --- a/bin/fixpackages +++ b/bin/fixpackages @@ -12,6 +12,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os mysettings = portage.settings mytrees = portage.db mtimedb = portage.mtimedb diff --git a/bin/glsa-check b/bin/glsa-check index 74a9ee7d0..ad06136e2 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -3,7 +3,6 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os import sys try: @@ -13,6 +12,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os from portage.output import * from optparse import OptionGroup, OptionParser diff --git a/bin/portageq b/bin/portageq index e18760ce8..8cb7a2b13 100755 --- a/bin/portageq +++ b/bin/portageq @@ -41,6 +41,7 @@ except ImportError: import portage del pym_path +from portage import os from portage.util import writemsg, writemsg_stdout #----------------------------------------------------------------------------- @@ -609,7 +610,7 @@ def main(): args = sys.argv[2:] if args and not isinstance(args[0], unicode): for i in xrange(len(args)): - args[i] = unicode(args[i], encoding='utf_8', errors='replace') + args[i] = portage._unicode_decode(args[i]) try: if uses_root: diff --git a/bin/quickpkg b/bin/quickpkg index 0a1346e4e..53f7e9b27 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import errno, signal, sys, os +import errno, signal, sys from itertools import izip try: @@ -13,6 +13,8 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage +from portage import os + def quickpkg_main(options, args, eout): from portage import catsplit, dep_expand, flatten, isvalidatom, xpak from portage.dep import use_reduce, paren_reduce diff --git a/bin/regenworld b/bin/regenworld index 11c6ea033..5d59d83f7 100755 --- a/bin/regenworld +++ b/bin/regenworld @@ -3,13 +3,15 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import sys, os +import sys 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 + +from portage import os import re import portage.exception diff --git a/bin/repoman b/bin/repoman index 8e0b8e428..368902255 100755 --- a/bin/repoman +++ b/bin/repoman @@ -13,7 +13,6 @@ import errno import formatter import logging import optparse -import os import re import signal import stat @@ -40,6 +39,7 @@ except ImportError: sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) import portage portage._disable_legacy_globals() +from portage import os try: from repoman.checks import run_checks diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index 89f9925cc..00c6620fd 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -10,16 +10,11 @@ from _emerge.BinpkgVerifier import BinpkgVerifier from _emerge.EbuildMerge import EbuildMerge from _emerge.EbuildBuildDir import EbuildBuildDir from portage.util import writemsg -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 import codecs -import os from portage.output import colorize + class Binpkg(CompositeTask): __slots__ = ("find_blockers", diff --git a/pym/_emerge/BinpkgFetcher.py b/pym/_emerge/BinpkgFetcher.py index f3b11bb6c..e72799a1d 100644 --- a/pym/_emerge/BinpkgFetcher.py +++ b/pym/_emerge/BinpkgFetcher.py @@ -5,15 +5,9 @@ from _emerge.SpawnProcess import SpawnProcess import urlparse import sys +import portage +from portage 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 os class BinpkgFetcher(SpawnProcess): __slots__ = ("pkg", "pretend", diff --git a/pym/_emerge/BinpkgPrefetcher.py b/pym/_emerge/BinpkgPrefetcher.py index a1e63fd32..4e637db03 100644 --- a/pym/_emerge/BinpkgPrefetcher.py +++ b/pym/_emerge/BinpkgPrefetcher.py @@ -5,7 +5,8 @@ from _emerge.BinpkgFetcher import BinpkgFetcher from _emerge.CompositeTask import CompositeTask from _emerge.BinpkgVerifier import BinpkgVerifier -import os +from portage import os + class BinpkgPrefetcher(CompositeTask): __slots__ = ("pkg",) + \ diff --git a/pym/_emerge/BinpkgVerifier.py b/pym/_emerge/BinpkgVerifier.py index e0bd82203..31599e2e2 100644 --- a/pym/_emerge/BinpkgVerifier.py +++ b/pym/_emerge/BinpkgVerifier.py @@ -5,15 +5,10 @@ from _emerge.AsynchronousTask import AsynchronousTask from portage.util import writemsg import sys -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 import codecs -import os + class BinpkgVerifier(AsynchronousTask): __slots__ = ("logfile", "pkg",) diff --git a/pym/_emerge/BlockerCache.py b/pym/_emerge/BlockerCache.py index cb8059eab..7b797ebbd 100644 --- a/pym/_emerge/BlockerCache.py +++ b/pym/_emerge/BlockerCache.py @@ -4,18 +4,14 @@ from portage.util import writemsg from portage.data import secpass -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 + try: import cPickle as pickle except ImportError: import pickle -import os + class BlockerCache(portage.cache.mappings.MutableMapping): """This caches blockers of installed packages so that dep_check does not have to be done for every single installed package on every invocation of diff --git a/pym/_emerge/BlockerDB.py b/pym/_emerge/BlockerDB.py index 7d8c86cc9..436793c59 100644 --- a/pym/_emerge/BlockerDB.py +++ b/pym/_emerge/BlockerDB.py @@ -2,16 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -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 portage import digraph from portage.sets.base import InternalPackageSet diff --git a/pym/_emerge/CompositeTask.py b/pym/_emerge/CompositeTask.py index 25de4dcf3..a9de7a1ab 100644 --- a/pym/_emerge/CompositeTask.py +++ b/pym/_emerge/CompositeTask.py @@ -3,7 +3,8 @@ # $Id$ from _emerge.AsynchronousTask import AsynchronousTask -import os +from portage import os + class CompositeTask(AsynchronousTask): __slots__ = ("scheduler",) + ("_current_task",) diff --git a/pym/_emerge/EbuildBinpkg.py b/pym/_emerge/EbuildBinpkg.py index 4f5159d78..8d742d640 100644 --- a/pym/_emerge/EbuildBinpkg.py +++ b/pym/_emerge/EbuildBinpkg.py @@ -3,7 +3,8 @@ # $Id$ from _emerge.EbuildProcess import EbuildProcess -import os +from portage import os + class EbuildBinpkg(EbuildProcess): """ This assumes that src_install() has successfully completed. diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index 4bfd817ad..f56adb660 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -11,15 +11,9 @@ from _emerge.EbuildMerge import EbuildMerge from _emerge.EbuildFetchonly import EbuildFetchonly from _emerge.EbuildBuildDir import EbuildBuildDir from portage.util import writemsg -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 import codecs -import os from portage.output import colorize class EbuildBuild(CompositeTask): diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py index 1a940e020..d9f819966 100644 --- a/pym/_emerge/EbuildBuildDir.py +++ b/pym/_emerge/EbuildBuildDir.py @@ -3,15 +3,10 @@ # $Id$ from _emerge.SlotObject import SlotObject -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 errno + class EbuildBuildDir(SlotObject): __slots__ = ("dir_path", "pkg", "settings", diff --git a/pym/_emerge/EbuildExecuter.py b/pym/_emerge/EbuildExecuter.py index c47374721..055a8fa47 100644 --- a/pym/_emerge/EbuildExecuter.py +++ b/pym/_emerge/EbuildExecuter.py @@ -5,14 +5,9 @@ from _emerge.EbuildPhase import EbuildPhase from _emerge.TaskSequence import TaskSequence from _emerge.CompositeTask import CompositeTask -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 + class EbuildExecuter(CompositeTask): __slots__ = ("pkg", "scheduler", "settings") + ("_tree",) diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index e8f810243..6ce72b9e3 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -5,16 +5,11 @@ from _emerge.SpawnProcess import SpawnProcess from _emerge.EbuildBuildDir import EbuildBuildDir import sys -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 import codecs -import os from portage.elog.messages import eerror + class EbuildFetcher(SpawnProcess): __slots__ = ("config_pool", "fetchonly", "fetchall", "pkg", "prefetch") + \ diff --git a/pym/_emerge/EbuildFetchonly.py b/pym/_emerge/EbuildFetchonly.py index 82e11065a..d65e2b2b1 100644 --- a/pym/_emerge/EbuildFetchonly.py +++ b/pym/_emerge/EbuildFetchonly.py @@ -4,15 +4,10 @@ from _emerge.SlotObject import SlotObject import shutil -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 from portage.elog.messages import eerror + class EbuildFetchonly(SlotObject): __slots__ = ("fetch_all", "pkg", "pretend", "settings") diff --git a/pym/_emerge/EbuildMerge.py b/pym/_emerge/EbuildMerge.py index 235f8b881..1ac03706e 100644 --- a/pym/_emerge/EbuildMerge.py +++ b/pym/_emerge/EbuildMerge.py @@ -3,14 +3,9 @@ # $Id$ from _emerge.SlotObject import SlotObject -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 + class EbuildMerge(SlotObject): __slots__ = ("find_blockers", "logger", "ldpath_mtimes", diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index 8e488d306..a84d722be 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.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 from itertools import izip import fcntl import codecs + class EbuildMetadataPhase(SubProcess): """ diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index 22b9f8bcb..598dcf7e3 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -6,15 +6,10 @@ from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from _emerge.EbuildProcess import EbuildProcess from _emerge.CompositeTask import CompositeTask from portage.util import writemsg -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 import codecs -import os + class EbuildPhase(CompositeTask): __slots__ = ("background", "pkg", "phase", diff --git a/pym/_emerge/EbuildProcess.py b/pym/_emerge/EbuildProcess.py index 2b625ee32..86a63282f 100644 --- a/pym/_emerge/EbuildProcess.py +++ b/pym/_emerge/EbuildProcess.py @@ -3,14 +3,9 @@ # $Id$ from _emerge.SpawnProcess import SpawnProcess -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 + class EbuildProcess(SpawnProcess): __slots__ = ("phase", "pkg", "settings", "tree") diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py index 5df52b3f7..c4eec6d68 100644 --- a/pym/_emerge/FakeVartree.py +++ b/pym/_emerge/FakeVartree.py @@ -2,17 +2,9 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os 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 _emerge.Package import Package from _emerge.PackageVirtualDbapi import PackageVirtualDbapi diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py index 97d2a33f2..6aa2d99b7 100644 --- a/pym/_emerge/JobStatusDisplay.py +++ b/pym/_emerge/JobStatusDisplay.py @@ -3,7 +3,6 @@ # $Id$ import formatter -import os import sys import time @@ -12,13 +11,8 @@ try: except ImportError: from StringIO import StringIO -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 xtermTitle from _emerge.getloadavg import getloadavg @@ -76,7 +70,7 @@ class JobStatusDisplay(object): def _write(self, s): if sys.hexversion < 0x3000000 and isinstance(s, unicode): # avoid potential UnicodeEncodeError - s = s.encode('utf_8', 'replace') + s = portage._unicode_encode(s) self.out.write(s) self.out.flush() diff --git a/pym/_emerge/MergeListItem.py b/pym/_emerge/MergeListItem.py index aab79da08..7e4556ec2 100644 --- a/pym/_emerge/MergeListItem.py +++ b/pym/_emerge/MergeListItem.py @@ -2,8 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os - +from portage import os from portage.output import colorize from _emerge.Binpkg import Binpkg diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py index a6a48deaa..ee6eb997a 100644 --- a/pym/_emerge/MetadataRegen.py +++ b/pym/_emerge/MetadataRegen.py @@ -2,16 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -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.EbuildMetadataPhase import EbuildMetadataPhase from _emerge.PollScheduler import PollScheduler diff --git a/pym/_emerge/MiscFunctionsProcess.py b/pym/_emerge/MiscFunctionsProcess.py index df45c679b..3e2fff7cc 100644 --- a/pym/_emerge/MiscFunctionsProcess.py +++ b/pym/_emerge/MiscFunctionsProcess.py @@ -3,14 +3,9 @@ # $Id$ from _emerge.SpawnProcess import SpawnProcess -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 + class MiscFunctionsProcess(SpawnProcess): """ Spawns misc-functions.sh with an existing ebuild environment.