Changeset 3781a2 in git
- Timestamp:
- Jun 24, 2005, 3:49:43 PM (18 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- 77f48383612238705c6d4aced9da57ed67fbb727
- Parents:
- 936ad6e7b43877925b9627e6c3c2fed178961312
- Location:
- modules/openmathserver
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/openmathserver/cd.py
r936ad6 r3781a2 2 2 from omexceptions import * 3 3 class OMCD(object): 4 def __init__(self, name, base="http://www.openmath.org/cd"):5 self.name =name6 self.base =base4 def __init__(self, name, base="http://www.openmath.org/cd"): 5 self.name = name 6 self.base = base 7 7 def __eq__(self, other): 8 8 try: 9 return (self.name ==other.name) and (self.base==other.base)9 return (self.name == other.name) and (self.base == other.base) 10 10 except: 11 11 return False … … 15 15 class OMCDImplementation(object): 16 16 def __init__(self,cd): 17 self.cd =cd18 self.implementations ={}17 self.cd = cd 18 self.implementations = {} 19 19 def __getitem__(self, name): 20 20 return self.implementations[name] 21 21 def __setitem__(self,name,value): 22 self.implementations[name] =value22 self.implementations[name] = value 23 23 def implement(self,symbolname, func): 24 24 symbol=OMSymbol(symbolname,self.cd) 25 impl =ImplementedOMSymbol(symbol,func)25 impl = ImplementedOMSymbol(symbol,func) 26 26 self[symbol]=impl 27 27 … … 31 31 def __init__(self,symbol, func): 32 32 super(ImplementedOMSymbol,self).__init__(symbol.name, symbol.cd) 33 self.implementation =func33 self.implementation = func 34 34 def __str__(self): 35 35 return "ImplementedOMS("+self.name+", " + self.cd.name +")" -
modules/openmathserver/objects.py
r936ad6 r3781a2 1 from omexceptions import * 2 from exceptions import * 1 """Implementation of openmath basic objects""" 2 from omexceptions import UnsupportedOperationError 3 from omexceptions import OutOfScopeError, EvaluationFailedError 4 from exceptions import NotImplementedError 3 5 from copy import copy 4 6 import base64 … … 194 196 195 197 class OMint(SimpleValue): 196 def __init__(self, value):197 if not isinstance(value, int):198 def __init__(self, value): 199 if not isinstance(value, int): 198 200 value = self.parse(value) 199 super(OMint, self).__init__(value)200 def parse(self, value):201 super(OMint, self).__init__(value) 202 def parse(self, value): 201 203 """FIXME: Not fully standard compliant, 202 204 -> hex encodings""" 203 return int(value, 10)205 return int(value, 10) 204 206 def __str__(self): 205 207 return "OMint("+repr(self.value)+")" … … 208 210 def setBody(self, value): 209 211 raise UnsupportedOperationError 210 XMLtag ="OMI"212 XMLtag = "OMI" 211 213 class OMfloat(SimpleValue): 212 214 def __init__(self, value): … … 220 222 XMLtag = "OMF" 221 223 def getXMLAttributes(self): 222 return [XMLAttribute("dec" ,str(self.value))]224 return [XMLAttribute("dec" ,str(self.value))] 223 225 class OMString(SimpleValue): 224 226 def __init__(self,value): … … 230 232 return self.value 231 233 class OMByteArray(SimpleValue): 232 def __init__(self, value):234 def __init__(self, value): 233 235 super(OMByteArray,self).__init__(value) 234 236 def __str__(self): … … 236 238 def parse(self, value): 237 239 return value 238 XMLtag ="OMB"240 XMLtag = "OMB" 239 241 def getBody(self): 240 242 return base64.encodestring(self.value) … … 276 278 XMLtag = "OMATTR" 277 279 if __name__ == '__main__': 278 from context import *279 280 from binding import *280 from context import Context 281 282 from binding import OMBinding, lambdasym 281 283 282 284 context = Context()
Note: See TracChangeset
for help on using the changeset viewer.