/[escript]/trunk/escript/py_src/modelframe.py
ViewVC logotype

Diff of /trunk/escript/py_src/modelframe.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 949 by gross, Tue Jan 30 08:57:37 2007 UTC revision 950 by gross, Tue Feb 6 07:01:11 2007 UTC
# Line 476  class ParameterSet(LinkableObject): Line 476  class ParameterSet(LinkableObject):
476          if self.isParameter(name):          if self.isParameter(name):
477              self.parameters.remove(name)              self.parameters.remove(name)
478              self.trace("parameter %s has been removed."%name)              self.trace("parameter %s has been removed."%name)
479    
480        def checkLinkTargets(self, models, hash):
481            """
482            returns a list of (paramter set,parameter, target model ) if the the parameter of model
483            is linking to the target_model which is not in list of models.
484            """
485            out=[]
486            for name, value in self:
487                if isinstance(value, Link):
488                   print str(self), name, value
489                   m=value.getTarget()
490                   if (m,name) in hash:
491                     raise RuntimeError("recursive link: %s"%(hash+[ (m,name) ]))
492                   if isinstance(m, Model) and not m in models: out.append( (self,name,m) )
493                   if isinstance(m, ParameterSet):
494                      try:
495                         out+=m.checkLinkTargets(models, hash+[ (self,name) ] )
496                      except RuntimeError, e:
497                         print str(e), str(self), name
498                         raise e
499            return list(set(out))
500            
501      def __iter__(self):      def __iter__(self):
502          """          """
# Line 909  class Simulation(Model): Line 930  class Simulation(Model):
930                 out.append(m)                 out.append(m)
931          return list(set(out))          return list(set(out))
932    
933      def checkModelLinks(self, models):      def checkModels(self, models, hash):
934          """          """
935          returns a list of (model,parameter, target model ) if the the parameter of model          returns a list of (model,parameter, target model ) if the the parameter of model
936          is linking to the target_model which is not in list of models.          is linking to the target_model which is not in list of models.
937          """          """
938          out=[]          out=self.checkLinkTargets(models, hash)
939          for m in self.iterModels():          for m in self.iterModels():
940              if isinstance(m, Simulation):              if isinstance(m, Simulation):
941                 out+=[ (m,) + f for f in  m.checkModelLinks(models) ]                   out+=[ (m,) + f for f in  m.checkModels(models, hash) ]
942              else:              else:
943                for p in m:                   out+=[ (m,) + f for f in  m.checkLinkTargets(models, hash) ]
                  if isinstance(p[1], Link):  
                     l_m=p[1].getTarget()  
                     if isinstance(l_m, Model) and not l_m in models: out.append( (m,p[0],l_m) )  
944          return out          return out
945    
946            
# Line 1053  class Simulation(Model): Line 1071  class Simulation(Model):
1071          # check the completness of the models:          # check the completness of the models:
1072          # first a list of all the models involved in the simulation including subsimulations:          # first a list of all the models involved in the simulation including subsimulations:
1073          #          #
1074          missing=self.checkModelLinks(self.getAllModels())          missing=self.checkModels(self.getAllModels(), [])
1075          if len(missing)>0:          if len(missing)>0:
1076              msg=""              msg=""
1077              for l in missing:              for l in missing:

Legend:
Removed from v.949  
changed lines
  Added in v.950

  ViewVC Help
Powered by ViewVC 1.1.26