Merged from trunk 6889:6917
authorFabian Groffen <grobian@gentoo.org>
Fri, 22 Jun 2007 08:46:32 +0000 (08:46 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 22 Jun 2007 08:46:32 +0000 (08:46 -0000)
   +------------------------------------------------------------------------+
   | 6889     | Make the progress bar percentage indicator stop at 100%     |
   | zmedico  | instead of just 99%.                                        |
   |----------+-------------------------------------------------------------|
   | 6890     | Use the the optparse options for --ignore-default-opts      |
   | zmedico  | since that allows option abreviation to work.               |
   |----------+-------------------------------------------------------------|
   | 6892     | Add an --ignore-default-opts option that is analogous to    |
   | zmedico  | the corresponding emerge option.                            |
   |----------+-------------------------------------------------------------|
   | 6894     | In dblink._security_check(), use os.path.realpath to make   |
   | zmedico  | sure that the same path isn't counted twice.                |
   |----------+-------------------------------------------------------------|
   | 6896     | as noted by Josh Saddler on the gentoo-dev mailing list,    |
   | SpankMan | issue a warning if we try to create a binpkg for something  |
   |          | that has IUSE=bindist but was emerged with USE=-bindist     |
   |----------+-------------------------------------------------------------|
   | 6897     | Make IUSE handling safe for IUSE defaults.                  |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6907     | Don't call digraph.hasallzeros() in --resume mode because   |
   | zmedico  | the digraph isn't currently populated in that case.         |
   |----------+-------------------------------------------------------------|
   | 6909     | Don't generate a list of keys for a containment test.       |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6911     | Remove lots of unnecessary list generation via dict.keys(). |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6912     | Remove more unnecessary list generation.                    |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6913     | Remove more unnecessary list generation.                    |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6914     | Implement UserConfigKlass.__iter__() so that tests pass.    |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6915     | Fix the test so that it can run inside a sandbox.           |
   | zmedico  |                                                             |
   |----------+-------------------------------------------------------------|
   | 6916     | Implement config.has_key() on top of __contains__ instead   |
   | zmedico  | of vice versa.                                              |
   |----------+-------------------------------------------------------------|
   | 6917     | Autodetect if sandbox is active in order to prevent         |
   | zmedico  | recursive sandbox invocation. Thanks to Brian Harring for   |
   |          | the suggestion.                                             |
   +------------------------------------------------------------------------+

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

29 files changed:
bin/fix-db.py
bin/md5check.py
bin/portageq
bin/quickpkg
bin/repoman
pym/emerge/__init__.py
pym/portage/__init__.py
pym/portage/cache/template.py
pym/portage/cache/util.py
pym/portage/checksum.py
pym/portage/cvstree.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/dbapi/virtual.py
pym/portage/elog/__init__.py
pym/portage/elog/filtering.py
pym/portage/elog/messages.py
pym/portage/elog/mod_custom.py
pym/portage/elog/mod_echo.py
pym/portage/elog/mod_mail_summary.py
pym/portage/env/config.py
pym/portage/getbinpkg.py
pym/portage/locks.py
pym/portage/manifest.py
pym/portage/tests/env/config/test_PackageMaskFile.py
pym/portage/tests/env/config/test_PortageModulesFile.py
pym/portage/tests/util/test_varExpand.py
pym/portage/util.py

index 3ea0fc602b578f4c9857df85e77c6f64b9c2a2f6..223fad30a2c7a7af33523cc931cf6f0eedee5318 100755 (executable)
@@ -137,7 +137,7 @@ for cat in os.listdir(vardbdir):
 
 actions = {}
 writemsg("\n\n")
-for catpkg in bad.keys():
+for catpkg in bad:
        bad[catpkg].sort()
 
        mystr = ""
@@ -156,7 +156,7 @@ for catpkg in bad.keys():
 
 if (len(sys.argv) > 1) and (sys.argv[1] == "--fix"):
        writemsg("These are only directions, at the moment.")
-       for catpkg in actions.keys():
+       for catpkg in actions:
                action = actions[catpkg]
                writemsg("We will now '%s' '%s'..." % (action, catpkg))
                #if action == 
index f977e764a666002cc257976e11f52948dc496a65..f574de3cfb5fad239374931307e1bca3ec515f71 100755 (executable)
@@ -68,10 +68,10 @@ for mycpv in hugelist:
                else:
                        continue
                
-               if mybn not in md5sums.keys():
+               if mybn not in md5sums:
                        portage.util.writemsg("Missing md5sum: %s in %s\n" % (mybn, mycpv))
                else:
-                       if mybn in md5_list.keys():
+                       if mybn in md5_list:
                                if (md5_list[mybn]["MD5"]  != md5sums[mybn]["MD5"]) or \
                                   (md5_list[mybn]["size"] != md5sums[mybn]["size"]):
 
@@ -89,12 +89,12 @@ for mycpv in hugelist:
                        del md5sums[mybn]
                
        #portage.writemsg(str(bn_list)+"\n")
-       for x in md5sums.keys():
+       for x in md5sums:
                if x not in bn_list:
                        portage.writemsg("Extra md5sum: %s in %s\n" % (x, mycpv))
 
 
 print col_list
 print
-print str(len(md5_list.keys()))+" unique distfile md5s."
+print str(len(md5_list))+" unique distfile md5s."
 print str(len(bn_list))+" unique distfile names."
index 653bcf229f40d58085196469ad5126cd131db5b1..e0fef37b4753c6fda4734dbd077df1ace0b81a5d 100755 (executable)
@@ -295,7 +295,7 @@ def list_preserved_libs(argv):
                sys.exit(2)
        mylibs = portage.db[argv[0]]["vartree"].dbapi.plib_registry.getPreservedLibs()
        rValue = 0
-       for cpv in mylibs.keys():
+       for cpv in mylibs:
                for path in mylibs[cpv]:
                        print "%s: %s" % (cpv, path)
                        rValue = 1
@@ -318,7 +318,7 @@ def usage(argv):
        # Show our commands -- we do this by scanning the functions in this
        # file, and formatting each functions documentation.
        #
-       commands = [x for x in globals().keys() if x not in \
+       commands = [x for x in globals() if x not in \
                                ("usage", "__doc__", "__name__", "main", "os", "portage", \
                                "sys", "__builtins__", "types", "string","exithandler")]
        commands.sort()
index 0dd9c7fc824a7e05353e5b31a70d11b9cc915c48..366eb1faa4ca7682af0660009bc038f5e0d21bd7 100755 (executable)
@@ -54,6 +54,12 @@ def quickpkg_main(options, args, eout):
                                if not dblnk.exists():
                                        # unmerged by a concurrent process
                                        continue
+                               iuse, use = vardb.aux_get(cpv, ["IUSE","USE"])
+                               iuse = [ x.lstrip("+-") for x in iuse.split() ]
+                               use = use.split()
+                               if "bindist" in iuse and "bindist" not in use:
+                                       eout.ewarn("%s: package was emerged with USE=-bindist!" % cpv)
+                                       eout.ewarn("%s: it may not be legal to redistribute this." % cpv)
                                eout.ebegin("Building package for %s" % cpv)
                                pkgs_for_arg += 1
                                contents = dblnk.getcontents()
@@ -124,9 +130,14 @@ if __name__ == "__main__":
        parser.add_option("--umask",
                default="0077",
                help="umask used during package creation (default is 0077)")
-       from portage import settings
-       default_opts = settings.get("QUICKPKG_DEFAULT_OPTS","").split()
-       options, args = parser.parse_args(default_opts + sys.argv[1:])
+       parser.add_option("--ignore-default-opts",
+               action="store_true",
+               help="do not use the QUICKPKG_DEFAULT_OPTS environment variable")
+       options, args = parser.parse_args(sys.argv[1:])
+       if not options.ignore_default_opts:
+               from portage import settings
+               default_opts = settings.get("QUICKPKG_DEFAULT_OPTS","").split()
+               options, args = parser.parse_args(default_opts + sys.argv[1:])
        if not args:
                parser.error("no packages atoms given")
        try:
index 7410d8b4c74848d665f9c4105885ee1d2785ed95..751a4ffdefa6f236ca942c78b0a682bf4e54243c 100755 (executable)
@@ -353,9 +353,9 @@ myoptions=[]
 if len(sys.argv)>1:
        x=1
        while x < len(sys.argv):
-               if sys.argv[x] in shortmodes.keys():
+               if sys.argv[x] in shortmodes:
                        sys.argv[x]=shortmodes[sys.argv[x]]
-               elif sys.argv[x] in repoman_shortoptions.keys():
+               elif sys.argv[x] in repoman_shortoptions:
                        sys.argv[x] = repoman_shortoptions[sys.argv[x]]
                if sys.argv[x] in modes:
                        if mymode is None:
@@ -1597,7 +1597,7 @@ def grouplist(mylist,seperator="/"):
                xs=x.split(seperator)
                if xs[0]==".":
                        xs=xs[1:]
-               if xs[0] not in mygroups.keys():
+               if xs[0] not in mygroups:
                        mygroups[xs[0]]=[seperator.join(xs[1:])]
                else:
                        mygroups[xs[0]]+=[seperator.join(xs[1:])]
index 23d29c6bbbdda52339c0fa76c523a8f57a333e72..e150ca49bd2265c623bd2a0367b3583d0b7cba95 100644 (file)
@@ -209,7 +209,7 @@ def emergelog(xterm_titles, mystr, short_msg=None):
        if xterm_titles:
                if short_msg == None:
                        short_msg = mystr
-               if "HOSTNAME" in os.environ.keys():
+               if "HOSTNAME" in os.environ:
                        short_msg = os.environ["HOSTNAME"]+": "+short_msg
                xtermTitle(short_msg)
        try:
@@ -442,7 +442,7 @@ class search(object):
                                if self.searchre.search(full_desc):
                                        self.matches["desc"].append([full_package,masked])
                self.mlen=0
-               for mtype in self.matches.keys():
+               for mtype in self.matches:
                        self.matches[mtype].sort()
                        self.mlen += len(self.matches[mtype])
 
@@ -451,7 +451,7 @@ class search(object):
                print "\b\b  \n[ Results for search key : "+white(self.searchkey)+" ]"
                print "[ Applications found : "+white(str(self.mlen))+" ]"
                print " "
-               for mtype in self.matches.keys():
+               for mtype in self.matches:
                        for match,masked in self.matches[mtype]:
                                if mtype=="pkg":
                                        catpack=match
@@ -2215,7 +2215,7 @@ class depgraph(object):
                        mylist = getlist(self.settings, "system")
                        worlddict=genericdict(worldlist)
 
-                       for x in worlddict.keys():
+                       for x in worlddict:
                                if not portage.isvalidatom(x):
                                        world_problems = True
                                        continue
@@ -2698,7 +2698,7 @@ class depgraph(object):
                                                if myfilesdict is None:
                                                        myfilesdict="[empty/missing/bad digest]"
                                                else:
-                                                       for myfetchfile in myfilesdict.keys():
+                                                       for myfetchfile in myfilesdict:
                                                                if myfetchfile not in myfetchlist:
                                                                        mysize+=myfilesdict[myfetchfile]
                                                                        myfetchlist.append(myfetchfile)
@@ -3613,7 +3613,7 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
                                        if not slotmap.has_key(myslot):
                                                slotmap[myslot]={}
                                        slotmap[myslot][localtree.dbapi.cpv_counter(mypkg)]=mypkg
-                               for myslot in slotmap.keys():
+                               for myslot in slotmap:
                                        counterkeys=slotmap[myslot].keys()
                                        counterkeys.sort()
                                        if not counterkeys:
@@ -3640,7 +3640,7 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
        finally:
                if vdb_lock:
                        portage.locks.unlockdir(vdb_lock)
-       for x in pkgmap.keys():
+       for x in pkgmap:
                for y in localtree.dep_match(x):
                        if y not in pkgmap[x]["omitted"] and \
                           y not in pkgmap[x]["selected"] and \
@@ -3696,7 +3696,7 @@ def unmerge(settings, myopts, vartree, unmerge_action, unmerge_files,
        if not autoclean:
                countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging")
 
-       for x in pkgmap.keys():
+       for x in pkgmap:
                for y in pkgmap[x]["selected"]:
                        print ">>> Unmerging "+y+"..."
                        emergelog(xterm_titles, "=== Unmerging... ("+y+")")
@@ -3880,7 +3880,7 @@ def post_emerge(trees, mtimedb, retval):
        if vardbapi.plib_registry.hasEntries():
                print colorize("WARN", "!!!") + " existing preserved libs:"
                plibdata = vardbapi.plib_registry.getPreservedLibs()
-               for cpv in plibdata.keys():
+               for cpv in plibdata:
                        print colorize("WARN", ">>>") + " package: %s" % cpv
                        for f in plibdata[cpv]:
                                print colorize("WARN", " * ") + " - %s" % f
@@ -5188,11 +5188,11 @@ def action_build(settings, trees, mtimedb,
                else:
                        mydepgraph.display(
                                mydepgraph.altlist(reversed=("--tree" in myopts)))
-               if ("--buildpkgonly" in myopts):
-                       if not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
-                               print "\n!!! --buildpkgonly requires all dependencies to be merged."
-                               print "!!! You have to merge the dependencies before you can build this package.\n"
-                               sys.exit(1)
+                       if "--buildpkgonly" in myopts and \
+                               not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
+                                       print "\n!!! --buildpkgonly requires all dependencies to be merged."
+                                       print "!!! You have to merge the dependencies before you can build this package.\n"
+                                       sys.exit(1)
        else:
                if ("--buildpkgonly" in myopts):
                        if not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
@@ -5510,7 +5510,7 @@ def emerge_main():
        xterm_titles = "notitles" not in settings.features
 
        tmpcmdline = []
-       if "--ignore-default-opts" not in sys.argv:
+       if "--ignore-default-opts" not in myopts:
                tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split())
        tmpcmdline.extend(sys.argv[1:])
        myaction, myopts, myfiles = parse_opts(tmpcmdline)
index bd27baa7caa43f207930e51a6369589944d2c262..53497266602b4aaed75be6ae759208b8a24c4d8f 100644 (file)
@@ -1653,9 +1653,8 @@ class config(object):
 
        def load_infodir(self,infodir):
                self.modifying()
-               if self.configdict.has_key("pkg"):
-                       for x in self.configdict["pkg"].keys():
-                               del self.configdict["pkg"][x]
+               if "pkg" in self.configdict:
+                       self.configdict["pkg"].clear()
                else:
                        writemsg("No pkg setup for settings instance?\n",
                                noiselevel=-1)
@@ -2114,8 +2113,7 @@ class config(object):
                        return self.virts_p
                virts = self.getvirtuals(myroot)
                if virts:
-                       myvkeys = virts.keys()
-                       for x in myvkeys:
+                       for x in virts:
                                vkeysplit = x.split("/")
                                if not self.virts_p.has_key(vkeysplit[1]):
                                        self.virts_p[vkeysplit[1]] = virts[x]
@@ -2213,14 +2211,14 @@ class config(object):
                return match
 
        def has_key(self,mykey):
-               for x in self.lookuplist:
-                       if x.has_key(mykey):
-                               return 1
-               return 0
+               return mykey in self
 
        def __contains__(self, mykey):
                """Called to implement membership test operators (in and not in)."""
-               return bool(self.has_key(mykey))
+               for d in self.lookuplist:
+                       if mykey in d:
+                               return True
+               return False
 
        def setdefault(self, k, x=None):
                if k in self:
@@ -2236,7 +2234,16 @@ class config(object):
                        return x
 
        def keys(self):
-               return unique_array(flatten([x.keys() for x in self.lookuplist]))
+               return list(self)
+
+       def __iter__(self):
+               keys = set()
+               for d in self.lookuplist:
+                       for k in d:
+                               if k in keys:
+                                       continue
+                               keys.add(k)
+                               yield k
 
        def __setitem__(self,mykey,myvalue):
                "set a value; will be thrown away at reset() time"
@@ -2249,7 +2256,7 @@ class config(object):
        def environ(self):
                "return our locally-maintained environment"
                mydict={}
-               for x in self.keys():
+               for x in self:
                        myvalue = self[x]
                        if not isinstance(myvalue, basestring):
                                writemsg("!!! Non-string value in config: %s=%s\n" % \
@@ -2425,7 +2432,7 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, **keyw
                        (not droppriv and "sandbox" not in features and \
                        "usersandbox" not in features))
 
-       if free:
+       if free or "SANDBOX_ACTIVE" in os.environ:
                keywords["opt_name"] += " bash"
                spawn_func = portage.process.spawn_bash
        else:
@@ -2648,7 +2655,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                        noiselevel=-1)
                                return 0
                        del distlocks_subdir
-       for myfile in filedict.keys():
+       for myfile in filedict:
                """
                fetched  status
                0        nonexistent
@@ -2879,7 +2886,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                else:
                                                                        eout = portage.output.EOutput()
                                                                        eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
-                                                                       for x_key in mydigests[myfile].keys():
+                                                                       for x_key in mydigests[myfile]:
                                                                                eout.ebegin("%s %s ;-)" % (myfile, x_key))
                                                                                eout.eend(0)
                                                                        fetched=2
@@ -3135,7 +3142,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
 def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
        if alwaysdep or "noauto" not in mysettings.features:
                # process dependency first
-               if "dep" in actionmap[mydo].keys():
+               if "dep" in actionmap[mydo]:
                        retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
                        if retval:
                                return retval
@@ -3944,11 +3951,11 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
 
                # merge the deps in so we have again a 'full' actionmap
                # be glad when this can die.
-               for x in actionmap.keys():
+               for x in actionmap:
                        if len(actionmap_deps.get(x, [])):
                                actionmap[x]["dep"] = ' '.join(actionmap_deps[x])
 
-               if mydo in actionmap.keys():
+               if mydo in actionmap:
                        retval = spawnebuild(mydo,
                                actionmap, mysettings, debug, logfile=logfile)
                elif mydo=="qmerge":
@@ -4954,9 +4961,11 @@ class FetchlistDict(UserDict.DictMixin):
                """Returns the complete fetch list for a given package."""
                return self.portdb.getfetchlist(pkg_key, mysettings=self.settings,
                        all=True, mytree=self.mytree)[1]
+       def __contains__(self):
+               return pkg_key in self.keys()
        def has_key(self, pkg_key):
                """Returns true if the given package exists within pkgdir."""
-               return pkg_key in self.keys()
+               return pkg_key in self
        def keys(self):
                """Returns keys for all packages within pkgdir"""
                return self.portdb.cp_list(self.cp, mytree=self.mytree)
index c0aea17acb264cfa157d992dd487428d898e728b..5034fc8cb08c9319c5832bcef7616d763b1be26d 100644 (file)
@@ -145,7 +145,7 @@ class database(object):
                        if key not in self.__known_keys:
                                raise InvalidRestriction(key, match, "Key isn't valid")
 
-               for cpv in self.keys():
+               for cpv in self.iterkeys():
                        cont = True
                        vals = self[cpv]
                        for key, match in restricts.iteritems():
index c31dc9163a965acae58834b91a8bb42ae801335b..8884562ee8f34a0dafeba73cb53a63e3231e694c 100644 (file)
@@ -18,8 +18,7 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
        else:
                noise=verbose_instance
 
-       dead_nodes = {}
-       dead_nodes = dict.fromkeys(trg_cache.keys())
+       dead_nodes = set(trg_cache.iterkeys())
        count=0
 
        if not trg_cache.autocommits:
@@ -28,8 +27,7 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
        for x in valid_nodes_iterable:
 #              print "processing x=",x
                count+=1
-               if dead_nodes.has_key(x):
-                       del dead_nodes[x]
+               dead_nodes.discard(x)
                try:    entry = src_cache[x]
                except KeyError, e:
                        noise.missing_entry(x)
@@ -99,7 +97,6 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                except cache_errors.CacheError, ce:
                        noise.exception(ce)
                        del ce
-       dead_nodes.clear()
        noise.finish()
 
 
index de4be208c7d410ae283b118fc34ac0382f04745a..576d502b268ce8c2cb77da7675f27e31ddea2e82 100644 (file)
@@ -79,7 +79,7 @@ def perform_md5(x, calc_prelink=0):
 
 def perform_all(x, calc_prelink=0):
        mydict = {}
-       for k in hashfunc_map.keys():
+       for k in hashfunc_map:
                mydict[k] = perform_checksum(x, hashfunc_map[k], calc_prelink)[0]
        return mydict
 
@@ -131,10 +131,10 @@ def verify_all(filename, mydict, calc_prelink=0, strict=0):
                got = " ".join(got)
                return False, ("Insufficient data for checksum verification", got, expected)
 
-       for x in mydict.keys():
+       for x in mydict:
                if   x == "size":
                        continue
-               elif x in hashfunc_map.keys():
+               elif x in hashfunc_map:
                        myhash = perform_checksum(filename, x, calc_prelink=calc_prelink)[0]
                        if mydict[x] != myhash:
                                if strict:
index 8a9450afda6c0949cddb5640d584a459bf067cbd..ede3ad589e952b3b19678c87f29620cf581d4f36 100644 (file)
@@ -64,12 +64,12 @@ def findnew(entries,recursive=0,basedir=""):
        if basedir and basedir[-1]!="/":
                basedir=basedir+"/"
        mylist=[]
-       for myfile in entries["files"].keys():
+       for myfile in entries["files"]:
                if "cvs" in entries["files"][myfile]["status"]:
                        if "0" == entries["files"][myfile]["revision"]:
                                mylist.append(basedir+myfile)
        if recursive:
-               for mydir in entries["dirs"].keys():
+               for mydir in entries["dirs"]:
                        mylist+=findnew(entries["dirs"][mydir],recursive,basedir+mydir)
        return mylist
                                        
@@ -81,14 +81,14 @@ def findchanged(entries,recursive=0,basedir=""):
        if basedir and basedir[-1]!="/":
                basedir=basedir+"/"
        mylist=[]
-       for myfile in entries["files"].keys():
+       for myfile in entries["files"]:
                if "cvs" in entries["files"][myfile]["status"]:
                        if "current" not in entries["files"][myfile]["status"]:
                                if "exists" in entries["files"][myfile]["status"]:
                                        if entries["files"][myfile]["revision"]!="0":
                                                mylist.append(basedir+myfile)
        if recursive:
-               for mydir in entries["dirs"].keys():
+               for mydir in entries["dirs"]:
                        mylist+=findchanged(entries["dirs"][mydir],recursive,basedir+mydir)
        return mylist
        
@@ -100,13 +100,13 @@ def findmissing(entries,recursive=0,basedir=""):
        if basedir and basedir[-1]!="/":
                basedir=basedir+"/"
        mylist=[]
-       for myfile in entries["files"].keys():
+       for myfile in entries["files"]:
                if "cvs" in entries["files"][myfile]["status"]:
                        if "exists" not in entries["files"][myfile]["status"]:
                                if "removed" not in entries["files"][myfile]["status"]:
                                        mylist.append(basedir+myfile)
        if recursive:
-               for mydir in entries["dirs"].keys():
+               for mydir in entries["dirs"]:
                        mylist+=findmissing(entries["dirs"][mydir],recursive,basedir+mydir)
        return mylist
 
@@ -120,11 +120,11 @@ def findunadded(entries,recursive=0,basedir=""):
        mylist=[]
 
        #ignore what cvs ignores.
-       for myfile in entries["files"].keys():
+       for myfile in entries["files"]:
                if "cvs" not in entries["files"][myfile]["status"]:
                        mylist.append(basedir+myfile)
        if recursive:
-               for mydir in entries["dirs"].keys():
+               for mydir in entries["dirs"]:
                        mylist+=findunadded(entries["dirs"][mydir],recursive,basedir+mydir)
        return mylist
 
@@ -135,11 +135,11 @@ def findremoved(entries,recursive=0,basedir=""):
        if basedir and basedir[-1]!="/":
                basedir=basedir+"/"
        mylist=[]
-       for myfile in entries["files"].keys():
+       for myfile in entries["files"]:
                if "removed" in entries["files"][myfile]["status"]:
                        mylist.append(basedir+myfile)
        if recursive:
-               for mydir in entries["dirs"].keys():
+               for mydir in entries["dirs"]:
                        mylist+=findremoved(entries["dirs"][mydir],recursive,basedir+mydir)
        return mylist
 
index 713a8c612738e0098197af460be2193574487132..3242cc158f2c25bf28f2ae000e10d4ba35ecdd63 100644 (file)
@@ -506,8 +506,7 @@ class binarytree(object):
                        # since it will provide no benefit due to the need to read CATEGORY
                        # from xpak.
                        if update_pkgindex and os.access(self.pkgdir, os.W_OK):
-                               cpv_all = self._pkg_paths.keys()
-                               stale = set(metadata).difference(cpv_all)
+                               stale = [cpv for cpv in metadata if cpv not in self._pkg_paths]
                                for cpv in stale:
                                        del metadata[cpv]
                                from portage.util import atomic_ofstream
index 0f23ce70e9c3c61c965f163709820535ccf3dd89..524a36fa2ecaa549091d34c1ed02377d091606b5 100644 (file)
@@ -144,7 +144,7 @@ class portdbapi(dbapi):
                if not hasattr(self, "auxdb"):
                        # unhandled exception thrown from constructor
                        return
-               for x in self.auxdb.keys():
+               for x in self.auxdb:
                        self.auxdb[x].sync()
                self.auxdb.clear()
 
@@ -192,7 +192,7 @@ class portdbapi(dbapi):
                repository ID's
                TreeMap = {id: path}
                """
-               return [k for k in self.treemap.keys() if k]
+               return [k for k in self.treemap if k]
 
        def findname2(self, mycpv, mytree=None):
                """ 
@@ -348,7 +348,7 @@ class portdbapi(dbapi):
                returnme = []
                for x in mylist:
                        if x == "INHERITED":
-                               returnme.append(' '.join(mydata.get("_eclasses_", {}).keys()))
+                               returnme.append(' '.join(mydata.get("_eclasses_", [])))
                        else:
                                returnme.append(mydata.get(x,""))
 
index 35ed7fe086e467711fa5e691335c3c93ea0d9611..7a3cf5768f121c690e76fa0592acf2f60a109621 100644 (file)
@@ -106,7 +106,7 @@ class PreservedLibsRegistry(object):
        
        def hasEntries(self):
                """ Check if this registry contains any records. """
-               return (len(self._data.keys()) > 0)
+               return len(self._data) > 0
        
        def getPreservedLibs(self):
                """ Return a mapping of packages->preserved objects.
@@ -114,7 +114,7 @@ class PreservedLibsRegistry(object):
                        @rtype Dict cpv->list-of-paths
                """
                rValue = {}
-               for cps in self._data.keys():
+               for cps in self._data:
                        rValue[self._data[cps][0]] = self._data[cps][2]
                return rValue
 
@@ -154,7 +154,7 @@ class LibraryPackageMap(object):
                                        else:
                                                obj_dict[lib].append(mysplit[0])
                mapfile = open(self._filename, "w")
-               for lib in obj_dict.keys():
+               for lib in obj_dict:
                        mapfile.write(lib+" "+",".join(obj_dict[lib])+"\n")
                mapfile.close()
 
@@ -1337,10 +1337,10 @@ class dblink(object):
 
                # get list of libraries from old package instance
                old_contents = self._installed_instance.getcontents().keys()
-               old_libs = set([os.path.basename(x) for x in old_contents]).intersection(libmap.keys())
+               old_libs = set([os.path.basename(x) for x in old_contents]).intersection(libmap)
 
                # get list of libraries from new package instance
-               mylibs = set([os.path.basename(x) for x in mycontents]).intersection(libmap.keys())
+               mylibs = set([os.path.basename(x) for x in mycontents]).intersection(libmap)
 
                # check which libs are present in the old, but not the new package instance
                preserve_libs = old_libs.difference(mylibs)
@@ -1506,6 +1506,7 @@ class dblink(object):
                for dblnk in installed_instances:
                        file_paths.update(dblnk.getcontents())
                inode_map = {}
+               real_paths = set()
                for path in file_paths:
                        try:
                                s = os.lstat(path)
@@ -1514,8 +1515,13 @@ class dblink(object):
                                        raise
                                del e
                                continue
-                       if stat.S_ISREG(s.st_mode) and \
-                               s.st_nlink > 1 and \
+                       if not stat.S_ISREG(s.st_mode):
+                               continue
+                       path = os.path.realpath(path)
+                       if path in real_paths:
+                               continue
+                       real_paths.add(path)
+                       if s.st_nlink > 1 and \
                                s.st_mode & (stat.S_ISUID | stat.S_ISGID):
                                k = (s.st_dev, s.st_ino)
                                inode_map.setdefault(k, []).append((path, s))
index 055503ab8102a004db6fbc632db052aaafb31b36..983e39b7f4ae6ebd957eb7e62ef46c17f306a157 100644 (file)
@@ -40,7 +40,7 @@ class fakedbapi(dbapi):
 
        def cp_all(self):
                returnme=[]
-               for x in self.cpdict.keys():
+               for x in self.cpdict:
                        returnme.extend(self.cpdict[x])
                return returnme
 
index 77bdd1b944e85794edcf678db463ea4ccf41709a..5b8ac44c3aa92da2d67d810af8a8383d4641d47e 100644 (file)
@@ -15,7 +15,8 @@ import os
 
 def _merge_logentries(a, b):
        rValue = {}
-       phases = set(a.keys()+b.keys())
+       phases = set(a)
+       phases.update(b)
        for p in phases:
                rValue[p] = []
                if a.has_key(p):
@@ -51,7 +52,7 @@ def elog_process(cpv, mysettings):
        my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
 
 
-       for key in all_logentries.keys():
+       for key in all_logentries:
                default_logentries = filter_loglevels(all_logentries[key], my_elog_classes)
 
                # in case the filters matched all messages and no module overrides exist
index f4748fede646f986e92204ea4b55d5a888957712..e8a5430fd04cc09bd4e9ba81895d7dfc3bab5db1 100644 (file)
@@ -7,7 +7,7 @@ def filter_loglevels(logentries, loglevels):
        # remove unwanted entries from all logentries
        rValue = {}
        loglevels = map(str.upper, loglevels)
-       for phase in logentries.keys():
+       for phase in logentries:
                for msgtype, msgcontent in logentries[phase]:
                        if msgtype.upper() in loglevels or "*" in loglevels:
                                if not rValue.has_key(phase):
index bfe428030dd50ccbb7a706e4a04ddffa512ad1b1..c2b21ac800f4bd6c6b04401aef0fd7dbf8ff918b 100644 (file)
@@ -84,6 +84,6 @@ def _make_msgfunction(level, color):
        return _elog
 
 import sys
-for f in _functions.keys():
+for f in _functions:
        setattr(sys.modules[__name__], f, _make_msgfunction(_functions[f][0], _functions[f][1]))
 del f, _functions
index a486c8931e6b98542a8cf21a233d457bc0396bb7..09d981a0c05d85fa9946bd9d2047a8d1d9b9f2b3 100644 (file)
@@ -8,8 +8,7 @@ import portage.elog_modules.mod_save, portage.process, portage.exception
 def process(mysettings, key, logentries, fulltext):
        elogfilename = portage.elog_modules.mod_save.process(mysettings, key, logentries, fulltext)
        
-       if (not "PORTAGE_ELOG_COMMAND" in mysettings.keys()) \
-                       or len(mysettings["PORTAGE_ELOG_COMMAND"]) == 0:
+       if not mysettings.get("PORTAGE_ELOG_COMMAND"):
                raise portage.exception.MissingParameter("!!! Custom logging requested but PORTAGE_ELOG_COMMAND is not defined")
        else:
                mylogcmd = mysettings["PORTAGE_ELOG_COMMAND"]
index 125a8c40e2181b53a0aa2dcc269d16a27ab342d2..6dcc652338b4253193db3a1b871b53a2b10fcc4d 100644 (file)
@@ -12,7 +12,7 @@ def process(mysettings, key, logentries, fulltext):
 
 def finalize(mysettings):
        printer = EOutput()
-       for key in _items.keys():
+       for key in _items:
                print
                printer.einfo("Messages for package %s:" % key)
                print
index a8e6949354294f3b11be756a20f71532adf03265..0a39b17b13770d1fe72deb022a361a82593669a4 100644 (file)
@@ -31,7 +31,7 @@ def finalize(mysettings):
 
        mybody = "elog messages for the following packages generated by " + \
                "process %d on host %s:\n" % (os.getpid(), socket.getfqdn())
-       for key in _items.keys():
+       for key in _items:
                 mybody += "- %s\n" % key
 
        mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, mybody, attachments=_items.values())
index 192d1085293d6980103921fcc60eec90ca83a199..a354dcf7de6b66198db5469c7f7419600b8e360e 100644 (file)
@@ -30,6 +30,9 @@ class UserConfigKlass(UserDict,object):
 
                self.data, self.errors = self._loader.load()
 
+       def __iter__(self):
+               return iter(self.data)
+
 class PackageKeywordsFile(UserConfigKlass):
        """
        Inherits from UserConfigKlass; implements a file-based backend.
index 79ddca5451c07df11a0ae9b5b00408764b4faca6..760fa103c20c2bcd53376b3a8a3ecae5c96a5140 100644 (file)
@@ -516,8 +516,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        for x in tbz2list:
                x = os.path.basename(x)
                binpkg_filenames.add(x)
-               if ((not metadata[baseurl]["data"].has_key(x)) or \
-                   (x not in metadata[baseurl]["data"].keys())):
+               if x not in metadata[baseurl]["data"]:
                        sys.stderr.write(yellow("x"))
                        metadata[baseurl]["modified"] = 1
                        myid = None
index 836b8306af8639d421712727f523403d96260a60..bed8ed36a27baaa91a56e5f23646b0cc403126c7 100644 (file)
@@ -285,13 +285,13 @@ def hardlock_cleanup(path, remove_all_locks=False):
 
        results.append("Found %(count)s locks" % {"count":mycount})
        
-       for x in mylist.keys():
+       for x in mylist:
                if mylist[x].has_key(myhost) or remove_all_locks:
                        mylockname = hardlock_name(path+"/"+x)
                        if hardlink_is_mine(mylockname, path+"/"+x) or \
                           not os.path.exists(path+"/"+x) or \
                                 remove_all_locks:
-                               for y in mylist[x].keys():
+                               for y in mylist[x]:
                                        for z in mylist[x][y]:
                                                filename = path+"/"+x+".hardlock-"+y+"-"+z
                                                if filename == mylockname:
index cd03dc293d18218316bef6a371b7113edaeaa8f9..5add55c81ab5d62e987231c1e24f0f69f404545f 100644 (file)
@@ -79,8 +79,7 @@ class ManifestEntry(object):
 
 class Manifest1Entry(ManifestEntry):
        def __str__(self):
-               myhashkeys = self.hashes.keys()
-               for hashkey in myhashkeys:
+               for hashkey in self.hashes:
                        if hashkey != "size":
                                break
                hashvalue = self.hashes[hashkey]
@@ -345,9 +344,9 @@ class Manifest(object):
                                        pass
 
        def checkIntegrity(self):
-               for t in self.fhashdict.keys():
+               for t in self.fhashdict:
                        for f in self.fhashdict[t]:
-                               if not portage.const.MANIFEST2_REQUIRED_HASH in self.fhashdict[t][f].keys():
+                               if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
                                        raise MissingParameter("Missing %s checksum: %s %s" % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
 
        def write(self, sign=False, force=False):
index ad87d5a56a15131411e19cc065454a84fc51c92e..e8357f7e61b2754e60df6d33ef59affa27866289 100644 (file)
@@ -18,7 +18,8 @@ class PackageMaskFileTestCase(TestCase):
                try:
                        f = PackageMaskFile(self.fname)
                        f.load()
-                       [atom for atom in f.keys() if self.assertTrue(atom in self.atoms)]
+                       for atom in f:
+                               self.assertTrue(atom in self.atoms)
                finally:
                        self.NukeFile()
        
index b523cbe7bf370ca32ca55f4b20fb9c252e9197b1..03104cff5f182a830fa6df52f435fab7f12165e1 100644 (file)
@@ -18,7 +18,7 @@ class PortageModulesFileTestCase(TestCase):
        def testPortageModulesFile(self):
                self.BuildFile()
                f = PortageModulesFile(self.fname)
-               for k in f.keys():
+               for k in f:
                        self.assertEqual( f[k], self.items[k] )
                self.NukeFile()
 
index ee0f573c97b1e656d80b0edd77b4c7feebf446c0..e4f85ef43d08f2c707b0156aefc681837284df72 100644 (file)
@@ -11,7 +11,7 @@ class VarExpandTestCase(TestCase):
        def testVarExpandPass(self):
 
                varDict = { "a":"5", "b":"7", "c":"-5" }
-               for key in varDict.keys():
+               for key in varDict:
                        result = varexpand( "$%s" % key, varDict )
                        
                        self.failIf( result != varDict[key],
index bf1bbe9df8f3e6f1c83f3f8d657a7f51680c811c..ebaafd70d9b0ae1e92df61630a9287e76bec475c 100644 (file)
@@ -77,7 +77,7 @@ def map_dictlist_vals(func,myDict):
        """Performs a function on each value of each key in a dictlist.
        Returns a new dictlist."""
        new_dl = {}
-       for key in myDict.keys():
+       for key in myDict:
                new_dl[key] = []
                new_dl[key] = map(func,myDict[key])
        return new_dl
@@ -119,7 +119,7 @@ def stack_dictlist(original_dicts, incremental=0, incrementals=[], ignore_none=0
        for mydict in original_dicts:
                if mydict is None:
                        continue
-               for y in mydict.keys():
+               for y in mydict:
                        if not y in final_dict:
                                final_dict[y] = []
                        
@@ -281,7 +281,7 @@ def writedict(mydict,myfilename,writekey=True):
                        for x in mydict.values():
                                myfile.write(x+"\n")
                else:
-                       for x in mydict.keys():
+                       for x in mydict:
                                myfile.write("%s %s\n" % (x, " ".join(mydict[x])))
                myfile.close()
        except IOError: