diff options
| author | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-04 21:03:22 +0100 |
|---|---|---|
| committer | Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io> | 2021-01-06 14:51:48 +0100 |
| commit | d9f344fcef6bec04a787f9ea9f4ea94f15eaa26c (patch) | |
| tree | 212261cffc6086e77a9731f3e23e8d12e6715b5e /sources/pyside6/doc/qtattributionsscannertorst.py | |
| parent | b6d1b76b46d7b756f7cb01361037e1cb5efc990a (diff) | |
sources: migration from format() to f-strings
This should be the last patch related the usage of f-strings
from the 'sources' directory.
Pick-to: 6.0
Change-Id: I0288d720dc4930dee088ca3396a66d1b3ba18f76
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/doc/qtattributionsscannertorst.py')
| -rw-r--r-- | sources/pyside6/doc/qtattributionsscannertorst.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sources/pyside6/doc/qtattributionsscannertorst.py b/sources/pyside6/doc/qtattributionsscannertorst.py index ff966b4cf..59f11ca9c 100644 --- a/sources/pyside6/doc/qtattributionsscannertorst.py +++ b/sources/pyside6/doc/qtattributionsscannertorst.py @@ -46,7 +46,7 @@ import os, json, subprocess, sys, warnings def indent(lines, indent): result = '' for l in lines: - result += "{}{}\n".format(indent, l) + result = f"{result}{indent}{l}\n" return result rstHeader="""Licenses Used in Qt for Python @@ -76,13 +76,13 @@ code licensed under third-party opensource licenses: """ def rstHeadline(title): - return '{}\n{}\n'.format(title, '-' * len(title)) + return f"{title}\n{'-' * len(title)}\n" def rstUrl(title, url): - return '`{} <{}>`_'.format(title, url) + return f"`{title} <{url}>`_" def rstLiteralBlock(lines): - return '::\n\n' + indent(lines, ' ') + '\n\n' + return f"::\n\n{indent(lines, ' ')}\n\n" def rstLiteralBlockFromText(text): return rstLiteralBlock(text.strip().split('\n')) @@ -94,21 +94,19 @@ def readFile(fileName): def runScanner(directory, targetFileName): # qtattributionsscanner recursively searches for qt_attribution.json files # and outputs them in JSON with the paths of the 'LicenseFile' made absolute - command = 'qtattributionsscanner --output-format json {}'.format(directory) + command = f'qtattributionsscanner --output-format json {directory}' jsonS = subprocess.check_output(command, shell=True) if not jsonS: - raise RuntimeError('{} failed to produce output.'.format(command)) + raise RuntimeError(f'{command} failed to produce output.') with open(targetFileName, 'w') as targetFile: targetFile.write(rstHeader) for entry in json.loads(jsonS.decode('utf-8')): - content = '{}\n{}\n{}\n\n'.format(rstHeadline(entry['Name']), - entry['Description'], entry['QtUsage']) + content = f"{entry['Name']}\n{entry['Description']}\n{entry['QtUsage']}\n\n" url = entry['Homepage'] version = entry['Version'] if url and version: - content += '{}, upstream version: {}\n\n'.format( - rstUrl('Project Homepage', url), version) + content = f"{content}{rstUrl('Project Homepage', url)}, upstream version: {version}\n\n" copyright = entry['Copyright'] if copyright: content += rstLiteralBlockFromText(copyright) @@ -118,8 +116,7 @@ def runScanner(directory, targetFileName): if os.path.isfile(licenseFile): content += rstLiteralBlock(readFile(licenseFile)) else: - warnings.warn('"{}" is not a file'.format(licenseFile), - RuntimeWarning) + warnings.warn(f'"{licenseFile}" is not a file', RuntimeWarning) targetFile.write(content) if len(sys.argv) < 3: |
