Logo Search packages:      
Sourcecode: zeroinstall-injector version File versions

def zeroinstall::injector::policy::Policy::recalculate (   self  ) 

Try to choose a set of implementations.
This may start downloading more interfaces, but will return immediately.
@postcondition: L{ready} indicates whether a possible set of implementations was chosen
@note: A policy may be ready before all feeds have been downloaded. As new feeds
arrive, the chosen versions may change.

Definition at line 203 of file policy.py.

00203                            :
            """Try to choose a set of implementations.
            This may start downloading more interfaces, but will return immediately.
            @postcondition: L{ready} indicates whether a possible set of implementations was chosen
            @note: A policy may be ready before all feeds have been downloaded. As new feeds
            arrive, the chosen versions may change.
            """

            self.restrictions = {}
            self.implementation = {}
            self.ready = True
            debug("Recalculate! root = %s", self.root)
            def process(dep):
                  iface = self.get_interface(dep.interface)
                  if iface in self.implementation:
                        debug("Interface requested twice; skipping second %s", iface)
                        if dep.restrictions:
                              warn("Interface requested twice; I've already chosen an implementation "
                                    "of '%s' but there are more restrictions! Ignoring the second set.", iface)
                        return
                  self.implementation[iface] = None   # Avoid cycles

                  assert iface not in self.restrictions
                  self.restrictions[iface] = dep.restrictions

                  impl = self._get_best_implementation(iface)
                  if impl:
                        debug("Will use implementation %s (version %s)", impl, impl.get_version())
                        self.implementation[iface] = impl
                        for d in impl.dependencies.values():
                              debug("Considering dependency %s", d)
                              process(d)
                  else:
                        debug("No implementation chould be chosen yet");
                        self.ready = False
            process(Dependency(self.root, restrictions = self.root_restrictions))
            for w in self.watchers: w()
      
      # Only to be called from recalculate, as it is quite slow.
      # Use the results stored in self.implementation instead.
      def _get_best_implementation(self, iface):


Generated by  Doxygen 1.6.0   Back to index