From: Zac Medico Date: Fri, 30 Jun 2006 18:12:54 +0000 (-0000) Subject: Integrate the load_mtimedb() function into the MtimeDB class. This function is relat... X-Git-Tag: v2.1.1~323 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=13e2576b7fa3e46c08a0e580b5bdd9119672f416;p=portage.git Integrate the load_mtimedb() function into the MtimeDB class. This function is relatively new so nobody should miss it. svn path=/main/trunk/; revision=3721 --- diff --git a/pym/portage.py b/pym/portage.py index 99a3591d1..9fd03677e 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -7083,29 +7083,6 @@ class LazyBintreeItem(object): self._bintree.populate() return self._bintree -def load_mtimedb(f): - """Given an open file, unpickle an mtimedb and validate it.""" - mypickle = cPickle.Unpickler(f) - mypickle.find_global = None - d = mypickle.load() - if "old" in d: - d["updates"] = d["old"] - del d["old"] - if "cur" in d: - del d["cur"] - - for k in ("info", "ldpath", "updates"): - d.setdefault(k, {}) - - mtimedbkeys = set(("info", "ldpath", "resume", "resume_backup", - "starttime", "updates", "version")) - - for k in d.keys(): - if k not in mtimedbkeys: - writemsg("Deleting invalid mtimedb key: %s\n" % str(k)) - del d[k] - return d - class MtimeDB(dict): def __init__(self, filename): dict.__init__(self) @@ -7115,11 +7092,32 @@ class MtimeDB(dict): def _load(self, filename): try: f = open(filename) - d = load_mtimedb(f) + mypickle = cPickle.Unpickler(f) + mypickle.find_global = None + d = mypickle.load() f.close() del f except (IOError, OSError, EOFError): - d = {"updates":{}, "ldpath":{}, "version":"", "starttime":0} + d = {} + + if "old" in d: + d["updates"] = d["old"] + del d["old"] + if "cur" in d: + del d["cur"] + + d.setdefault("starttime", 0) + d.setdefault("version", "") + for k in ("info", "ldpath", "updates"): + d.setdefault(k, {}) + + mtimedbkeys = set(("info", "ldpath", "resume", "resume_backup", + "starttime", "updates", "version")) + + for k in d.keys(): + if k not in mtimedbkeys: + writemsg("Deleting invalid mtimedb key: %s\n" % str(k)) + del d[k] self.update(d) def commit(self):