Пример #1
0
def qread(f, **kwargs):
	d=f.readlines()
	attr=nmpml.nameFromFile(f)	
	abst=nmpml.createElement('AbstractModel', attr)
	for l in d:
		l = l.strip()
		if not l or l.startswith("#"):
			continue
		i = l.index("(")
		fn = l[:i]
		argstring = l[i+1:-1]
		args = eval("_kwargstodict(%s)" % argstring)	
		mb=nmpml.createElement('MienBlock', {'Function':fn})
		abst.newElement(mb)
		mb.setArguments(args)
	return nmpml.wrapInDocument([abst])
Пример #2
0
def read(f, **kwargs):
	d=f.read()
	d=eval(d)
	attr=nmpml.nameFromFile(f)	
	abst=nmpml.createElement('AbstractModel', attr)
	disable=[]
	for i, l in enumerate(d):
		fn, args, dis = l[:3]
		if dis:
			disable.append(l)
		mb=nmpml.createElement('MienBlock', {'Function':fn})
		abst.newElement(mb)
		mb.setArguments(args)
	if disable:
		abst.setAttrib('disable', disable)	
	return nmpml.wrapInDocument([abst])