Exemplo n.º 1
0
    def _sort_screenshots_by_best_version(self, screenshot_list):
        """ take a screenshot result dict from screenshots.debian.org
            and sort it
        """
        from softwarecenter.utils import version_compare

        my_version = self.version
        # discard screenshots which are more recent than the available version
        for item in screenshot_list[:]:
            v = item["version"]
            if v and version_compare(my_version, v) < 0:
                screenshot_list.remove(item)
        # now sort from high to low
        return sorted(
            screenshot_list, cmp=lambda a, b: version_compare(a["version"] or "", b["version"] or ""), reverse=True
        )
Exemplo n.º 2
0
 def warning(self):
     # apturl minver matches
     if not self.pkg_state == PkgStates.INSTALLED:
         if self._app.request:
             minver_matches = re.findall(r'minver=[a-z,0-9,-,+,.,~]*',
                 self._app.request)
             if minver_matches and self.version:
                 minver = minver_matches[0][7:]
                 from softwarecenter.utils import version_compare
                 if version_compare(minver, self.version) > 0:
                     return _("Version %s or later not available.") % minver
     # can we enable a source
     if not self._pkg:
         source_to_enable = None
         if self.channelname and self._unavailable_channel():
             source_to_enable = self.channelname
         elif (self.component and
               self.component not in ("independent", "commercial")):
             source_to_enable = self.component
         if source_to_enable:
             sources = source_to_enable.split('&')
             sources_length = len(sources)
             if sources_length == 1:
                 warning = (_("Available from the \"%s\" source.") %
                     sources[0])
             elif sources_length > 1:
                 # Translators: the visible string is constructed
                 # concatenating the following 3 strings like this:
                 # Available from the following sources: %s, ... %s, %s.
                 warning = _("Available from the following sources: ")
                 # Cycle through all, but the last
                 for source in sources[:-1]:
                     warning += _("\"%s\", ") % source
                 warning += _("\"%s\".") % sources[sources_length - 1]
             return warning
Exemplo n.º 3
0
 def _sort_screenshots_by_best_version(self, screenshot_list):
     """ take a screenshot result dict from screenshots.debian.org
         and sort it
     """
     from softwarecenter.utils import version_compare
     my_version = self.version
     # discard screenshots which are more recent than the available version
     for item in screenshot_list[:]:
         v = item['version']
         if v and version_compare(my_version, v) < 0:
             screenshot_list.remove(item)
     # now sort from high to low
     return sorted(screenshot_list,
                   cmp=lambda a, b: version_compare(a["version"] or '', b[
                       "version"] or ''),
                   reverse=True)