Beispiel #1
0
    def __init__(self,
                 default,
                 ro=False,
                 index=None,
                 value=None,
                 name=None,
                 doc=None,
                 **kwargs):
        """Specify a Parameter with a default value and arbitrary
        number of additional attributes.

        Parameters
        ----------
        name : str
          Name of the parameter under which it should be available in its
          respective collection.
        doc : str
          Documentation about the purpose of this parameter.
        index : int or None
          Index of parameter among the others.  Determines order of listing
          in help.  If None, order of instantiation determines the index.
        ro : bool
          Either value which will be assigned in the constructor is read-only and
          cannot be changed
        value
          Actual value of the parameter to be assigned
        """
        # XXX probably is too generic...
        # and potentially dangerous...
        # let's at least keep track of what is passed
        self._additional_props = []
        for k, v in kwargs.iteritems():
            self.__setattr__(k, v)
            self._additional_props.append(k)

        self.__default = default
        self._ro = ro

        # needs to come after kwargs processing, since some debug statements
        # rely on working repr()
        # value is not passed since we need to invoke _set with init=True
        # below
        IndexedCollectable.__init__(
            self,
            index=index,  # value=value,
            name=name,
            doc=doc)
        self._isset = False
        if value is None:
            self._set(self.__default, init=True)
        else:
            self._set(value, init=True)

        if __debug__:
            if kwargs.has_key('val'):
                raise ValueError, "'val' property name is illegal."
Beispiel #2
0
    def __init__(self, default, ro=False,  index=None,  value=None,
                 name=None, doc=None, **kwargs):
        """Specify a Parameter with a default value and arbitrary
        number of additional attributes.

        Parameters
        ----------
        name : str
          Name of the parameter under which it should be available in its
          respective collection.
        doc : str
          Documentation about the purpose of this parameter.
        index : int or None
          Index of parameter among the others.  Determines order of listing
          in help.  If None, order of instantiation determines the index.
        ro : bool
          Either value which will be assigned in the constructor is read-only and
          cannot be changed
        value
          Actual value of the parameter to be assigned
        """
        # XXX probably is too generic...
        # and potentially dangerous...
        # let's at least keep track of what is passed
        self._additional_props = []
        for k, v in kwargs.iteritems():
            self.__setattr__(k, v)
            self._additional_props.append(k)

        self.__default = default
        self._ro = ro

        # needs to come after kwargs processing, since some debug statements
        # rely on working repr()
        # value is not passed since we need to invoke _set with init=True
        # below
        IndexedCollectable.__init__(self, index=index, # value=value,
                                    name=name, doc=doc)
        self._isset = False
        if value is None:
            self._set(self.__default, init=True)
        else:
            self._set(value, init=True)

        if __debug__:
            if kwargs.has_key('val'):
                raise ValueError, "'val' property name is illegal."
Beispiel #3
0
 def __str__(self):
     res = IndexedCollectable.__str__(self)
     # it is enabled but no value is assigned yet
     res += '=%s' % (self.value, )
     return res
Beispiel #4
0
 def __reduce__(self):
     icr = IndexedCollectable.__reduce__(self)
     res = (self.__class__, (self.__default, self._ro) + icr[1], icr[2])
     #if __debug__ and 'COL_RED' in debug.active:
     #    debug('COL_RED', 'Returning %s for %s' % (res, self))
     return res
Beispiel #5
0
 def __str__(self):
     res = IndexedCollectable.__str__(self)
     # it is enabled but no value is assigned yet
     res += '=%s' % (self.value,)
     return res
Beispiel #6
0
 def __reduce__(self):
     icr = IndexedCollectable.__reduce__(self)
     res = (icr[0], (self.__default, self._ro) + icr[1], icr[2])
     #if __debug__ and 'COL_RED' in debug.active:
     #    debug('COL_RED', 'Returning %s for %s' % (res, self))
     return res