diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-08-30 14:54:46 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-08-30 17:44:34 +0900 |
commit | fcc17c820d676b82dc2536c270bbfc3c28abfba1 (patch) | |
tree | b7539adb7f074c8c6328299bac5b690322a16034 | |
parent | 8aec11026c266d0f3dc1f04bf83c09c2e823d95d (diff) | |
download | buildstream-fcc17c820d676b82dc2536c270bbfc3c28abfba1.tar.gz |
source.py: Stylistic changes in Source.__do_fetch()
Added some comments to make the flow easier to follow, and
removed an annoying 'success' variabled in favor of a for / else
loop statement.
-rw-r--r-- | buildstream/source.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/buildstream/source.py b/buildstream/source.py index a9ae090a5..5e43da5ea 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -865,10 +865,12 @@ class Source(Plugin): def __do_fetch(self, **kwargs): project = self._get_project() source_fetchers = self.get_source_fetchers() + + # Use the source fetchers if they are provided + # if source_fetchers: for fetcher in source_fetchers: alias = fetcher._get_alias() - success = False for uri in project.get_alias_uris(alias, first_pass=self.__first_pass): try: fetcher.fetch(uri) @@ -877,10 +879,16 @@ class Source(Plugin): except BstError as e: last_error = e continue - success = True + + # No error, we're done with this fetcher break - if not success: + + else: + # No break occurred, raise the last detected error raise last_error + + # Default codepath is to reinstantiate the Source + # else: alias = self._get_alias() if self.__first_pass: @@ -904,7 +912,11 @@ class Source(Plugin): except BstError as e: last_error = e continue + + # No error, we're done here return + + # Re raise the last detected error raise last_error # Tries to call track for every mirror, stopping once it succeeds |