From 6e6ce6c1ed8501fd7f996526d4e4bdce6dc6c6da Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Mon, 24 Aug 2009 09:31:55 +0000 Subject: [PATCH] Merged from trunk -r14077:14087 | 14078 | Use portage.os, _content_encoding, and _fs_encoding where | | zmedico | appropriate. | | 14079 | Enable error='strict' when encoding arguments inside | | zmedico | _unicode_func_wrapper(), and document behavior. | | 14080 | Use portage.os, _content_encoding, and _fs_encoding where | | zmedico | appropriate. | | 14081 | Bug #277619 - Fix news item relevance logic. Thanks to Alec | | zmedico | Warner for this patch. | | 14082 | Use st_* attributes instead of the stat module. | | zmedico | | | 14083 | Implement lazy loading of color.map when either the codes or | | zmedico | _styles attribute is accessed. This provides and | | | _init(config_root='/') function that the prefix branch can | | | use to substitute an appropriate config_root value at | | | runtime. | | 14084 | Use _content_encoding and _fs_encoding where appropriate. | | zmedico | | | 14085 | Use _content_encoding and _fs_encoding where appropriate. | | zmedico | Also, enable strict exceptions for unicode encoding | | | failures. | | 14086 | Bug #270866 - Validate News-Item-Format headers. | | zmedico | | | 14087 | Don't wrap os.popen(). | | zmedico | | svn path=/main/branches/prefix/; revision=14139 --- pym/portage/__init__.py | 20 ++++-- pym/portage/_selinux.py | 38 +++++----- pym/portage/dispatch_conf.py | 9 ++- pym/portage/locks.py | 5 +- pym/portage/news.py | 66 ++++++++++++----- pym/portage/output.py | 70 ++++++++++++++----- pym/portage/tests/bin/setup_env.py | 12 ++-- pym/portage/tests/ebuild/test_spawn.py | 12 +++- .../env/config/test_PackageKeywordsFile.py | 3 +- .../tests/env/config/test_PackageMaskFile.py | 3 +- .../tests/env/config/test_PackageUseFile.py | 2 +- .../env/config/test_PortageModulesFile.py | 5 +- pym/portage/tests/news/test_NewsItem.py | 3 +- pym/portage/tests/process/test_poll.py | 7 +- .../tests/sets/files/testConfigFileSet.py | 3 +- .../tests/sets/files/testStaticFileSet.py | 5 +- pym/portage/tests/util/test_uniqueArray.py | 3 +- 17 files changed, 178 insertions(+), 88 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 390c1de96..74ad998ff 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -145,7 +145,13 @@ def _unicode_decode(s, encoding=_content_encoding, errors='replace'): class _unicode_func_wrapper(object): """ Wraps a function, converts arguments from unicode to bytes, - and return values to unicode from bytes. + and return values to unicode from bytes. Function calls + will raise UnicodeEncodeError if an argument fails to be + encoded with the required encoding. Return values that + are single strings are decoded with errors='replace'. Return + values that are lists of strings are decoded with errors='strict' + and elements that fail to be decoded are omitted from the returned + list. """ __slots__ = ('_func', '_encoding') @@ -156,10 +162,12 @@ class _unicode_func_wrapper(object): def __call__(self, *args, **kwargs): encoding = self._encoding - wrapped_args = [_unicode_encode(x) for x in args] + wrapped_args = [_unicode_encode(x, encoding=encoding, errors='strict') + for x in args] if kwargs: - wrapped_kwargs = dict((_unicode_encode(k, encoding=encoding), - _unicode_encode(v, encoding=encoding)) \ + wrapped_kwargs = dict( + (_unicode_encode(k, encoding=encoding, errors='strict'), + _unicode_encode(v, encoding=encoding, errors='strict')) for k, v in kwargs.iteritems()) else: wrapped_kwargs = {} @@ -168,7 +176,8 @@ class _unicode_func_wrapper(object): if isinstance(rval, (basestring, list, tuple)): if isinstance(rval, basestring): - rval = _unicode_decode(rval, encoding=encoding) + rval = _unicode_decode(rval, + encoding=encoding, errors='replace') else: decoded_rval = [] for x in rval: @@ -218,6 +227,7 @@ class _unicode_module_wrapper(object): import os as _os _os_overrides = { id(_os.fdopen) : _os.fdopen, + id(_os.popen) : _os.popen, id(_os.read) : _os.read, id(_os.system) : _os.system, } diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py index 71ec0a46e..9c0f08299 100644 --- a/pym/portage/_selinux.py +++ b/pym/portage/_selinux.py @@ -7,15 +7,17 @@ import os import shutil -import portage +from portage import _content_encoding +from portage import _fs_encoding +from portage import _unicode_encode from portage.localization import _ import selinux -from selinux import is_selinux_enabled, getfilecon, lgetfilecon +from selinux import is_selinux_enabled def copyfile(src, dest): - src = portage._unicode_encode(src) - dest = portage._unicode_encode(dest) + src = _unicode_encode(src, encoding=_fs_encoding, errors='strict') + dest = _unicode_encode(dest, encoding=_fs_encoding, errors='strict') (rc, ctx) = selinux.lgetfilecon(src) if rc < 0: raise OSError(_("copyfile: Failed getting context of \"%s\".") % src) @@ -34,23 +36,23 @@ def getcontext(): return ctx def mkdir(target, refdir): - target = portage._unicode_encode(target) - refdir = portage._unicode_encode(refdir) + target = _unicode_encode(target, encoding=_fs_encoding, errors='strict') + refdir = _unicode_encode(refdir, encoding=_fs_encoding, errors='strict') (rc, ctx) = selinux.getfilecon(refdir) if rc < 0: raise OSError( _("mkdir: Failed getting context of reference directory \"%s\".") \ % refdir) - setfscreatecon(ctx) + selinux.setfscreatecon(ctx) try: os.mkdir(target) finally: - setfscreatecon() + selinux.setfscreatecon() def rename(src, dest): - src = portage._unicode_encode(src) - dest = portage._unicode_encode(dest) + src = _unicode_encode(src, encoding=_fs_encoding, errors='strict') + dest = _unicode_encode(dest, encoding=_fs_encoding, errors='strict') (rc, ctx) = selinux.lgetfilecon(src) if rc < 0: raise OSError(_("rename: Failed getting context of \"%s\".") % src) @@ -67,21 +69,23 @@ def settype(newtype): return ":".join(ret) def setexec(ctx="\n"): - if isinstance(ctx, unicode): - ctx = ctx.encode('utf_8', 'replace') + ctx = _unicode_encode(ctx, encoding=_content_encoding, errors='strict') if selinux.setexeccon(ctx) < 0: raise OSError(_("setexec: Failed setting exec() context \"%s\".") % ctx) def setfscreate(ctx="\n"): - ctx = portage._unicode_encode(ctx) + ctx = _unicode_encode(ctx, + encoding=_content_encoding, errors='strict') if selinux.setfscreatecon(ctx) < 0: raise OSError( _("setfscreate: Failed setting fs create context \"%s\".") % ctx) def spawn_wrapper(spawn_func, selinux_type): + selinux_type = _unicode_encode(selinux_type, + encoding=_content_encoding, errors='strict') + def wrapper_func(*args, **kwargs): - selinux_type = portage._unicode_encode(selinux_type) con = settype(selinux_type) setexec(con) try: @@ -92,9 +96,9 @@ def spawn_wrapper(spawn_func, selinux_type): return wrapper_func def symlink(target, link, reflnk): - target = portage._unicode_encode(target) - link = portage._unicode_encode(link) - reflnk = portage._unicode_encode(reflnk) + target = _unicode_encode(target, encoding=_fs_encoding, errors='strict') + link = _unicode_encode(link, encoding=_fs_encoding, errors='strict') + reflnk = _unicode_encode(reflnk, encoding=_fs_encoding, errors='strict') (rc, ctx) = selinux.lgetfilecon(reflnk) if rc < 0: raise OSError( diff --git a/pym/portage/dispatch_conf.py b/pym/portage/dispatch_conf.py index 98e6aad0f..d61266b31 100644 --- a/pym/portage/dispatch_conf.py +++ b/pym/portage/dispatch_conf.py @@ -7,7 +7,6 @@ # Library by Wayne Davison , derived from code # written by Jeremy Wohl (http://igmus.org) -from stat import * import os, sys, commands, shutil import portage, portage.const @@ -86,8 +85,8 @@ def rcs_archive(archive, curconf, newconf, mrgconf): # This puts the results of the merge into mrgconf. ret = os.system(RCS_MERGE % (archive, mrgconf)) mystat = os.lstat(newconf) - os.chmod(mrgconf, mystat[ST_MODE]) - os.chown(mrgconf, mystat[ST_UID], mystat[ST_GID]) + os.chmod(mrgconf, mystat.st_mode) + os.chown(mrgconf, mystat.st_uid, mystat.st_gid) os.rename(archive, archive + '.dist.new') return ret @@ -137,8 +136,8 @@ def file_archive(archive, curconf, newconf, mrgconf): # This puts the results of the merge into mrgconf. ret = os.system(DIFF3_MERGE % (curconf, archive + '.dist', newconf, mrgconf)) mystat = os.lstat(newconf) - os.chmod(mrgconf, mystat[ST_MODE]) - os.chown(mrgconf, mystat[ST_UID], mystat[ST_GID]) + os.chmod(mrgconf, mystat.st_mode) + os.chown(mrgconf, mystat.st_uid, mystat.st_gid) return ret diff --git a/pym/portage/locks.py b/pym/portage/locks.py index 92a1435bb..d07f16bb5 100644 --- a/pym/portage/locks.py +++ b/pym/portage/locks.py @@ -7,7 +7,10 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \ "hardlock_name", "hardlink_is_mine", "hardlink_lockfile", \ "unhardlink_lockfile", "hardlock_cleanup"] -import errno, os, stat, time +import errno +import stat +import time +from portage import os from portage.exception import DirectoryNotFound, FileNotFound, \ InvalidData, TryAgain, OperationNotPermitted, PermissionDenied from portage.data import portage_gid diff --git a/pym/portage/news.py b/pym/portage/news.py index 36d4603f7..f3482150d 100644 --- a/pym/portage/news.py +++ b/pym/portage/news.py @@ -9,8 +9,13 @@ __all__ = ["NewsManager", "NewsItem", "DisplayRestriction", import codecs import logging -import os +import os as _os import re +from portage import os +from portage import _content_encoding +from portage import _fs_encoding +from portage import _unicode_decode +from portage import _unicode_encode from portage.util import apply_secpass_permissions, ensure_dirs, \ grabfile, normalize_path, write_atomic, writemsg_level from portage.data import portage_gid @@ -94,7 +99,8 @@ class NewsManager(object): news_dir = self._news_dir(repoid) try: - news = os.listdir(news_dir) + news = _os.listdir(_unicode_encode(news_dir, + encoding=_fs_encoding, errors='strict')) except OSError: return @@ -112,14 +118,23 @@ class NewsManager(object): updates = [] for itemid in news: + try: + itemid = _unicode_decode(itemid, + encoding=_fs_encoding, errors='strict') + except UnicodeDecodeError: + itemid = _unicode_decode(itemid, + encoding=_fs_encoding, errors='replace') + writemsg_level( + "!!! Invalid encoding in news item name: '%s'\n" % \ + itemid, level=logging.ERROR, noiselevel=-1) + continue + if itemid in skip: continue filename = os.path.join(news_dir, itemid, itemid + "." + self.language_id + ".txt") if not os.path.isfile(filename): continue - if not isinstance(itemid, unicode): - itemid = unicode(itemid, encoding='utf_8', errors='replace') item = NewsItem(filename, itemid) if not item.isValid(): continue @@ -171,6 +186,7 @@ class NewsManager(object): if unread_lock: unlockfile(unread_lock) +_formatRE = re.compile("News-Item-Format:\s*([^\s]*)\s*$") _installedRE = re.compile("Display-If-Installed:(.*)\n") _profileRE = re.compile("Display-If-Profile:(.*)\n") _keywordRE = re.compile("Display-If-Keyword:(.*)\n") @@ -184,7 +200,6 @@ class NewsItem(object): "display if arch: x86" and so forth. Creation of a news item involves passing in the path to the particular news item. - """ def __init__(self, path, name): @@ -203,24 +218,33 @@ class NewsItem(object): and a vardb so we can look at installed packages). Each restriction will pluck out the items that are required for it to match or raise a ValueError exception if the required object is not present. + + Restrictions of the form Display-X are OR'd with like-restrictions; + otherwise restrictions are AND'd. any_match is the ORing and + all_match is the ANDing. """ if not self._parsed: self.parse() if not len(self.restrictions): - return True # no restrictions to match means everyone should see it + return True kwargs = \ { 'vardb' : vardb, 'config' : config, 'profile' : profile } - for restriction in self.restrictions: - if restriction.checkRestriction(**kwargs): - return True + all_match = True + for values in self.restrictions.itervalues(): + any_match = False + for restriction in values: + if restriction.checkRestriction(**kwargs): + any_match = True + if not any_match: + all_match = False - return False # No restrictions were met; thus we aren't relevant :( + return all_match def isValid(self): if not self._parsed: @@ -228,13 +252,18 @@ class NewsItem(object): return self._valid def parse(self): - lines = codecs.open(self.path, mode='r', - encoding='utf_8', errors='replace').readlines() - self.restrictions = [] + lines = codecs.open(_unicode_encode(self.path, + encoding=_fs_encoding, errors='strict'), + mode='r', encoding=_content_encoding, errors='replace').readlines() + self.restrictions = {} invalids = [] for i, line in enumerate(lines): - #Optimization to ignore regex matchines on lines that - #will never match + # Optimization to ignore regex matchines on lines that + # will never match + format_match = _formatRE.match(line) + if format_match is not None and format_match.group(1) != '1.0': + invalids.append((i + 1, line.rstrip('\n'))) + break if not line.startswith('D'): continue restricts = { _installedRE : DisplayInstalledRestriction, @@ -243,9 +272,12 @@ class NewsItem(object): for regex, restriction in restricts.iteritems(): match = regex.match(line) if match: - self.restrictions.append(restriction(match.groups()[0].strip())) - if not self.restrictions[-1].isValid(): + restrict = restriction(match.groups()[0].strip()) + if not restrict.isValid(): invalids.append((i + 1, line.rstrip("\n"))) + else: + self.restrictions.setdefault( + id(restriction), []).append(restrict) continue if invalids: self._valid = False diff --git a/pym/portage/output.py b/pym/portage/output.py index 22897d71e..c47b65cc0 100644 --- a/pym/portage/output.py +++ b/pym/portage/output.py @@ -8,9 +8,7 @@ import codecs import commands import errno import formatter -import os import re -import shlex import sys import portage @@ -18,6 +16,10 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.util:writemsg', ) +from portage import os +from portage import _content_encoding +from portage import _fs_encoding +from portage import _unicode_encode from portage.const import COLOR_MAP_FILE, EPREFIX from portage.exception import CommandNotFound, FileNotFound, \ ParseError, PermissionDenied, PortageException @@ -141,7 +143,7 @@ _styles["PKG_NOMERGE_WORLD"] = ( "blue", ) _styles["PROMPT_CHOICE_DEFAULT"] = ( "green", ) _styles["PROMPT_CHOICE_OTHER"] = ( "red", ) -def _parse_color_map(onerror=None): +def _parse_color_map(config_root='/', onerror=None): """ Parse /etc/portage/color.map and return a dict of error codes. @@ -157,7 +159,7 @@ def _parse_color_map(onerror=None): # that can be called in order adjust the location that color.map # is read from. global codes, _styles - myfile = os.path.join(EPREFIX, COLOR_MAP_FILE) + myfile = os.path.join(config_root, COLOR_MAP_FILE) ansi_code_pattern = re.compile("^[0-9;]*m$") quotes = '\'"' def strip_quotes(token): @@ -166,8 +168,9 @@ def _parse_color_map(onerror=None): return token try: lineno=0 - for line in codecs.open( myfile, mode='r', - encoding='utf_8', errors='replace' ): + for line in codecs.open(_unicode_encode(myfile, + encoding=_fs_encoding, errors='strict'), + mode='r', encoding=_content_encoding, errors='replace'): lineno += 1 commenter_pos = line.find("#") @@ -467,7 +470,7 @@ class EOutput(object): def _write(self, f, s): if sys.hexversion < 0x3000000 and isinstance(s, unicode): # avoid potential UnicodeEncodeError - s = s.encode('utf_8', 'replace') + s = s.encode(_content_encoding, 'replace') f.write(s) f.flush() @@ -723,13 +726,46 @@ class TermProgressBar(ProgressBar): ">" + ((max_bar_width - bar_width) * " ") + "]" return image -try: - _parse_color_map(onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1)) -except FileNotFound: - pass -except PermissionDenied, e: - writemsg(_("Permission denied: '%s'\n") % str(e), noiselevel=-1) - del e -except PortageException, e: - writemsg("%s\n" % str(e), noiselevel=-1) - del e +_color_map_loaded = False + +def _init(config_root='/'): + """ + Load color.map from the given config_root. This is called automatically + on first access of the codes or _styles attributes (unless it has already + been called for some other reason). + """ + + global _color_map_loaded, codes, _styles + if _color_map_loaded: + return + + _color_map_loaded = True + codes = object.__getattribute__(codes, '_attr') + _styles = object.__getattribute__(_styles, '_attr') + + try: + _parse_color_map(config_root=config_root, + onerror=lambda e: writemsg("%s\n" % str(e), noiselevel=-1)) + except FileNotFound: + pass + except PermissionDenied, e: + writemsg(_("Permission denied: '%s'\n") % str(e), noiselevel=-1) + del e + except PortageException, e: + writemsg("%s\n" % str(e), noiselevel=-1) + del e + +class _LazyInitColorMap(portage.proxy.objectproxy.ObjectProxy): + + __slots__ = ('_attr',) + + def __init__(self, attr): + portage.proxy.objectproxy.ObjectProxy.__init__(self) + object.__setattr__(self, '_attr', attr) + + def _get_target(self): + _init() + return object.__getattribute__(self, '_attr') + +codes = _LazyInitColorMap(codes) +_styles = _LazyInitColorMap(_styles) diff --git a/pym/portage/tests/bin/setup_env.py b/pym/portage/tests/bin/setup_env.py index 727f02e7b..aab210ee9 100644 --- a/pym/portage/tests/bin/setup_env.py +++ b/pym/portage/tests/bin/setup_env.py @@ -3,15 +3,17 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os, shutil, sys -from os.path import dirname, abspath, join +from portage import os +from portage import shutil from portage.tests import TestCase from portage.process import spawn from portage.const import PORTAGE_BIN_PATH -bindir = join(dirname(dirname(abspath(__file__))), +bindir = os.path.join(os.path.dirname(os.path.dirname( + os.path.abspath(__file__))), "..", "..", "..", "bin", "ebuild-helpers") -basedir = join(dirname(dirname(abspath(__file__))), "bin", "root") +basedir = os.path.join(os.path.dirname(os.path.dirname( + os.path.abspath(__file__))), "bin", "root") os.environ["D"] = os.path.join(basedir, "image") os.environ["T"] = os.path.join(basedir, "temp") os.environ["S"] = os.path.join(basedir, "workdir") @@ -52,7 +54,7 @@ def xexists_in_D(path): def portage_func(func, args, exit_status=0): # we don't care about the output of the programs, # just their exit value and the state of $D - f = open('/dev/null', 'w') + f = open('/dev/null', 'wb') fd_pipes = {0:0,1:f.fileno(),2:f.fileno()} spawn(func+" "+args, env=os.environ, fd_pipes=fd_pipes) f.close() diff --git a/pym/portage/tests/ebuild/test_spawn.py b/pym/portage/tests/ebuild/test_spawn.py index 1ba6e5847..908fce606 100644 --- a/pym/portage/tests/ebuild/test_spawn.py +++ b/pym/portage/tests/ebuild/test_spawn.py @@ -2,7 +2,13 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import errno, os, sys +import codecs +import errno +import sys +from portage import os +from portage import _content_encoding +from portage import _fs_encoding +from portage import _unicode_encode from portage.tests import TestCase class SpawnTestCase(TestCase): @@ -27,7 +33,9 @@ class SpawnTestCase(TestCase): spawn("echo -n '%s'" % test_string, settings, logfile=logfile, free=1, fd_pipes={0:sys.stdin.fileno(), 1:null_fd, 2:null_fd}) os.close(null_fd) - f = open(logfile, 'r') + f = codecs.open(_unicode_encode(logfile, + encoding=_fs_encoding, errors='strict'), + mode='r', encoding=_content_encoding, errors='strict') log_content = f.read() f.close() # When logging passes through a pty, this comparison will fail diff --git a/pym/portage/tests/env/config/test_PackageKeywordsFile.py b/pym/portage/tests/env/config/test_PackageKeywordsFile.py index 228ce4a82..228cf2ecb 100644 --- a/pym/portage/tests/env/config/test_PackageKeywordsFile.py +++ b/pym/portage/tests/env/config/test_PackageKeywordsFile.py @@ -3,10 +3,10 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +from portage import os from portage.tests import TestCase from portage.env.config import PackageKeywordsFile from tempfile import mkstemp -import os class PackageKeywordsFileTestCase(TestCase): @@ -38,5 +38,4 @@ class PackageKeywordsFileTestCase(TestCase): f.close() def NukeFile(self): - import os os.unlink(self.fname) diff --git a/pym/portage/tests/env/config/test_PackageMaskFile.py b/pym/portage/tests/env/config/test_PackageMaskFile.py index dca8002bc..90cdf5387 100644 --- a/pym/portage/tests/env/config/test_PackageMaskFile.py +++ b/pym/portage/tests/env/config/test_PackageMaskFile.py @@ -3,8 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os - +from portage import os from portage.env.config import PackageMaskFile from portage.tests import TestCase, test_cps from tempfile import mkstemp diff --git a/pym/portage/tests/env/config/test_PackageUseFile.py b/pym/portage/tests/env/config/test_PackageUseFile.py index aa18364a0..575ede505 100644 --- a/pym/portage/tests/env/config/test_PackageUseFile.py +++ b/pym/portage/tests/env/config/test_PackageUseFile.py @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os +from portage import os from portage.tests import TestCase from portage.env.config import PackageUseFile from tempfile import mkstemp diff --git a/pym/portage/tests/env/config/test_PortageModulesFile.py b/pym/portage/tests/env/config/test_PortageModulesFile.py index fb164b4a7..40472104b 100644 --- a/pym/portage/tests/env/config/test_PortageModulesFile.py +++ b/pym/portage/tests/env/config/test_PortageModulesFile.py @@ -1,9 +1,12 @@ +# Copyright 2006-2009 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ +from portage import os from portage.tests import TestCase from portage.env.config import PortageModulesFile from tempfile import mkstemp from itertools import izip -import os class PortageModulesFileTestCase(TestCase): diff --git a/pym/portage/tests/news/test_NewsItem.py b/pym/portage/tests/news/test_NewsItem.py index f4a073504..721ab2690 100644 --- a/pym/portage/tests/news/test_NewsItem.py +++ b/pym/portage/tests/news/test_NewsItem.py @@ -3,10 +3,9 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import os +from portage import os from portage.tests import TestCase from portage.news import NewsItem -from portage.const import PROFILE_PATH from portage.dbapi.virtual import testdbapi from tempfile import mkstemp # TODO(antarus) Make newsitem use a loader so we can load using a string instead of a tempfile diff --git a/pym/portage/tests/process/test_poll.py b/pym/portage/tests/process/test_poll.py index 3f4a597b4..22aa6aa8b 100644 --- a/pym/portage/tests/process/test_poll.py +++ b/pym/portage/tests/process/test_poll.py @@ -2,11 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import errno, os, sys -import fcntl -import termios -import portage -from portage.output import get_term_size, set_term_size +import sys +from portage import os from portage.tests import TestCase from _emerge.TaskScheduler import TaskScheduler from _emerge.PipeReader import PipeReader diff --git a/pym/portage/tests/sets/files/testConfigFileSet.py b/pym/portage/tests/sets/files/testConfigFileSet.py index 7ea17fd1b..95ea4f44a 100644 --- a/pym/portage/tests/sets/files/testConfigFileSet.py +++ b/pym/portage/tests/sets/files/testConfigFileSet.py @@ -3,8 +3,9 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import tempfile, os +import tempfile +from portage import os from portage.tests import TestCase, test_cps from portage.sets.files import ConfigFileSet diff --git a/pym/portage/tests/sets/files/testStaticFileSet.py b/pym/portage/tests/sets/files/testStaticFileSet.py index fff583da1..138c99e5e 100644 --- a/pym/portage/tests/sets/files/testStaticFileSet.py +++ b/pym/portage/tests/sets/files/testStaticFileSet.py @@ -3,12 +3,11 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ -import tempfile, os +import tempfile +from portage import os from portage.tests import TestCase, test_cps from portage.sets.files import StaticFileSet -from portage.env.loaders import TestTextLoader -from portage.env.config import ConfigLoaderKlass class StaticFileSetTestCase(TestCase): """Simple Test Case for StaticFileSet""" diff --git a/pym/portage/tests/util/test_uniqueArray.py b/pym/portage/tests/util/test_uniqueArray.py index e1b9caec8..e9485b126 100644 --- a/pym/portage/tests/util/test_uniqueArray.py +++ b/pym/portage/tests/util/test_uniqueArray.py @@ -3,6 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +from portage import os from portage.tests import TestCase from portage.util import unique_array @@ -13,8 +14,6 @@ class UniqueArrayTestCase(TestCase): test portage.util.uniqueArray() """ - import os - tests = [ ( ["a","a","a",os,os,[],[],[]], ['a',os,[]] ), ( [1,1,1,2,3,4,4] , [1,2,3,4]) ] -- 2.26.2