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


git-svn-id: file:///usr/local/Singular/svn/trunk@8371 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.