- Timestamp:
- Oct 18, 2005, 3:03:37 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 740d7f07620d0ff7edf1cbd7b4e2fa59e20ee5a4
- Parents:
- 8176269a9eb0610a89bd09c4e559ce01fb0d1957
- Location:
- modules/openmathserver
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/openmathserver/CAS/kuchenessen.py
r817626 r01e2df 318 318 def negative(self): 319 319 return kuchen([(m[1],m[0]) for m in self.gebiete]) 320 321 322 try: 323 from objects import * 324 import CD.gametheory 325 def decode_kuchen_OM(kOM): 326 assert isinstance(kOM,OMApply) 327 sizes=[a.getValue() for a in kOM.args] 328 regions=[(sizes[i],sizes[i+1]) for i in xrange(0, len(sizes),2)] 329 return kuchen(regions) 330 def left_wins_func(context, kuchen): 331 kuchen=decode_kuchen_OM(kuchen) 332 erg=kuchen.greater_equal_zero() 333 if erg: 334 return OMint(1) 335 else: 336 return OMint(0) 337 def install_kuchenessen_plugin(): 338 CD.gametheory.implementation.implement("left_wins", left_wins_func) 339 except: 340 print "no openmath library available" 341 342 343 -
modules/openmathserver/context.py
r817626 r01e2df 17 17 self.implementations[implementation.cd]=implementation 18 18 def lookupImplementation(self, oms): 19 #print self.implementations 19 20 try: 20 21 return self.implementations[oms.cd][oms] … … 70 71 return func(self,*args) 71 72 except: 73 from traceback import print_exc 74 print_exc() 72 75 raise EvaluationFailedError 73 76 def XMLEncodeBody(self,body): -
modules/openmathserver/objects.py
r817626 r01e2df 6 6 from xml.sax.xmlreader import AttributesImpl as attr 7 7 import base64 8 raiseException=True 8 9 #TODO: OMOBJ, OME, OMATTR 9 10 #from cd import * … … 146 147 def XMLSAXEncode(self, context, generator): 147 148 #works not for attp 149 #print "attr", self.XMLAttributes 148 150 generator.startElement(self.XMLtag, attr(self.XMLAttributes)) 149 151 for c in self.children: … … 189 191 eargs = [context.evaluate(a) for a in self.args] 190 192 if callable(efunc): 191 try: 192 return context.apply(efunc, eargs) 193 except EvaluationFailedError, NotImplementedError: 194 return OMApply(efunc, eargs) 193 if raiseException: 194 return context.apply(efunc,eargs) 195 else: 196 try: 197 return context.apply(efunc, eargs) 198 except EvaluationFailedError, NotImplementedError: 199 return OMApply(efunc, eargs) 195 200 #return self 196 201 else: 202 #print efunc 197 203 return OMApply(efunc, eargs) 198 204 XMLtag="OMA" … … 267 273 return "OMfloat("+repr(self.value)+")" 268 274 XMLtag = "OMF" 275 269 276 def getXMLAttributes(self): 270 277 return {"dec":str(self.value)} … … 362 369 print i.body 363 370 print i.XMLEncode(context) 371 print context.XMLEncodeObject(OMSymbol("plus", arith1.content)) 364 372 #i.body="dshj" 365 373 -
modules/openmathserver/omxmlreader.py
r817626 r01e2df 23 23 root=doc.lastChild 24 24 return root 25 26 def readStream(input_stream): 27 docIS=DOMInputSource() 28 docIS.byteStream=input_stream 29 doc= DOMBuilder().parse(docIS) 25 30 31 root=doc.lastChild 32 return root 26 33 def get_text_in_children(n): 27 34 t = ""
Note: See TracChangeset
for help on using the changeset viewer.