build_manifest.py: Use fstrings for string formatting

This commit is contained in:
Jordan Petridis 2018-10-23 16:34:19 +03:00
parent 095c93c62c
commit c457ca0570
No known key found for this signature in database
GPG key ID: 902CC06D159744F5

View file

@ -47,21 +47,23 @@ def find_repository_sha(module: str, branchname: str) -> Tuple[str, str]:
# print("No 'namespace' in: %s - ignoring?" % project, file=sys.stderr) # print("No 'namespace' in: %s - ignoring?" % project, file=sys.stderr)
continue continue
id = project['id']
if project['namespace']['name'] in useful_namespaces: if project['namespace']['name'] in useful_namespaces:
if project['namespace']['name'] == user_namespace: if project['namespace']['name'] == user_namespace:
# If we have a branch with same name, use it. # If we have a branch with same name, use it.
for branch in request('%s/repository/branches' % project['id']): for branch in request(f"{id}/repository/branches"):
if branch['name'] == branchname: if branch['name'] == branchname:
print("%s/%s" % (project['namespace']['name'], branchname)) name = project['namespace']['name']
print(f"{name}/{branchname}")
return 'user', branch['commit']['id'] return 'user', branch['commit']['id']
else: else:
for branch in request('%s/repository/branches"' % project['id']): for branch in request(f"{id}/repository/branches"):
if branch['name'] == branchname: if branch['name'] == branchname:
print("gstreamer/%s" % (branchname)) print(f"gstreamer/{branchname}")
return 'gstreamer', branch['commit']['id'] return 'gstreamer', branch['commit']['id']
branch, = request('%s/repository/branches?search=master' % project['id']) branch, = request(f"{id}/repository/branches?search=master")
print('gstreamer/master') print('gstreamer/master')
return 'gstreamer', branch.attributes['commit']['id'] return 'gstreamer', branch.attributes['commit']['id']
@ -83,14 +85,14 @@ if __name__ == "__main__":
project_template: str = ' <project name="%s" remote="%s" revision="%s" />\n' project_template: str = ' <project name="%s" remote="%s" revision="%s" />\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("Checking %s:" % module, end=' ') print(f"Checking {module}:", end=' ')
remote = "origin" remote = 'origin'
revision = None revision = None
if module == project_name: if module == project_name:
revision = os.environ['CI_COMMIT_SHA'] revision = os.environ['CI_COMMIT_SHA']
remote = "user" remote = 'user'
print("%s/%s" % (user_namespace, branchname)) print(f"{user_namespace}/{branchname}")
else: else:
remote, revision = find_repository_sha(module, branchname) remote, revision = find_repository_sha(module, branchname)