switching to cPickle

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@853 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
(no author)
2007-12-12 23:10:40 +00:00
parent 100dafbcb2
commit 8e87e26c33
3 changed files with 14 additions and 20 deletions

1
TODO
View File

@@ -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

View File

@@ -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'],{})

View File

@@ -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"