Changeset 01e2df in git for modules


Ignore:
Timestamp:
Oct 18, 2005, 3:03:37 PM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
740d7f07620d0ff7edf1cbd7b4e2fa59e20ee5a4
Parents:
8176269a9eb0610a89bd09c4e559ce01fb0d1957
Message:
*bricken: some work


git-svn-id: file:///usr/local/Singular/svn/trunk@8732 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
modules/openmathserver
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/CAS/kuchenessen.py

    r817626 r01e2df  
    318318    def negative(self):
    319319        return kuchen([(m[1],m[0]) for m in self.gebiete])
     320
     321
     322try:
     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)
     339except:
     340        print "no openmath library available"
     341
     342
     343       
  • modules/openmathserver/context.py

    r817626 r01e2df  
    1717        self.implementations[implementation.cd]=implementation
    1818    def lookupImplementation(self, oms):
     19        #print self.implementations
    1920        try:
    2021            return self.implementations[oms.cd][oms]
     
    7071            return func(self,*args)
    7172        except:
     73            from traceback import print_exc
     74            print_exc()
    7275            raise EvaluationFailedError
    7376    def XMLEncodeBody(self,body):
  • modules/openmathserver/objects.py

    r817626 r01e2df  
    66from xml.sax.xmlreader import AttributesImpl as attr
    77import base64
     8raiseException=True
    89#TODO: OMOBJ, OME, OMATTR
    910#from cd import *
     
    146147    def XMLSAXEncode(self, context, generator):
    147148        #works not for attp
     149        #print "attr", self.XMLAttributes
    148150        generator.startElement(self.XMLtag, attr(self.XMLAttributes))
    149151        for c in self.children:
     
    189191        eargs = [context.evaluate(a) for a in self.args]
    190192        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)
    195200                #return self
    196201        else:
     202            #print efunc
    197203            return OMApply(efunc, eargs)
    198204    XMLtag="OMA"
     
    267273        return "OMfloat("+repr(self.value)+")"
    268274    XMLtag = "OMF"
     275   
    269276    def getXMLAttributes(self):
    270277        return {"dec":str(self.value)}
     
    362369    print i.body
    363370    print i.XMLEncode(context)
     371    print context.XMLEncodeObject(OMSymbol("plus", arith1.content))
    364372    #i.body="dshj"
    365373   
  • modules/openmathserver/omxmlreader.py

    r817626 r01e2df  
    2323    root=doc.lastChild
    2424    return root
     25
     26def readStream(input_stream):
     27    docIS=DOMInputSource()
     28    docIS.byteStream=input_stream
     29    doc= DOMBuilder().parse(docIS)
    2530   
     31    root=doc.lastChild
     32    return root
    2633def  get_text_in_children(n):
    2734    t = ""
Note: See TracChangeset for help on using the changeset viewer.