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 82a5440fd104e57bf2fcf17855b7c17fe694613c 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/buildstream/source.py b/src/buildstream/source.py index 0278c5a32..6360653a8 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, + 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 @@ -717,6 +725,9 @@ class Source(Plugin): # Ensure that the download URL is also marked self.mark_download_url(url, primary=primary) + if suffix: + url = url + suffix + # Alias overriding can happen explicitly (by command-line) or # implicitly (the Source being constructed with an __alias_override). if alias_override or self.__alias_override:
