This is an automated email from the ASF dual-hosted git repository. not-in-ldap pushed a commit to branch jonathan/mirror-client-sourcedownloader in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 3c452cd7cb880348c073ec62a61bbf22b3f0237c 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 9054ae2..dde167d 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -132,10 +132,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 ec38ae8..af5411a 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -299,7 +299,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. @@ -310,7 +310,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
