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

def zeroinstall::injector::policy::Policy::compare (   self,
  interface,
  b,
  a 
)

Compare a and b to see which would be chosen first.
@param interface: The interface we are trying to resolve, which may
not be the interface of a or b if they are from feeds.
@rtype: int

Definition at line 275 of file policy.py.

00275                                         :
            """Compare a and b to see which would be chosen first.
            @param interface: The interface we are trying to resolve, which may
            not be the interface of a or b if they are from feeds.
            @rtype: int"""
            restrictions = self.restrictions.get(interface, [])

            a_stab = a.get_stability()
            b_stab = b.get_stability()

            # Usable ones come first
            r = cmp(self.is_unusable(b, restrictions), self.is_unusable(a, restrictions))
            if r: return r

            # Preferred versions come first
            r = cmp(a_stab == preferred, b_stab == preferred)
            if r: return r

            if self.network_use != network_full:
                  r = cmp(self.get_cached(a), self.get_cached(b))
                  if r: return r

            # Stability
            stab_policy = interface.stability_policy
            if not stab_policy:
                  if self.help_with_testing: stab_policy = testing
                  else: stab_policy = stable

            if a_stab >= stab_policy: a_stab = preferred
            if b_stab >= stab_policy: b_stab = preferred

            r = cmp(a_stab, b_stab)
            if r: return r
            
            # Newer versions come before older ones
            r = cmp(a.version, b.version)
            if r: return r

            # Get best OS
            r = cmp(arch.os_ranks.get(a.os, None),
                  arch.os_ranks.get(b.os, None))
            if r: return r

            # Get best machine
            r = cmp(arch.machine_ranks.get(a.machine, None),
                  arch.machine_ranks.get(b.machine, None))
            if r: return r

            # Slightly prefer cached versions
            if self.network_use == network_full:
                  r = cmp(self.get_cached(a), self.get_cached(b))
                  if r: return r

            return cmp(a.id, b.id)
      
      def usable_feeds(self, iface):


Generated by  Doxygen 1.6.0   Back to index