diff --git a/docs/SConscript b/docs/SConscript index c32d9519f..14c38b0a0 100644 --- a/docs/SConscript +++ b/docs/SConscript @@ -77,5 +77,5 @@ if GetOption('enable_sphinx'): doc_env.AlwaysBuild(doc_env.Alias('docs', ['doxygen', 'sphinx'])) for manpage in doc_env.GlobFiles('#docs/sphinx/manuals/*.rst'): - doc_env.AddDistFile(GetOption('mandir'), '#docs/man/%s.1' % - manpage.srcnode().name.replace('.rst', '').replace('_', '-')) + doc_env.AddDistFile(GetOption('mandir'), '#docs/man/{}.1'.format( + manpage.srcnode().name.replace('.rst', '').replace('_', '-'))) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 36eaeb030..bd313bcb0 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -9,8 +9,8 @@ def get_version(): proc = subprocess.Popen( [sys.executable, - '%s/../../scripts/scons_helpers/parse-version.py' % - os.path.dirname(os.path.realpath(__file__))], + os.path.dirname(os.path.realpath(__file__)) + + '/../../scripts/scons_helpers/parse-version.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return tuple(proc.stdout.read().decode().strip().split('.')) @@ -32,13 +32,13 @@ def get_version(): master_doc = 'index' project = u'Roc Toolkit' -copyright = u'%s, Roc Streaming authors' % datetime.datetime.now().year +copyright = u'{}, Roc Streaming authors'.format(datetime.datetime.now().year) author = u'Roc Streaming authors' version_tuple = get_version() -version = 'Roc Toolkit %s' % '.'.join(version_tuple[:2]) -release = '%s' % '.'.join(version_tuple) +version = 'Roc Toolkit {}'.format('.'.join(version_tuple[:2])) +release = '.'.join(version_tuple) today_fmt = '%Y' @@ -55,7 +55,7 @@ def get_version(): # -- Options for HTML output ---------------------------------------------- -html_title = '%s %s' % (project, release) +html_title = '{} {}'.format(project, release) html_theme = 'nature' diff --git a/scripts/help2rst.py b/scripts/help2rst.py index 7551b8948..e71464c2e 100755 --- a/scripts/help2rst.py +++ b/scripts/help2rst.py @@ -38,7 +38,7 @@ def format_options(inp): col2.append(m.group(3)) for c1, c2 in zip(col1, col2): - print(('%-'+str(maxlen+2)+'s%s') % (c1, c2)) + print(('{:<' + str(maxlen + 2) + '}{}').format(c1, c2)) format_options( filter_options( diff --git a/scripts/scons_helpers/clangdb.py b/scripts/scons_helpers/clangdb.py index 3acc31f8a..0cc07255d 100644 --- a/scripts/scons_helpers/clangdb.py +++ b/scripts/scons_helpers/clangdb.py @@ -50,7 +50,7 @@ def funlock(fp): db_path = os.path.join(build_dir, "compile_commands.json") cmd = { - "command": "%s %s" % (compiler, ' '.join(compiler_args)), + "command": "{} {}".format(compiler, ' '.join(compiler_args)), "directory": root_dir, "file": source_file, } @@ -81,7 +81,7 @@ def funlock(fp): funlock(fp) except: e = sys.exc_info()[1] - print("error: unable to write clangdb to %s" % db_path, file=sys.stderr) + print("error: unable to write clangdb to " + db_path, file=sys.stderr) print(str(e), file=sys.stderr) cmd = shlex.split(compiler) + compiler_args diff --git a/scripts/scons_helpers/format-header.py b/scripts/scons_helpers/format-header.py index 1c5814da0..631fc5f95 100644 --- a/scripts/scons_helpers/format-header.py +++ b/scripts/scons_helpers/format-header.py @@ -1,20 +1,21 @@ +import datetime +import fnmatch import os import re +import shutil import sys -import fnmatch import tempfile -import shutil -import datetime - -copyright_str = ''' -/* - * Copyright (c) %s Roc Streaming authors - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -''' % datetime.datetime.now().year +import textwrap + +copyright_str = textwrap.dedent(''' + /* + * Copyright (c) {} Roc Streaming authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +''').format(datetime.datetime.now().year) def is_header(path): return re.search('\.h$', path) @@ -51,12 +52,12 @@ def make_guard(path): def make_doxygen_path(path): path = '/'.join(path.split(os.sep)) path = re.sub('^\.?/', '', path) - return '@file %s' % path + return '@file ' + path def make_doxygen_brief(text): if not text.endswith('.'): text += '.' - return '@brief %s' % text + return '@brief ' + text def format_file(output, path): def fprint(s): @@ -140,7 +141,7 @@ def fprint(s): continue if re.match(r'^\s*//!\s*@file', line): - fprint('//! %s' % make_doxygen_path(path)) + fprint('//! {}'.format(make_doxygen_path(path))) else: fprint(line) @@ -152,8 +153,8 @@ def fprint(s): else: if not has_doxygen: if is_header(path): - fprint('//! %s' % make_doxygen_path(path)) - fprint('//! %s' % make_doxygen_brief(brief)) + fprint('//! {}'.format(make_doxygen_path(path))) + fprint('//! {}'.format(make_doxygen_brief(brief))) section = 'guard' else: section = 'body' @@ -165,12 +166,12 @@ def fprint(s): m = re.match(r'#\s*(ifndef|define)', line) if m: has_guard = True - fprint('#%s %s' % (m.group(1), make_guard(path))) + fprint('#{} {}'.format(m.group(1), make_guard(path))) continue else: if not has_guard: - fprint('#ifndef %s' % make_guard(path)) - fprint('#define %s' % make_guard(path)) + fprint('#ifndef {}'.format_file(make_guard(path))) + fprint('#define {}'.format_file(make_guard(path))) fprint('') section = 'body' @@ -182,7 +183,7 @@ def fprint(s): if is_header(path): fprint('') - fprint('#endif // %s' % make_guard(path)) + fprint('#endif // {}'.format(make_guard(path))) def walk_dir(directory, patterns): for root, dirs, files in os.walk(directory): diff --git a/scripts/scons_helpers/parse-version.py b/scripts/scons_helpers/parse-version.py index 582356ea3..b9e50330a 100644 --- a/scripts/scons_helpers/parse-version.py +++ b/scripts/scons_helpers/parse-version.py @@ -1,4 +1,5 @@ from __future__ import print_function + import os import os.path import re diff --git a/scripts/scons_helpers/timeout-run.py b/scripts/scons_helpers/timeout-run.py index 14abde87a..ad62d05cd 100644 --- a/scripts/scons_helpers/timeout-run.py +++ b/scripts/scons_helpers/timeout-run.py @@ -17,7 +17,7 @@ proc = subprocess.Popen(cmd) def trap(): - print("timeout of %ss expired, aborting" % timeout, file=sys.stderr) + print("timeout of {}s expired, aborting".format(timeout), file=sys.stderr) try: proc.terminate() except: