Split out a _create_prefetcher() method from _add_prefetchers().
authorZac Medico <zmedico@gentoo.org>
Thu, 3 Jul 2008 12:04:45 +0000 (12:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 3 Jul 2008 12:04:45 +0000 (12:04 -0000)
svn path=/main/trunk/; revision=10913

pym/_emerge/__init__.py

index 09aff941aa4b6581f7c976a6208f87b1c093b2f5..bff2e3a04e0be08a78f021fa8918d3b3d230a224 100644 (file)
@@ -7168,21 +7168,33 @@ class Scheduler(object):
                        getbinpkg = "--getbinpkg" in self.myopts
 
                        for pkg in self._mergelist:
-                               if not isinstance(pkg, Package):
-                                       continue
-                               if pkg.type_name == "ebuild":
-                                       self._add_task(EbuildFetcherAsync(
-                                               logfile=self._fetch_log,
-                                               pkg=pkg, register=self._register,
-                                               unregister=self._unregister))
-                               elif pkg.type_name == "binary" and getbinpkg and \
-                                       pkg.root_config.trees["bintree"].isremote(pkg.cpv):
-                                       prefetcher = BinpkgFetcherAsync(
-                                               logfile=self._fetch_log,
-                                               pkg=pkg, register=self._register,
-                                               unregister=self._unregister)
-                                       prefetchers[pkg] = prefetcher
+                               prefetcher = self._create_prefetcher(pkg)
+                               if prefetcher is not None:
                                        self._add_task(prefetcher)
+                                       prefetchers[pkg] = prefetcher
+
+       def _create_prefetcher(self, pkg):
+               """
+               @return: a prefetcher, or None if not applicable
+               """
+               prefetcher = None
+
+               if not isinstance(pkg, Package):
+                       pass
+
+               elif pkg.type_name == "ebuild":
+
+                       prefetcher = EbuildFetcherAsync(logfile=self._fetch_log, pkg=pkg,
+                               register=self._register, unregister=self._unregister)
+
+               elif pkg.type_name == "binary" and \
+                       "--getbinpkg" in self.myopts and \
+                       pkg.root_config.trees["bintree"].isremote(pkg.cpv):
+
+                       prefetcher = BinpkgFetcherAsync(logfile=self._fetch_log,
+                               pkg=pkg, register=self._register, unregister=self._unregister)
+
+               return prefetcher
 
        def _show_failed_fetches(self):
                failed_fetches = self._failed_fetches