Ejemplo n.º 1
0
 def __new__(metacls, clsname, bases, dic):
     cls = PLOptionDict.__metaclass__.__new__(metacls, clsname, bases, dic)
     PyPLearnObject = cls
     if clsname!="PyPLearnObject":
         PyPLearnObject = globals()['PyPLearnObject']
     actualContext(PyPLearnObject).pyplearn_object_subclasses[clsname] = cls
     return cls
Ejemplo n.º 2
0
 def __new__(metacls, clsname, bases, dic):
     cls = PLOptionDict.__metaclass__.__new__(metacls, clsname, bases,
                                              dic)
     PyPLearnObject = cls
     if clsname != "PyPLearnObject":
         PyPLearnObject = globals()['PyPLearnObject']
     actualContext(
         PyPLearnObject).pyplearn_object_subclasses[clsname] = cls
     return cls
Ejemplo n.º 3
0
    def instances( cls ):
        """Returns a list of this I{cls} instances.

        Notes that if the class has subclass, instances of the subclasses
        will be returned too.
        """
        ilist = []
        for instance in actualContext(PyPLearnObject).pyplearn_object_instances:
            if isinstance( instance, cls ):
                ilist.append(instance)
        return ilist
Ejemplo n.º 4
0
    def instances(cls):
        """Returns a list of this I{cls} instances.

        Notes that if the class has subclass, instances of the subclasses
        will be returned too.
        """
        ilist = []
        for instance in actualContext(
                PyPLearnObject).pyplearn_object_instances:
            if isinstance(instance, cls):
                ilist.append(instance)
        return ilist
Ejemplo n.º 5
0
 def getCurrentPyReprMap():
     context = actualContext(_PyReprMap)
     assert hasattr(context, 'pyrepr_map')
     return context.pyrepr_map
Ejemplo n.º 6
0
 def getCurrentPRefMap():
     context = actualContext(PRefMap)
     assert hasattr(context, 'pref_map')
     return context.pref_map
Ejemplo n.º 7
0
 def __setstate__(self, state):
     """For the deepcopy mechanism."""
     self.__dict__.update(state)
     instances = actualContext(PyPLearnObject).pyplearn_object_instances 
     instances.append( self )
     self.__serial_number = len(instances)
Ejemplo n.º 8
0
 def __init__(self, **overrides):
     super(PyPLearnObject, self).__init__(**overrides)
     instances = actualContext(PyPLearnObject).pyplearn_object_instances 
     instances.append( self )
     self.__serial_number = len(instances)
Ejemplo n.º 9
0
 def __setstate__(self, state):
     """For the deepcopy mechanism."""
     self.__dict__.update(state)
     instances = actualContext(PyPLearnObject).pyplearn_object_instances
     instances.append(self)
     self.__serial_number = len(instances)
Ejemplo n.º 10
0
 def __init__(self, **overrides):
     super(PyPLearnObject, self).__init__(**overrides)
     instances = actualContext(PyPLearnObject).pyplearn_object_instances
     instances.append(self)
     self.__serial_number = len(instances)