From: Zac Medico Date: Thu, 3 Jul 2008 12:04:45 +0000 (-0000) Subject: Split out a _create_prefetcher() method from _add_prefetchers(). X-Git-Tag: v2.2_rc2~224 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=216e0d1372c85916dd17e1f472bbae2a384b9c72;p=portage.git Split out a _create_prefetcher() method from _add_prefetchers(). svn path=/main/trunk/; revision=10913 --- diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 09aff941a..bff2e3a04 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -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