Changeset 01cd17f in git


Ignore:
Timestamp:
Jun 15, 2005, 1:52:50 PM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '648d28f488f6ff08f5607ff229b9ad9e4a5b93c2')
Children:
aeb6d365075d1f830530abf950058c3afdc8f977
Parents:
16678227fe277530e8904f607ce8e6128f93df2a
Message:
*bricken: refactoring


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

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/objects.py

    r1667822 r01cd17f  
    22from exceptions import *
    33#from cd import *
    4 class XMLattribute(object):
     4class XMLAttribute(object):
    55    def __init__(self, name, value):
    66        self.name=name
     
    5656        except AttributeError:
    5757                raise UnsupportedOperationError
    58     def __getXMLattributes(self):
    59         try:
    60             return self.getXMLattributes()
    61         except AttributeError:
    62             try:
    63                 return self.__XMLattributes
     58    def __getXMLAttributes(self):
     59        try:
     60            return self.getXMLAttributes()
     61        except AttributeError:
     62            try:
     63                return self.__XMLAttributes
    6464            except AttributeError:
    6565                #do return None, cause if modifiying a new list, changes will not be saved
    6666                return []
    67     def __delXMLattributes(self):
    68         try:
    69             self.delXMLattributes()
     67    def __delXMLAttributes(self):
     68        try:
     69            self.delXMLAttributes()
    7070            return
    7171        except AttributeError:
    7272            try:
    73                 del self.__XMLattributes
     73                del self.__XMLAttributes
    7474            except AttributeError:
    7575                pass
    76     def __setXMLattributes(self,XMLattributes):
    77         try:
    78             self.setBody(XMLattributes)
     76    def __setXMLAttributes(self,XMLAttributes):
     77        try:
     78            self.setBody(XMLAttributes)
    7979        except AttributeError:
    8080            raise UnsupportedOperationError
     
    8383    body=property(__getBody,__setBody,__delBody,\
    8484        "xml body,FIXME: at the moment only char data")
    85     XMLattributes=property(__getXMLattributes,__setXMLattributes,__delXMLattributes,\
     85    XMLAttributes=property(__getXMLAttributes,__setXMLAttributes,__delXMLAttributes,\
    8686        "xml attributes")
    8787    def XMLencode(self, context):
    8888       
    89         attr=self.XMLattributes
     89        attr=self.XMLAttributes
    9090        if attr:
    9191            attrstr=" "+" ".join([a.encode(context) for a in attr])
     
    117117        return "OMV(" + self.name +")"
    118118    XMLtag="OMV"
    119     def getXMLattributes(self):
    120         return [XMLattribute("name", self.name)]
     119    def getXMLAttributes(self):
     120        return [XMLAttribute("name", self.name)]
    121121       
    122 class OMapplication(OMObjectBase):
     122class OMApply(OMObjectBase):
    123123    def __init__(self, func, args):
    124         super(OMapplication,self).__init__()
     124        super(OMApply,self).__init__()
    125125        self.func=func
    126126        self.args=args
     
    132132                return context.apply(efunc, eargs)
    133133            except EvaluationFailedError, NotImplementedError:
    134                 return OMapplication(efunc, eargs)
     134                return OMApply(efunc, eargs)
    135135                #return self
    136136        else:
    137             return OMapplication(efunc, eargs)
     137            return OMApply(efunc, eargs)
    138138    XMLtag="OMA"
    139139    def getChildren(self):
     
    159159        return context.evaluateSymbol(self)
    160160    XMLtag="OMS"
    161     def getXMLattributes(self):
    162         return [XMLattribute("name", self.name),\
    163                  XMLattribute("cdbase",self.cd.base),\
    164                  XMLattribute("cd",self.cd.name)]
    165     def setXMLattributes(self):
     161    def getXMLAttributes(self):
     162        return [XMLAttribute("name", self.name),\
     163                 XMLAttribute("cdbase",self.cd.base),\
     164                 XMLAttribute("cd",self.cd.name)]
     165    def setXMLAttributes(self):
    166166        raise UnsupportedOperationError
    167167class SimpleValue(OMObjectBase):
     
    204204        return "OMfloat("+repr(self.value)+")"
    205205    XMLtag="OMF"
    206     def getXMLattributes(self):
    207         return [XMLattribute("dec",str(self.value))]
     206    def getXMLAttributes(self):
     207        return [XMLAttribute("dec",str(self.value))]
    208208class OMRef(OMObjectBase):
    209209    def __init__(self, ref):
     
    233233    firstArg=OMbinding(lambdasym,[OMVar("x"), OMVar("y")], OMVar("x"))
    234234    #print context.evaluate(firstArg)
    235     application=OMapplication(firstArg, [x,y])
    236     print context.evaluate(application)
    237     application=OMapplication(firstArg,[y,x])
     235    application=OMApply(firstArg, [x,y])
     236    print context.evaluate(application)
     237    application=OMApply(firstArg,[y,x])
    238238    print context.evaluate(application)
    239239    import arith1
    240240    context.addCDImplementation(arith1.implementation)
    241241    #print type(context.lookupImplementation(arith1.plussym))
    242     #application=OMapplication(arith1.plussym,[x])
    243     #application=OMapplication(arith1.plussym,[x,x])
    244     application=OMapplication(OMSymbol("plus",arith1.content),[x,x])
     242    #application=OMApply(arith1.plussym,[x])
     243    #application=OMApply(arith1.plussym,[x,x])
     244    application=OMApply(OMSymbol("plus",arith1.content),[x,x])
    245245   
    246246    print context.evaluate(application)
    247     application=OMapplication(OMSymbol("plus",arith1.content),[x,x,x])
     247    application=OMApply(OMSymbol("plus",arith1.content),[x,x,x])
    248248   
    249249    print context.evaluate(application)
  • modules/openmathserver/omxmlreader.py

    r1667822 r01cd17f  
    5151            name=node.getAttribute("name") #node.attributes["name"]
    5252            #print dir(name)
    53             erg= OMvar(name)
     53            erg= OMVar(name)
    5454        if (node.nodeName=="OMS"):
    5555            if node.hasAttribute("cdbase"):
     
    6767            else:
    6868                cd=OMcd(cdname,cdbase)
    69             erg=OMsymbol(name,cd)
     69            erg=OMSymbol(name,cd)
    7070        if (node.nodeName=="OMA"):
    7171            children=[self.buildFromNode(c) for c in node.childNodes]
     
    8282        if (node.nodeName=="OMR"):
    8383            if node.hasAttribute("xref"):
    84                 erg=OMref(node.getAttribute("xref"))
     84                erg=OMRef(node.getAttribute("xref"))
    8585                self.refs.append(erg)
    8686            else:
  • modules/openmathserver/xmlencodetest.py

    r1667822 r01cd17f  
    88print i.XMLencode(context)
    99print context.XMLEncodeObject(i)
    10 v=OMvar("x")
     10v=OMVar("x")
    1111print v.XMLencode(context)
    1212x=v
    13 y=OMvar("y")
    14 a=OMapplication(OMsymbol("plus",arith1.content),[x,y,i])
     13y=OMVar("y")
     14a=OMapplication(OMSymbol("plus",arith1.content),[x,y,i])
    1515print a.XMLencode(context)
    1616print context.XMLEncodeObject(context.evaluate(a))
    17 a1=OMapplication(OMsymbol("plus",arith1.content),[OMint(1),OMint(2)])
    18 a2=OMapplication(OMsymbol("plus",arith1.content),[a1,OMint(2)])
    19 a3=OMapplication(OMsymbol("plus",arith1.content),[a2,x])
     17a1=OMapplication(OMSymbol("plus",arith1.content),[OMint(1),OMint(2)])
     18a2=OMapplication(OMSymbol("plus",arith1.content),[a1,OMint(2)])
     19a3=OMapplication(OMSymbol("plus",arith1.content),[a2,x])
    2020context.addCDImplementation(arith1.implementation)
    2121print "a3", context.XMLEncodeObject(context.evaluate(a3))
Note: See TracChangeset for help on using the changeset viewer.