Esempio n. 1
0
File: mzip.py Progetto: gic888/MIEN
def writeZip(f, doc, **kwargs):
	f=ZipFile(f, 'w')
	xml=StringIO()
	xm.writeXML(xml, doc)
	xml=xml.getvalue()
	f.writestr('xml', xml)
	dat=StringIO()
	from mien.parsers.datahash import writeMD	
	writeMD(dat, doc)
	dat=dat.getvalue()
	if dat:
		f.writestr('data', dat)
	f.close()	
Esempio n. 2
0
File: mzip.py Progetto: gic888/MIEN
def serialize(f, doc, **kwargs):
	xml=StringIO()
	xm.writeXML(xml, doc)
	tree=xml.getvalue()
	tree=zlib.compress(tree)
	l=len(tree)
	l=struct.pack('<I', l)
	dat=StringIO()
	from mien.parsers.datahash import writeMD	
	writeMD(dat, doc)
	dat=dat.getvalue()
	if dat and kwargs.get("compress"):
		dat=zlib.compress(dat)
	s=str(l)+tree+dat
	if f!=None:
		f.write(s)
	else:
		return s
Esempio n. 3
0
def writeGenericXML(f, doc, **kwargs):
	pr=kwargs.get('pretty', True)	
	st=kwargs.get('style', {})
	fc=kwargs.get('formatCData', 1)	
	return xm.writeXML(f, doc, st,  pr, fc)
Esempio n. 4
0
def save():
	'''Save the database'''
	open(DB+".bak", "wb").write(open(DB).read())
	open(os.path.join(WD, '.CHANGED'), 'w').write(str(time.time()))
	writeXML(DB, doc, {}, True, True)