Merged from trunk -r12619:12633
authorFabian Groffen <grobian@gentoo.org>
Thu, 19 Feb 2009 17:50:29 +0000 (17:50 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 19 Feb 2009 17:50:29 +0000 (17:50 -0000)
   | 12620    | unify code for unpacking of tar files                       |
   | SpankMan |                                                             |

   | 12621    | Bug #259124 - Inside EbuildFetcher._start(), pass the       |
   | zmedico  | NOCOLOR variable into the fetch environment, so that        |
   |          | --color=n is respected.                                     |

   | 12622    | Fix grabfile_package() to preprocess atoms before passing   |
   | zmedico  | them to isvalidatom() because isvalidatom() has gotten more |
   |          | strict since r12614. Thanks to ABCD for reporting.          |

   | 12623    | Bug #253904 - Add a lookahead mechanism inside              |
   | zmedico  | depgraph._dep_check_composite_db._visible() which masks     |
   |          | package choices that are likely to trigger slot conflicts.  |
   |          | Thanks to Vlastimil Babka <caster@g.o> for the suggestion.  |

   | 12624    | Call depgraph._dep_check_composite_db._clear_cache() inside |
   | zmedico  | depgraph._add_pkg() since                                   |
   |          | _dep_check_composite_db._visible() is now affected by which |
   |          | packages are added to the graph.                            |

   | 12625    | Make save_ebuild_env() filter NOCOLOR, and remove related   |
   | zmedico  | code from ebuild.sh since that variable is not loaded from  |
   |          | $T/environment anymore.                                     |

   | 12626    | Set svn:keywords Id on all files.                           |
   | zmedico  |                                                             |

   | 12628    | In python-3.0, the UserDict.DictMixin class has been        |
   | zmedico  | replaced by Mapping and MutableMapping from the collections |
   |          | module, but 2to3 doesn't currently account for this change: |
   |          | http://bugs.python.org/issue2876 As a workaround for the    |
   |          | above issue, implement Mapping and MutableMapping classes   |
   |          | as substitutes for UserDict.DictMixin so that code          |
   |          | converted via 2to3 will run.                                |

   | 12629    | Implement a substitute for UserDict.UserDict so that code   |
   | zmedico  | converted via 2to3 will run:                                |
   |          | http://bugs.python.org/issue2876                            |

   | 12630    | Implement UserDict.__contains__() and __iter__().           |
   | zmedico  |                                                             |

   | 12631    | Remove redundant ConfigLoaderKlass.__iter__() method.       |
   | zmedico  |                                                             |

   | 12632    | Fix classes that implement __iter__() to copy it to their   |
   | zmedico  | keys() method when running under >=python-3.0.              |

   | 12633    | For compatibility with python-3.0, use isinstance() instead |
   | zmedico  | of type().                                                  |

svn path=/main/branches/prefix/; revision=12651

23 files changed:
bin/dohtml
bin/ebuild.sh
bin/isolated-functions.sh
pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/cache/mappings.py
pym/portage/cache/sql_template.py
pym/portage/dep.py
pym/portage/env/config.py
pym/portage/locks.py
pym/portage/tests/bin/setup_env.py
pym/portage/tests/bin/test_dobin.py
pym/portage/tests/bin/test_dodir.py
pym/portage/tests/dep/test_dep_getusedeps.py
pym/portage/tests/env/config/test_PackageKeywordsFile.py
pym/portage/tests/env/config/test_PackageMaskFile.py
pym/portage/tests/env/config/test_PackageUseFile.py
pym/portage/tests/news/test_NewsItem.py
pym/portage/tests/process/__init__.py
pym/portage/tests/process/test_poll.py
pym/portage/tests/sets/files/testConfigFileSet.py
pym/portage/tests/sets/files/testStaticFileSet.py
pym/portage/util.py

index 6bc41ff0251200d87f2c28943eab795164029d59..69286a741bcb0fc62894f15266c9b7fca5416824 100755 (executable)
@@ -31,7 +31,6 @@
 
 import os
 import sys
-import types
 
 def dodir(path):
        os.spawnlp(os.P_WAIT, "install", "install", "-d", path)
@@ -160,9 +159,6 @@ def main():
 
        (options, args) = parse_args()
 
-       if type(options.allowed_exts) == types.StringType:
-               options.allowed_exts = options.allowed_exts.split(",")
-
        if options.verbose:
                print "Allowed extensions:", options.allowed_exts
                print "Document prefix : '" + options.doc_prefix         + "'"
index 4b0845fda4a2237c569e85da302184e7072ae814..69cf87c5d25f1bb9437b604d8dbc0489dcc91d2d 100755 (executable)
@@ -353,6 +353,15 @@ unpack() {
                fi
                [[ ! -s ${srcdir}${x} ]] && die "${x} does not exist"
 
+               _unpack_tar() {
+                       if [ "${y}" == "tar" ]; then
+                               $1 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
+                               assert "$myfail"
+                       else
+                               $1 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
+                       fi
+               }
+
                myfail="failure unpacking ${x}"
                case "${x##*.}" in
                        tar)
@@ -369,19 +378,10 @@ unpack() {
                                unzip -qo "${srcdir}${x}" || die "$myfail"
                                ;;
                        gz|Z|z)
-                               if [ "${y}" == "tar" ]; then
-                                       tar zoxf "${srcdir}${x}" ${tar_opts} || die "$myfail"
-                               else
-                                       gzip -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
-                               fi
+                               _unpack_tar gzip
                                ;;
                        bz2|bz)
-                               if [ "${y}" == "tar" ]; then
-                                       bzip2 -dc "${srcdir}${x}" | tar xof - ${tar_opts}
-                                       assert "$myfail"
-                               else
-                                       bzip2 -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
-                               fi
+                               _unpack_tar bzip2
                                ;;
                        7Z|7z)
                                local my_output
@@ -428,23 +428,13 @@ unpack() {
                                fi
                                ;;
                        lzma)
-                               if [ "${y}" == "tar" ]; then
-                                       lzma -dc "${srcdir}${x}" | tar xof - ${tar_opts}
-                                       assert "$myfail"
-                               else
-                                       lzma -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
-                               fi
+                               _unpack_tar lzma
                                ;;
                        xz)
                                if hasq $eapi 0 1 2 ; then
                                        vecho "unpack ${x}: file format not recognized. Ignoring."
                                else
-                                       if [ "${y}" == "tar" ]; then
-                                               xz -dc "${srcdir}${x}" | tar xof - ${tar_opts}
-                                               assert "$myfail"
-                                       else
-                                               xz -dc "${srcdir}${x}" > ${x%.*} || die "$myfail"
-                                       fi
+                                       _unpack_tar xz
                                fi
                                ;;
                        *)
@@ -1854,18 +1844,6 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm depend && \
        unset x y
        export SANDBOX_ON=${PORTAGE_SANDBOX_ON}
        unset PORTAGE_SANDBOX_ON
-
-       # After loading the environment, make sure the color variables
-       # are in sync with the current NOCOLOR setting.
-       case "${NOCOLOR:-false}" in
-               yes|true)
-                       unset_colors
-                       ;;
-               no|false)
-                       set_colors
-                       ;;
-       esac
-
 fi
 
 if ! hasq "$EBUILD_PHASE" clean cleanrm && \
index 1eead1a2cbb02d70110977c2f9fe97611753ac5e..b3256452cea5e453ced499adfa9d6006d30d9f31 100755 (executable)
@@ -528,7 +528,7 @@ save_ebuild_env() {
                        ECLASSDIR ECLASS_DEPTH ENDCOL FAKEROOTKEY \
                        GOOD HILITE HOME IMAGE \
                        LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \
-                       NORMAL PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \
+                       NOCOLOR NORMAL PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \
                        PORTAGE_ACTUAL_DISTDIR PORTAGE_ARCHLIST \
                        PORTAGE_BASHRC PORTAGE_BASHRCS_SOURCED \
                        PORTAGE_BINPKG_TAR_OPTS PORTAGE_BINPKG_TMPFILE PORTAGE_BUILDDIR \
index e210fedb537b57a54271f6fd7d333a4263677b8e..2967beafe9cf20f79cb142423ccbb4397360ecb0 100644 (file)
@@ -46,7 +46,7 @@ from portage import digraph
 from portage.const import NEWS_LIB_PATH
 
 import _emerge.help
-import portage.xpak, commands, errno, re, socket, time, types
+import portage.xpak, commands, errno, re, socket, time
 from portage.output import blue, bold, colorize, darkblue, darkgreen, darkred, green, \
        nc_len, red, teal, turquoise, xtermTitle, \
        xtermTitleReset, yellow
@@ -71,7 +71,6 @@ from portage.sets import load_default_config, SETPREFIX
 from portage.sets.base import InternalPackageSet
 
 from itertools import chain, izip
-from UserDict import DictMixin
 
 try:
        import cPickle as pickle
@@ -293,8 +292,8 @@ def countdown(secs=5, doing="Starting"):
 
 # formats a size given in bytes nicely
 def format_size(mysize):
-       if type(mysize) not in [types.IntType,types.LongType]:
-               return str(mysize)
+       if isinstance(mysize, basestring):
+               return mysize
        if 0 != mysize % 1024:
                # Always round up to the next kB so that it doesn't show 0 kB when
                # some small file still needs to be fetched.
@@ -2485,6 +2484,10 @@ class EbuildFetcher(SpawnProcess):
                # the config instance in the subproccess.
                fetch_env = os.environ.copy()
 
+               nocolor = settings.get("NOCOLOR")
+               if nocolor is not None:
+                       fetch_env["NOCOLOR"] = nocolor
+
                fetch_env["PORTAGE_NICENESS"] = "0"
                if self.prefetch:
                        fetch_env["PORTAGE_PARALLEL_FETCHONLY"] = "1"
@@ -4034,7 +4037,7 @@ class Dependency(SlotObject):
                if self.depth is None:
                        self.depth = 0
 
-class BlockerCache(DictMixin):
+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
        emerge.  The cache is invalidated whenever it is detected that something
@@ -4192,11 +4195,6 @@ class BlockerCache(DictMixin):
                """
                return self.BlockerData(*self._cache_data["blockers"][cpv])
 
-       def keys(self):
-               """This needs to be implemented so that self.__repr__() doesn't raise
-               an AttributeError."""
-               return list(self)
-
 class BlockerDB(object):
 
        def __init__(self, root_config):
@@ -5090,9 +5088,10 @@ class depgraph(object):
                                # dependencies so that things like --fetchonly can still
                                # function despite collisions.
                                pass
-                       else:
+                       elif not previously_added:
                                self._slot_pkg_map[pkg.root][pkg.slot_atom] = pkg
                                self.mydbapi[pkg.root].cpv_inject(pkg)
+                               self._filtered_trees[pkg.root]["porttree"].dbapi._clear_cache()
 
                        if not pkg.installed:
                                # Allow this package to satisfy old-style virtuals in case it
@@ -8929,6 +8928,20 @@ class depgraph(object):
                                                return False
                                except portage.exception.InvalidDependString:
                                        pass
+                       in_graph = self._depgraph._slot_pkg_map[
+                               self._root].get(pkg.slot_atom)
+                       if in_graph is None:
+                               # Mask choices for packages which are not the highest visible
+                               # version within their slot (since they usually trigger slot
+                               # conflicts).
+                               highest_visible, in_graph = self._depgraph._select_package(
+                                       self._root, pkg.slot_atom)
+                               if pkg != highest_visible:
+                                       return False
+                       elif in_graph != pkg:
+                               # Mask choices for packages that would trigger a slot
+                               # conflict with a previously selected package.
+                               return False
                        return True
 
                def _dep_expand(self, atom):
index 729bbd06f6a8a42cfae97b051ca0a85cd104a1e9..e4245ed2c04045a314e32c1527eccea15ce36df2 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 
-VERSION="$Rev: 9373 $"[6:-2] + "-svn"
+VERSION="$Rev: 12601 $"[6:-2] + "-svn"
 
 # ===========================================================================
 # START OF IMPORTS -- START OF IMPORTS -- START OF IMPORTS -- START OF IMPORT
@@ -28,7 +28,6 @@ try:
        import commands
        from time import sleep
        from random import shuffle
-       import UserDict
        from itertools import chain, izip
        import platform
        import warnings
@@ -7293,7 +7292,7 @@ from portage.dbapi.bintree import bindbapi, binarytree
 from portage.dbapi.vartree import vardbapi, vartree, dblink
 from portage.dbapi.porttree import close_portdbapi_caches, portdbapi, portagetree
 
-class FetchlistDict(UserDict.DictMixin):
+class FetchlistDict(portage.cache.mappings.Mapping):
        """This provide a mapping interface to retrieve fetch lists.  It's used
        to allow portage.manifest.Manifest to access fetch lists via a standard
        mapping interface rather than use the dbapi directly."""
@@ -7313,10 +7312,17 @@ class FetchlistDict(UserDict.DictMixin):
        def has_key(self, pkg_key):
                """Returns true if the given package exists within pkgdir."""
                return pkg_key in self
+
+       def __iter__(self):
+               return iter(self.portdb.cp_list(self.cp, mytree=self.mytree))
+
        def keys(self):
                """Returns keys for all packages within pkgdir"""
                return self.portdb.cp_list(self.cp, mytree=self.mytree)
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
 def pkgmerge(mytbz2, myroot, mysettings, mydbapi=None,
        vartree=None, prev_mtimes=None, blockers=None):
        """will merge a .tbz2 file, returning a list of runtime dependencies
index 010eb7f8e8d8b19bad1477acf365ecdcebeb693e..5fe836daad115c468b266ef2247c25fb98ae2bee 100644 (file)
-# Copyright: 2005 Gentoo Foundation
+# Copyright: 2005-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
 # Author(s): Brian Harring (ferringb@gentoo.org)
-# License: GPL2
 # $Id$
 
+__all__ = ["Mapping", "MutableMapping", "UserDict", "ProtectedDict",
+       "LazyLoad", "slot_dict_class"]
+
 import sys
-import UserDict
 import warnings
 import weakref
 
-class ProtectedDict(UserDict.DictMixin):
+class Mapping(object):
+       """
+       In python-3.0, the UserDict.DictMixin class has been replaced by
+       Mapping and MutableMapping from the collections module, but 2to3
+       doesn't currently account for this change:
+
+           http://bugs.python.org/issue2876
+
+       As a workaround for the above issue, use this class as a substitute
+       for UserDict.DictMixin so that code converted via 2to3 will run.
+       """
+
+       def __iter__(self):
+               return self.iterkeys()
+
+       def keys(self):
+               return list(self.__iter__())
+
+       def has_key(self, key):
+               warnings.warn("portage.cache.mappings.Mapping.has_key() " + \
+                       "is deprecated, use the in operator instead", DeprecationWarning)
+               return key in self
+
+       def __contains__(self, key):
+               try:
+                       value = self[key]
+               except KeyError:
+                       return False
+               return True
+
+       def iteritems(self):
+               for k in self:
+                       yield (k, self[k])
+
+       def iterkeys(self):
+               return self.__iter__()
+
+       def itervalues(self):
+               for _, v in self.iteritems():
+                       yield v
+
+       def values(self):
+               return [v for _, v in self.iteritems()]
+
+       def items(self):
+               return list(self.iteritems())
+
+       def get(self, key, default=None):
+               try:
+                       return self[key]
+               except KeyError:
+                       return default
+
+       def __repr__(self):
+               return repr(dict(self.iteritems()))
+
+       def __len__(self):
+               return len(self.keys())
+
+       if sys.hexversion >= 0x3000000:
+               items = iteritems
+               keys = __iter__
+               values = itervalues
+
+class MutableMapping(Mapping):
+       """
+       A mutable vesion of the Mapping class.
+       """
+
+       def clear(self):
+               for key in self.keys():
+                       del self[key]
+
+       def setdefault(self, key, default=None):
+               try:
+                       return self[key]
+               except KeyError:
+                       self[key] = default
+               return default
+
+       def pop(self, key, *args):
+               if len(args) > 1:
+                       raise TypeError("pop expected at most 2 arguments, got " + \
+                               repr(1 + len(args)))
+               try:
+                       value = self[key]
+               except KeyError:
+                       if args:
+                               return args[0]
+                       raise
+               del self[key]
+               return value
+
+       def popitem(self):
+               try:
+                       k, v = self.iteritems().next()
+               except StopIteration:
+                       raise KeyError('container is empty')
+               del self[k]
+               return (k, v)
+
+       def update(self, other=None, **kwargs):
+               if other is None:
+                       pass
+               elif hasattr(other, 'iteritems'):
+                       for k, v in other.iteritems():
+                               self[k] = v
+               elif hasattr(other, 'keys'):
+                       for k in other.keys():
+                               self[k] = other[k]
+               else:
+                       for k, v in other:
+                               self[k] = v
+               if kwargs:
+                       self.update(kwargs)
+
+class UserDict(MutableMapping):
+       """
+       Use this class as a substitute for UserDict.UserDict so that
+       code converted via 2to3 will run:
+
+            http://bugs.python.org/issue2876
+       """
+
+       def __init__(self, dict=None, **kwargs):
+               self.data = {}
+               if dict is not None:
+                       self.update(dict)
+               if kwargs:
+                       self.update(kwargs)
+
+       def __repr__(self):
+               return repr(self.data)
+
+       def __contains__(self, key):
+               return key in self.data
+
+       def __iter__(self):
+               return iter(self.data)
+
+       def __len__(self):
+               return len(self.data)
+
+       def __getitem__(self, key):
+               return self.data[key]
+
+       def __setitem__(self, key, item):
+               self.data[key] = item
+
+       def __delitem__(self, key):
+               del self.data[key]
+
+       def clear(self):
+               self.data.clear()
+
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
+class ProtectedDict(MutableMapping):
        """
        given an initial dict, this wraps that dict storing changes in a secondary dict, protecting
        the underlying dict from changes
@@ -52,11 +212,6 @@ class ProtectedDict(UserDict.DictMixin):
                        if k not in self.blacklist and k not in self.new:
                                yield k
 
-
-       def keys(self):
-               return list(self.__iter__())
-
-
        def __contains__(self, key):
                return key in self.new or (key not in self.blacklist and key in self.orig)
 
@@ -68,9 +223,8 @@ class ProtectedDict(UserDict.DictMixin):
 
        if sys.hexversion >= 0x3000000:
                keys = __iter__
-               items = iteritems
 
-class LazyLoad(UserDict.DictMixin):
+class LazyLoad(Mapping):
        """
        Lazy loading of values for a dict
        """
@@ -90,16 +244,11 @@ class LazyLoad(UserDict.DictMixin):
                        self.pull = None
                return self.d[key]
 
-
        def __iter__(self):
-               return iter(self.keys())
-
-       def keys(self):
-               if self.pull != None:
+               if self.pull is not None:
                        self.d.update(self.pull())
                        self.pull = None
-               return self.d.keys()
-
+               return iter(self.d)
 
        def has_key(self, key):
                warnings.warn("portage.cache.mappings.LazyLoad.has_key() is "
@@ -118,7 +267,6 @@ class LazyLoad(UserDict.DictMixin):
 
        if sys.hexversion >= 0x3000000:
                keys = __iter__
-               items = iteritems
 
 _slot_dict_classes = weakref.WeakValueDictionary()
 
@@ -235,6 +383,9 @@ def slot_dict_class(keys, prefix="_val_"):
                                return hasattr(self, self._prefix + k)
 
                        def has_key(self, k):
+                               warnings.warn("portage.cache.mappings.SlotDict.has_key()" + \
+                                       " is deprecated, use the in operator instead",
+                                       DeprecationWarning)
                                return k in self
 
                        def pop(self, key, *args):
index e5903cd67382ace9be3e2b6167d0a5f3ef3c5c6c..47bef9124957dec236756fbe3d28fa62af200259 100644 (file)
@@ -280,3 +280,4 @@ class SQLDatabase(template.database):
 
        if sys.hexversion >= 0x3000000:
                items = iteritems
+               keys = __iter__
index 831a8a324a267414f6e63982a0193c0af1bb2dcc..04817068c0b587aa12c754f3323214a43445bc9e 100644 (file)
@@ -18,7 +18,7 @@
 # "a? ( b? ( z ) ) -- Valid
 #
 
-import re, sys, types
+import re, sys
 import weakref
 from itertools import chain
 import portage.exception
@@ -230,7 +230,7 @@ def use_reduce(deparray, uselist=[], masklist=[], matchall=0, excludeall=[]):
        while mydeparray:
                head = mydeparray.pop(0)
 
-               if type(head) == types.ListType:
+               if not isinstance(head, basestring):
                        additions = use_reduce(head, uselist, masklist, matchall, excludeall)
                        if additions:
                                rlist.append(additions)
index c990d9f0effe3b80661ac6ecc7bd909415e48495..b6efdbecf9950aac67d3613da4eff4458dce659d 100644 (file)
@@ -1,12 +1,15 @@
 # config.py -- Portage Config
-# Copyright 2007 Gentoo Foundation
+# Copyright 2007-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-from UserDict import UserDict
+__all__ = ["ConfigLoaderKlass", "GenericFile", "PackageKeywordsFile",
+       "PackageUseFile", "PackageMaskFile", "PortageModulesFile"]
+
+from portage.cache.mappings import UserDict
 from portage.env.loaders import KeyListFileLoader, KeyValuePairFileLoader, ItemFileLoader
 
-class ConfigLoaderKlass(UserDict, object):
+class ConfigLoaderKlass(UserDict):
        """
        A base class stub for things to inherit from.
        Users may want a non-file backend.
@@ -29,9 +32,6 @@ class ConfigLoaderKlass(UserDict, object):
 
                self.data, self.errors = self._loader.load()
 
-       def __iter__(self):
-               return iter(self.data)
-
 class GenericFile(UserDict):
        """
        Inherits from ConfigLoaderKlass, attempts to use all known loaders
index 912b2a32f566ccf82e12878c015e05c13877c538..ddd39323fbd110b918321d82700d25affcd1f18c 100644 (file)
@@ -7,7 +7,7 @@ __all__ = ["lockdir", "unlockdir", "lockfile", "unlockfile", \
        "hardlock_name", "hardlink_is_mine", "hardlink_lockfile", \
        "unhardlink_lockfile", "hardlock_cleanup"]
 
-import errno, os, stat, time, types
+import errno, os, stat, time
 from portage.exception import DirectoryNotFound, FileNotFound, \
        InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
 from portage.data import portage_gid
@@ -36,12 +36,12 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
        if not mypath:
                raise InvalidData("Empty path given")
 
-       if type(mypath) == types.StringType and mypath[-1] == '/':
+       if isinstance(mypath, basestring) and mypath[-1] == '/':
                mypath = mypath[:-1]
 
-       if type(mypath) == types.FileType:
+       if hasattr(mypath, 'fileno'):
                mypath = mypath.fileno()
-       if type(mypath) == types.IntType:
+       if isinstance(mypath, int):
                lockfilename    = mypath
                wantnewlockfile = 0
                unlinkfile      = 0
@@ -52,8 +52,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                unlinkfile   = 1
        else:
                lockfilename = mypath
-       
-       if type(mypath) == types.StringType:
+
+       if isinstance(mypath, basestring):
                if not os.path.exists(os.path.dirname(mypath)):
                        raise DirectoryNotFound(os.path.dirname(mypath))
                preexisting = os.path.exists(lockfilename)
@@ -87,7 +87,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                finally:
                        os.umask(old_mask)
 
-       elif type(mypath) == types.IntType:
+       elif isinstance(mypath, int):
                myfd = mypath
 
        else:
@@ -143,7 +143,7 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
                        raise
 
                
-       if type(lockfilename) == types.StringType and \
+       if isinstance(lockfilename, basestring) and \
                myfd != HARDLINK_FD and _fstat_nlink(myfd) == 0:
                # The file was deleted on us... Keep trying to make one...
                os.close(myfd)
@@ -188,7 +188,8 @@ def unlockfile(mytuple):
                return True
        
        # myfd may be None here due to myfd = mypath in lockfile()
-       if type(lockfilename) == types.StringType and not os.path.exists(lockfilename):
+       if isinstance(lockfilename, basestring) and \
+               not os.path.exists(lockfilename):
                writemsg("lockfile does not exist '%s'\n" % lockfilename,1)
                if myfd is not None:
                        os.close(myfd)
@@ -200,7 +201,7 @@ def unlockfile(mytuple):
                        unlinkfile = 1
                locking_method(myfd,fcntl.LOCK_UN)
        except OSError:
-               if type(lockfilename) == types.StringType:
+               if isinstance(lockfilename, basestring):
                        os.close(myfd)
                raise IOError("Failed to unlock file '%s'\n" % lockfilename)
 
@@ -231,7 +232,7 @@ def unlockfile(mytuple):
        # why test lockfilename?  because we may have been handed an
        # fd originally, and the caller might not like having their
        # open fd closed automatically on them.
-       if type(lockfilename) == types.StringType:
+       if isinstance(lockfilename, basestring):
                os.close(myfd)
 
        return True
index 274d7265486394f942295cab7162dc677fc983da..388428a7cf974f5ceca4f40242f5d9baf70eb0d0 100644 (file)
@@ -1,7 +1,7 @@
 # setup_env.py -- Make sure bin subdir has sane env for testing
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_dep_getcpv.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 import os, shutil, sys
 from os.path import dirname, abspath, join
index b6ca12c72a540f8e06ea7938951c050f5a140a48..70a97cb0a03a2c94d50567069ee83570765da07d 100644 (file)
@@ -1,7 +1,7 @@
 # test_dobin.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_dep_getcpv.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 from setup_env import *
 
index 988b67b8d3175eb502789a76020c84382164e7c1..1035152ce03ee05633494ad20c4d393c1a5a76f0 100644 (file)
@@ -1,7 +1,7 @@
 # test_dodir.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_dodir.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 from setup_env import *
 
index 99a17b80de765cd54198e85f247b48c4de9a8269..82649e24378903c2f69f5585bf03b381b04b0d36 100644 (file)
@@ -1,7 +1,7 @@
 # test_dep_getusedeps.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_dep_getslot.py 5794 2007-01-27 18:16:08Z antarus $
+# $Id$
 
 from portage.tests import TestCase
 from portage.dep import dep_getusedeps
index fb053153b580245bfbdb1b3b930ae37394cba044..228ce4a8299b0649ffbeb7e3e23f25c1a6973815 100644 (file)
@@ -1,7 +1,7 @@
 # test_PackageKeywordsFile.py -- Portage Unit Testing Functionality
 # Copyright 2006 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_PackageKeywordsFile.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 from portage.tests import TestCase
 from portage.env.config import PackageKeywordsFile
index 4000f18071b358817facc6b6c873368964561011..dca8002bced8a1e1d57c5a62c7066404ec8f8e5e 100644 (file)
@@ -1,7 +1,7 @@
 # test_PackageMaskFile.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_PackageMaskFile.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 import os
 
index 93474b6f7d19a8a6977ed2bc233b804358112868..f6eb38846c941af281fe291eeac7f427485ad146 100644 (file)
@@ -1,7 +1,7 @@
 # test_PackageUseFile.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_PackageUseFile.py 6182 2007-03-06 07:35:22Z antarus $
+# $Id$
 
 import os
 from portage.tests import TestCase
index fef66b022b068ed352cd00d928f9d308e31bf66e..f6c59e6a223cd2cf88958b307e7dbcf8810381dd 100644 (file)
@@ -1,7 +1,7 @@
 # test_NewsItem.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_varExpand.py 5596 2007-01-12 08:08:53Z antarus $
+# $Id$
 
 import os
 from portage.tests import TestCase
index a4a87a46132f6f3d5d5a064fdef707bdf934034b..21d15a4bf7e301a8fa6519f92720a2577a41ef36 100644 (file)
@@ -1,3 +1,3 @@
 # Copyright 1998-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: __init__.py 6870 2007-06-19 07:22:18Z zmedico $
+# $Id$
index 4ab67674ee3a9d5448d7258ef3fa80638864446e..ebcc822ef9a27a584c4309fa5ba311059395712e 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1998-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: test_spawn.py 8474 2007-11-09 03:35:38Z zmedico $
+# $Id$
 
 import errno, os, sys
 import fcntl
index 7d588fbc33f0aa85338e42c54e3a22c865762129..5a54e6a7866793f65c3d56bb93bbe112e23eb6b0 100644 (file)
@@ -1,7 +1,7 @@
 # testConfigFileSet.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: testShell.py 7363 2007-07-22 23:21:14Z zmedico $
+# $Id$
 
 import tempfile, os
 
index 71c47dc1b70cb551c743854a443c56f0f55e057c..57a8c58cd5dad6600c671ec4a9a4264d942c6605 100644 (file)
@@ -1,7 +1,7 @@
 # testStaticFileSet.py -- Portage Unit Testing Functionality
 # Copyright 2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Id: testShell.py 7363 2007-07-22 23:21:14Z zmedico $
+# $Id$
 
 import tempfile, os
 
index e2a32b0aa5b293c3369f4bdee6678fce066d300c..1a8acd7f093e4b3bc25ee871c2ed1dbaa46375ed 100644 (file)
@@ -282,7 +282,10 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0):
        pkgs=grabfile(myfilename, compatlevel, recursive=recursive)
        for x in range(len(pkgs)-1, -1, -1):
                pkg = pkgs[x]
-               if pkg[0] in '-*': # -atom *pkg for packages file
+               # for packages and package.mask files
+               if pkg[:1] == "-":
+                       pkg = pkg[1:]
+               if pkg[:1] == "*":
                        pkg = pkg[1:]
                if not isvalidatom(pkg):
                        writemsg("--- Invalid atom in %s: %s\n" % (myfilename, pkgs[x]),