예제 #1
0
파일: TCnumbers.py 프로젝트: ndawe/pyAMI
 def __init__(self, choices, pname=None, **kw):
     Integer.__init__(self, pname, **kw)
     self.choices = choices
     t = type(choices)
     if t in _seqtypes:
         self.choices = tuple(choices)
     elif TypeCode.typechecks:
         raise TypeError(
             'Enumeration choices must be list or sequence, not ' + str(t))
     if TypeCode.typechecks:
         for c in self.choices:
             if type(c) not in _inttypes:
                 raise TypeError('Enumeration choice "' +
                         str(c) + '" is not an integer')
예제 #2
0
파일: TCnumbers.py 프로젝트: ndawe/pyAMI
 def parse(self, elt, ps):
     val = Integer.parse(self, elt, ps)
     if val not in self.choices:
         raise EvaluateException('Value "' + str(val) + \
                     '" not in enumeration list',
                 ps.Backtrace(elt))
     return val
예제 #3
0
파일: TCnumbers.py 프로젝트: ndawe/pyAMI
 def serialize(self, elt, sw, pyobj, name=None, orig=None, **kw):
     if pyobj not in self.choices:
         raise EvaluateException('Value not in int enumeration list',
                 ps.Backtrace(elt))
     Integer.serialize(self, elt, sw, pyobj, name=name, orig=orig, **kw)