diff --git a/docs/changelog.py b/docs/changelog.py index fe2cad6..9a5ff74 100644 --- a/docs/changelog.py +++ b/docs/changelog.py @@ -54,7 +54,7 @@ A total of %d pull requests were merged for this release. def get_authors(revision_range): pat = '^.*\\t(.*)$' - lst_release, cur_release = [r.strip() for r in revision_range.split('..')] + lst_release, cur_release = (r.strip() for r in revision_range.split('..')) # authors, in current release and previous to current release. cur = set(re.findall(pat, this_repo.git.shortlog('-s', revision_range), @@ -94,7 +94,7 @@ def get_pull_requests(repo, revision_range): def main(token, revision_range): - lst_release, cur_release = [r.strip() for r in revision_range.split('..')] + lst_release, cur_release = (r.strip() for r in revision_range.split('..')) github = Github(token) github_repo = github.get_repo('saimn/sigal') diff --git a/sigal/__init__.py b/sigal/__init__.py index acad34a..107527c 100644 --- a/sigal/__init__.py +++ b/sigal/__init__.py @@ -170,14 +170,14 @@ def build(source, destination, debug, verbose, quiet, force, config, theme, for subtype in ('skipped', 'failed') if stats[_type + '_' + subtype] > 0] opt = ' ({})'.format(', '.join(opt)) if opt else '' - return '{} {}s{}'.format(stats[_type], _type, opt) + return f'{stats[_type]} {_type}s{opt}' if not quiet: stats_str = '' - types = sorted(set(t.rsplit('_', 1)[0] for t in stats)) + types = sorted({t.rsplit('_', 1)[0] for t in stats}) for t in types[:-1]: - stats_str += '{} and '.format(format_stats(t)) - stats_str += '{}'.format(format_stats(types[-1])) + stats_str += f'{format_stats(t)} and ' + stats_str += f'{format_stats(types[-1])}' print('Done, processed {} in {:.2f} seconds.' .format(stats_str, time.time() - start_time)) @@ -278,4 +278,4 @@ def set_meta(target, keys, overwrite=False): for i in range(len(keys) // 2): k, v = keys[i * 2:(i + 1) * 2] fp.write(f"{k.capitalize()}: {v}\n") - print("{} metadata key(s) written to {}".format(len(keys) // 2, descfile)) + print(f"{len(keys) // 2} metadata key(s) written to {descfile}") diff --git a/sigal/gallery.py b/sigal/gallery.py index 3b362a5..9ce6946 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -96,7 +96,7 @@ class Media: signals.media_initialized.send(self) def __repr__(self): - return "<{}>({!r})".format(self.__class__.__name__, str(self)) + return f"<{self.__class__.__name__}>({str(self)!r})" def __str__(self): return join(self.path, self.src_filename) diff --git a/sigal/log.py b/sigal/log.py index 46078d8..386c5f3 100644 --- a/sigal/log.py +++ b/sigal/log.py @@ -25,8 +25,8 @@ from logging import Formatter # The background is set with 40 plus the number of the color, and the # foreground with 30 -BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = [30 + i - for i in range(8)] +BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = (30 + i + for i in range(8)) COLORS = { 'DEBUG': BLUE, diff --git a/sigal/video.py b/sigal/video.py index 071ed6a..009645c 100644 --- a/sigal/video.py +++ b/sigal/video.py @@ -43,8 +43,7 @@ def check_subprocess(cmd, source, outname=None): """ logger = logging.getLogger(__name__) try: - res = subprocess.run(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + res = subprocess.run(cmd, capture_output=True) except KeyboardInterrupt: logger.debug('Process terminated, removing file %s', outname) if outname and os.path.isfile(outname): diff --git a/tests/test_video.py b/tests/test_video.py index 55a39be..e801682 100644 --- a/tests/test_video.py +++ b/tests/test_video.py @@ -101,7 +101,7 @@ def test_second_pass_video(mock_generate_video_pass, fmt, tmpdir): base, ext = os.path.splitext(TEST_VIDEO) dstfile = str(tmpdir.join(base + '.' + fmt)) settings_1 = '-c:v libvpx-vp9 -b:v 0 -crf 30 -pass 1 -an -f null dev/null' - settings_2 = '-c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -f {}'.format(fmt) + settings_2 = f'-c:v libvpx-vp9 -b:v 0 -crf 30 -pass 2 -f {fmt}' settings_opts = {'video_size': (100, 50), 'video_format': fmt, fmt + '_options': settings_1.split(" "), fmt + '_options_second_pass': settings_2.split(" ")}