build_manifest.py: Use .format instead %s for templates

This commit is contained in:
Jordan Petridis 2018-10-23 17:02:37 +03:00
parent c457ca0570
commit 6e77bfb893
No known key found for this signature in database
GPG key ID: 902CC06D159744F5

View file

@ -25,10 +25,10 @@ GSTREAMER_MODULES: List[str] = [
MANIFEST_TEMPLATE: str = """<?xml version="1.0" encoding="UTF-8"?> MANIFEST_TEMPLATE: str = """<?xml version="1.0" encoding="UTF-8"?>
<manifest> <manifest>
<remote fetch="%s" name="user"/> <remote fetch="{}" name="user"/>
<remote fetch="https://gitlab.freedesktop.org/gstreamer/" name="gstreamer"/> <remote fetch="https://gitlab.freedesktop.org/gstreamer/" name="gstreamer"/>
<remote fetch="git://anongit.freedesktop.org/gstreamer/" name="origin"/> <remote fetch="git://anongit.freedesktop.org/gstreamer/" name="origin"/>
%s {}
</manifest>""" </manifest>"""
@ -38,6 +38,7 @@ def request(path: str) -> Dict[str, str]:
return requests.get('https://gitlab.gnome.org/api/v4/' + path, headers=gitlab_header).json() return requests.get('https://gitlab.gnome.org/api/v4/' + path, headers=gitlab_header).json()
def find_repository_sha(module: str, branchname: str) -> Tuple[str, str]: def find_repository_sha(module: str, branchname: str) -> Tuple[str, str]:
for project in request('projects?search=' + module): for project in request('projects?search=' + module):
if project['name'] != module: if project['name'] != module:
@ -82,7 +83,7 @@ if __name__ == "__main__":
# Shouldn't be needed. # Shouldn't be needed.
remote: str = "git://anongit.freedesktop.org/gstreamer/" remote: str = "git://anongit.freedesktop.org/gstreamer/"
projects: str = '' projects: str = ''
project_template: str = ' <project name="%s" remote="%s" revision="%s" />\n' project_template: str = " <project name=\"{}\" remote=\"{}\" revision=\"{}\" />\n"
user_remote: str = os.path.dirname(os.environ['CI_PROJECT_URL']) user_remote: str = os.path.dirname(os.environ['CI_PROJECT_URL'])
for module in GSTREAMER_MODULES: for module in GSTREAMER_MODULES:
print(f"Checking {module}:", end=' ') print(f"Checking {module}:", end=' ')
@ -98,7 +99,7 @@ if __name__ == "__main__":
if not revision: if not revision:
revision = 'master' revision = 'master'
projects += project_template % (module, remote, revision) projects += project_template.format(module, remote, revision)
with open('manifest.xml', mode='w') as manifest: with open('manifest.xml', mode='w') as manifest:
print(MANIFEST_TEMPLATE % (user_remote, projects), file=manifest) print(MANIFEST_TEMPLATE.format(user_remote, projects), file=manifest)