This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch jonathan/mirror-client-sourcedownloader-tidy in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit d02bfe075c89fcc8a0e197888283a84193fecc55 Author: Jonathan Maw <[email protected]> AuthorDate: Fri Jun 22 16:51:14 2018 +0100 Allow translate_url to be overridden with a different alias in Project and Source --- buildstream/_project.py | 8 ++++++-- buildstream/source.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/buildstream/_project.py b/buildstream/_project.py index 110aeec..98be8fb 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -133,10 +133,14 @@ class Project(): # This method is provided for :class:`.Source` objects to resolve # fully qualified urls based on the shorthand which is allowed # to be specified in the YAML - def translate_url(self, url): + def translate_url(self, url, alias_override=None): if url and utils._ALIAS_SEPARATOR in url: url_alias, url_body = url.split(utils._ALIAS_SEPARATOR, 1) - alias_url = self._aliases.get(url_alias) + if alias_override: + alias_url = alias_override + else: + alias_url = self._aliases.get(url_alias) + if alias_url: url = alias_url + url_body diff --git a/buildstream/source.py b/buildstream/source.py index 470a407..ee0903d 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -300,7 +300,7 @@ class Source(Plugin): os.makedirs(directory, exist_ok=True) return directory - def translate_url(self, url): + def translate_url(self, url, alias_override=None): """Translates the given url which may be specified with an alias into a fully qualified url. @@ -311,7 +311,7 @@ class Source(Plugin): str: The fully qualified url, with aliases resolved """ project = self._get_project() - return project.translate_url(url) + return project.translate_url(url, alias_override) def get_project_directory(self): """Fetch the project base directory
