diff --git a/TODO b/TODO index bdff6d759..40066abc9 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,6 @@ TODO list: - world: first fetch all, then upgrade - multipackage: clean tool - implement a sane exception infrastructure - - use cPickle for dumpTools - mirrors: one more and in random order - trigger: Regenerating cracklib dictionary - autotriggers: for enewgroup, enewuser and friends diff --git a/client/equoTools.py b/client/equoTools.py index e75ceb2df..1414ebb9e 100644 --- a/client/equoTools.py +++ b/client/equoTools.py @@ -50,7 +50,9 @@ def loadCaches(): try: mycache = dumpTools.loadobj(etpCache['atomMatch']) if isinstance(mycache, dict): - atomMatchCache = mycache.copy() + atomMatchCache.clear() + atomMatchCache.update(mycache) + del mycache except: atomMatchCache.clear() dumpTools.dumpobj(etpCache['atomMatch'],{}) @@ -59,7 +61,9 @@ def loadCaches(): try: mycache3 = dumpTools.loadobj(etpCache['generateDependsTree']) if isinstance(mycache3, dict): - generateDependsTreeCache = mycache3.copy() + generateDependsTreeCache.clear() + generateDependsTreeCache.update(mycache3) + del mycache3 except: generateDependsTreeCache.clear() dumpTools.dumpobj(etpCache['generateDependsTree'],{}) diff --git a/libraries/dumpTools.py b/libraries/dumpTools.py index 716358eda..6577d6946 100644 --- a/libraries/dumpTools.py +++ b/libraries/dumpTools.py @@ -19,9 +19,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -import sys -from xml.dom import minidom from entropyConstants import * +import cPickle ''' @description: dump object to file @@ -30,13 +29,6 @@ from entropyConstants import * ''' def dumpobj(name, object, completePath = False): while 1: # trap ctrl+C - doc = minidom.Document() - structure = doc.createElement("structure") - doc.appendChild(structure) - data = doc.createElement("data") - structure.appendChild(data) - text = doc.createTextNode(unicode(object)) - data.appendChild(text) # etpConst['dumpstoragedir'] try: if completePath: @@ -45,8 +37,8 @@ def dumpobj(name, object, completePath = False): if not os.path.isdir(etpConst['dumpstoragedir']): os.makedirs(etpConst['dumpstoragedir']) dmpfile = etpConst['dumpstoragedir']+"/"+name+".dmp" - f = open(dmpfile,"w") - f.writelines(doc.toprettyxml(indent=" ")) + f = open(dmpfile,"wb") + cPickle.dump(object,f) f.flush() f.close() except: @@ -66,12 +58,11 @@ def loadobj(name, completePath = False): dmpfile = etpConst['dumpstoragedir']+"/"+name+".dmp" if os.path.isfile(dmpfile): try: - xmldoc = minidom.parse(dmpfile) - structure = xmldoc.firstChild - data = structure.childNodes[1] - x = eval(data.firstChild.data.strip()) - return x - except: + f = open(dmpfile,"rb") + x = cPickle.load(f) + f.close() + return x + except cPickle.UnpicklingError: os.remove(dmpfile) raise SyntaxError,"cannot load object"