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

def zeroinstall::injector::policy::Policy::begin_icon_download (   self,
  interface,
  force = False 
)

Start downloading an icon for this interface. On success, add it to the
icon cache. If the interface has no icon, do nothing.

Definition at line 492 of file policy.py.

00492                                                              :
            """Start downloading an icon for this interface. On success, add it to the
            icon cache. If the interface has no icon, do nothing."""
            debug("begin_icon_download %s (force = %d)", interface, force)

            # Find a suitable icon to download
            for icon in interface.get_metadata(XMLNS_IFACE, 'icon'):
                  type = icon.getAttribute('type')
                  if type != 'image/png':
                        debug('Skipping non-PNG icon')
                        continue
                  source = icon.getAttribute('href')
                  if source:
                        break
                  warn('Missing "href" attribute on <icon> in %s', interface)
            else:
                  info('No PNG icons found in %s', interface)
                  return

            dl = self.handler.get_download(source, force = force)
            if dl.on_success:
                  # Possibly we should handle this better, but it's unlikely anyone will need
                  # to use an icon as an interface or implementation as well, and some of the code
                  # may assume it's OK keep asking for the same icon to be downloaded.
                  info("Already have a handler for %s; not adding another", source)
                  return
            dl.on_success.append(lambda stream: self.store_icon(interface, stream))

      def store_icon(self, interface, stream):


Generated by  Doxygen 1.6.0   Back to index