This is an automated email from the ASF dual-hosted git repository. akitouni pushed a commit to branch abderrahim/translate-url-suffix in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 79ba97362ee9c28242b184e267c72b5caa8c518d Author: Abderrahim Kitouni <[email protected]> AuthorDate: Thu Mar 14 06:46:25 2024 +0100 source: add suffix parameter to translate_url --- src/buildstream/source.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/buildstream/source.py b/src/buildstream/source.py index 0278c5a32..21a44f95d 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -696,7 +696,14 @@ class Source(Plugin): return self.__mirror_directory - def translate_url(self, url: str, *, alias_override: Optional[str] = None, primary: bool = True) -> str: + def translate_url( + self, + base_url: str, + *, + alias_override: Optional[str] = None, + primary: bool = True, + suffix: Optional[str] = None + ) -> str: """Translates the given url which may be specified with an alias into a fully qualified url. @@ -704,6 +711,7 @@ class Source(Plugin): url: A URL, which may be using an alias alias_override: Optionally, an URI to override the alias with. primary: Whether this is the primary URL for the source. + suffix: an optional suffix to append to the URL (*Since: 2.2*) Returns: The fully qualified URL, with aliases resolved @@ -715,7 +723,9 @@ class Source(Plugin): is not called. """ # Ensure that the download URL is also marked - self.mark_download_url(url, primary=primary) + self.mark_download_url(base_url, primary=primary) + + url = base_url + suffix # Alias overriding can happen explicitly (by command-line) or # implicitly (the Source being constructed with an __alias_override).
