mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Fix formatting
This commit is contained in:
parent
36d42c5b6f
commit
c490ac5810
31 changed files with 67 additions and 71 deletions
|
|
@ -121,15 +121,15 @@ class Assertions:
|
|||
|
||||
def assertIsFile(self, path):
|
||||
self.assertExists(path)
|
||||
assert os.path.isfile(
|
||||
syspath(path)
|
||||
), "path exists, but is not a regular file: {!r}".format(path)
|
||||
assert os.path.isfile(syspath(path)), (
|
||||
"path exists, but is not a regular file: {!r}".format(path)
|
||||
)
|
||||
|
||||
def assertIsDir(self, path):
|
||||
self.assertExists(path)
|
||||
assert os.path.isdir(
|
||||
syspath(path)
|
||||
), "path exists, but is not a directory: {!r}".format(path)
|
||||
assert os.path.isdir(syspath(path)), (
|
||||
"path exists, but is not a directory: {!r}".format(path)
|
||||
)
|
||||
|
||||
def assert_equal_path(self, a, b):
|
||||
"""Check that two paths are equal."""
|
||||
|
|
|
|||
|
|
@ -1768,7 +1768,7 @@ def _open_library(config):
|
|||
)
|
||||
)
|
||||
log.debug(
|
||||
"library database: {0}\n" "library directory: {1}",
|
||||
"library database: {0}\nlibrary directory: {1}",
|
||||
util.displayable_path(lib.path),
|
||||
util.displayable_path(lib.directory),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1599,9 +1599,7 @@ def list_func(lib, opts, args):
|
|||
|
||||
|
||||
list_cmd = ui.Subcommand("list", help="query the library", aliases=("ls",))
|
||||
list_cmd.parser.usage += (
|
||||
"\n" "Example: %prog -f '$album: $title' artist:beatles"
|
||||
)
|
||||
list_cmd.parser.usage += "\nExample: %prog -f '$album: $title' artist:beatles"
|
||||
list_cmd.parser.add_all_common_options()
|
||||
list_cmd.func = list_func
|
||||
default_commands.append(list_cmd)
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ def link(path: bytes, dest: bytes, replace: bool = False):
|
|||
except NotImplementedError:
|
||||
# raised on python >= 3.2 and Windows versions before Vista
|
||||
raise FilesystemError(
|
||||
"OS does not support symbolic links." "link",
|
||||
"OS does not support symbolic links.link",
|
||||
(path, dest),
|
||||
traceback.format_exc(),
|
||||
)
|
||||
|
|
@ -581,14 +581,14 @@ def hardlink(path: bytes, dest: bytes, replace: bool = False):
|
|||
os.link(syspath(path), syspath(dest))
|
||||
except NotImplementedError:
|
||||
raise FilesystemError(
|
||||
"OS does not support hard links." "link",
|
||||
"OS does not support hard links.link",
|
||||
(path, dest),
|
||||
traceback.format_exc(),
|
||||
)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EXDEV:
|
||||
raise FilesystemError(
|
||||
"Cannot hard link across devices." "link",
|
||||
"Cannot hard link across devices.link",
|
||||
(path, dest),
|
||||
traceback.format_exc(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ only files which would be processed",
|
|||
# If file has no MBID, skip it.
|
||||
if not mbid:
|
||||
self._log.info(
|
||||
"Not analysing {}, missing " "musicbrainz track id.", item
|
||||
"Not analysing {}, missing musicbrainz track id.", item
|
||||
)
|
||||
return None
|
||||
|
||||
|
|
@ -220,6 +220,6 @@ only files which would be processed",
|
|||
)
|
||||
else:
|
||||
self._log.debug(
|
||||
"Successfully submitted AcousticBrainz analysis " "for {}.",
|
||||
"Successfully submitted AcousticBrainz analysis for {}.",
|
||||
item,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ class AcousticPlugin(plugins.BeetsPlugin):
|
|||
yield v, subdata[k]
|
||||
else:
|
||||
self._log.warning(
|
||||
"Acousticbrainz did not provide info " "about {}", k
|
||||
"Acousticbrainz did not provide info about {}", k
|
||||
)
|
||||
self._log.debug(
|
||||
"Data {} could not be mapped to scheme {} "
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class BareascPlugin(BeetsPlugin):
|
|||
"bareasc", help="unidecode version of beet list command"
|
||||
)
|
||||
cmd.parser.usage += (
|
||||
"\n" "Example: %prog -f '$album: $title' artist:beatles"
|
||||
"\nExample: %prog -f '$album: $title' artist:beatles"
|
||||
)
|
||||
cmd.parser.add_all_common_options()
|
||||
cmd.func = self.unidecode_list
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class BPMPlugin(BeetsPlugin):
|
|||
def commands(self):
|
||||
cmd = ui.Subcommand(
|
||||
"bpm",
|
||||
help="determine bpm of a song by pressing " "a key to the rhythm",
|
||||
help="determine bpm of a song by pressing a key to the rhythm",
|
||||
)
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
|
@ -79,7 +79,7 @@ class BPMPlugin(BeetsPlugin):
|
|||
return
|
||||
|
||||
self._log.info(
|
||||
"Press Enter {0} times to the rhythm or Ctrl-D " "to exit",
|
||||
"Press Enter {0} times to the rhythm or Ctrl-D to exit",
|
||||
self.config["max_strokes"].get(int),
|
||||
)
|
||||
new_bpm = bpm(self.config["max_strokes"].get(int))
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
checksum = getattr(item, key, False)
|
||||
if not checksum:
|
||||
self._log.debug(
|
||||
"key {0} on item {1} not cached:" "computing checksum",
|
||||
"key {0} on item {1} not cached:computing checksum",
|
||||
key,
|
||||
displayable_path(item.path),
|
||||
)
|
||||
|
|
@ -255,7 +255,7 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
)
|
||||
else:
|
||||
self._log.debug(
|
||||
"key {0} on item {1} cached:" "not computing checksum",
|
||||
"key {0} on item {1} cached:not computing checksum",
|
||||
key,
|
||||
displayable_path(item.path),
|
||||
)
|
||||
|
|
@ -275,13 +275,13 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
values = [v for v in values if v not in (None, "")]
|
||||
if strict and len(values) < len(keys):
|
||||
self._log.debug(
|
||||
"some keys {0} on item {1} are null or empty:" " skipping",
|
||||
"some keys {0} on item {1} are null or empty: skipping",
|
||||
keys,
|
||||
displayable_path(obj.path),
|
||||
)
|
||||
elif not strict and not len(values):
|
||||
self._log.debug(
|
||||
"all keys {0} on item {1} are null or empty:" " skipping",
|
||||
"all keys {0} on item {1} are null or empty: skipping",
|
||||
keys,
|
||||
displayable_path(obj.path),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class EmbedCoverArtPlugin(BeetsPlugin):
|
|||
if self.config["maxwidth"].get(int) and not ArtResizer.shared.local:
|
||||
self.config["maxwidth"] = 0
|
||||
self._log.warning(
|
||||
"ImageMagick or PIL not found; " "'maxwidth' option ignored"
|
||||
"ImageMagick or PIL not found; 'maxwidth' option ignored"
|
||||
)
|
||||
if (
|
||||
self.config["compare_threshold"].get(int)
|
||||
|
|
|
|||
|
|
@ -686,7 +686,7 @@ class FanartTV(RemoteArtSource):
|
|||
# can this actually occur?
|
||||
else:
|
||||
self._log.debug(
|
||||
"fanart.tv: unexpected mb_releasegroupid in " "response!"
|
||||
"fanart.tv: unexpected mb_releasegroupid in response!"
|
||||
)
|
||||
|
||||
matches.sort(key=lambda x: int(x["likes"]), reverse=True)
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ class ImportAddedPlugin(BeetsPlugin):
|
|||
or session.config["reflink"]
|
||||
):
|
||||
self._log.debug(
|
||||
"In place import detected, recording mtimes from "
|
||||
"source paths"
|
||||
"In place import detected, recording mtimes from source paths"
|
||||
)
|
||||
items = (
|
||||
[task.item]
|
||||
|
|
@ -95,7 +94,7 @@ class ImportAddedPlugin(BeetsPlugin):
|
|||
mtime = os.stat(util.syspath(source)).st_mtime
|
||||
self.item_mtime[destination] = mtime
|
||||
self._log.debug(
|
||||
"Recorded mtime {0} for item '{1}' imported from " "'{2}'",
|
||||
"Recorded mtime {0} for item '{1}' imported from '{2}'",
|
||||
mtime,
|
||||
util.displayable_path(destination),
|
||||
util.displayable_path(source),
|
||||
|
|
@ -130,7 +129,7 @@ class ImportAddedPlugin(BeetsPlugin):
|
|||
def update_item_times(self, lib, item):
|
||||
if self.reimported_item(item):
|
||||
self._log.debug(
|
||||
"Item '{0}' is reimported, skipping import of " "added date.",
|
||||
"Item '{0}' is reimported, skipping import of added date.",
|
||||
util.displayable_path(item.path),
|
||||
)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class InlineError(Exception):
|
|||
|
||||
def __init__(self, code, exc):
|
||||
super().__init__(
|
||||
("error in inline path field code:\n" "%s\n%s: %s")
|
||||
("error in inline path field code:\n%s\n%s: %s")
|
||||
% (code, type(exc).__name__, str(exc))
|
||||
)
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ class InlinePlugin(BeetsPlugin):
|
|||
func = _compile_func(python_code)
|
||||
except SyntaxError:
|
||||
self._log.error(
|
||||
"syntax error in inline field definition:\n" "{0}",
|
||||
"syntax error in inline field definition:\n{0}",
|
||||
traceback.format_exc(),
|
||||
)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ def process_tracks(lib, tracks, log):
|
|||
count = int(song.get("play_count", 0))
|
||||
new_count = int(tracks[num].get("playcount", 1))
|
||||
log.debug(
|
||||
"match: {0} - {1} ({2}) " "updating: play_count {3} => {4}",
|
||||
"match: {0} - {1} ({2}) updating: play_count {3} => {4}",
|
||||
song.artist,
|
||||
song.title,
|
||||
song.album,
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class ListenBrainzPlugin(BeetsPlugin):
|
|||
)
|
||||
for playlist in listenbrainz_playlists:
|
||||
self._log.debug(
|
||||
f'Playlist: {playlist["type"]} - {playlist["date"]}'
|
||||
f"Playlist: {playlist['type']} - {playlist['date']}"
|
||||
)
|
||||
return listenbrainz_playlists
|
||||
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ class Genius(SearchBackend):
|
|||
|
||||
@cached_property
|
||||
def headers(self) -> dict[str, str]:
|
||||
return {"Authorization": f'Bearer {self.config["genius_api_key"]}'}
|
||||
return {"Authorization": f"Bearer {self.config['genius_api_key']}"}
|
||||
|
||||
def search(self, artist: str, title: str) -> Iterable[SearchResult]:
|
||||
search_data: GeniusAPI.Search = self.fetch_json(
|
||||
|
|
@ -913,17 +913,17 @@ class RestFiles:
|
|||
|
||||
def write_artist(self, artist: str, items: Iterable[Item]) -> None:
|
||||
parts = [
|
||||
f'{artist}\n{"=" * len(artist)}',
|
||||
f"{artist}\n{'=' * len(artist)}",
|
||||
".. contents::\n :local:",
|
||||
]
|
||||
for album, items in groupby(items, key=lambda i: i.album):
|
||||
parts.append(f'{album}\n{"-" * len(album)}')
|
||||
parts.append(f"{album}\n{'-' * len(album)}")
|
||||
parts.extend(
|
||||
part
|
||||
for i in items
|
||||
if (title := f":index:`{i.title.strip()}`")
|
||||
for part in (
|
||||
f'{title}\n{"~" * len(title)}',
|
||||
f"{title}\n{'~' * len(title)}",
|
||||
textwrap.indent(i.lyrics, "| "),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class SmartPlaylistPlugin(BeetsPlugin):
|
|||
if extm3u:
|
||||
attr = [(k, entry.item[k]) for k in keys]
|
||||
al = [
|
||||
f" {key}=\"{quote(str(value), safe='/:')}\""
|
||||
f' {key}="{quote(str(value), safe="/:")}"'
|
||||
for key, value in attr
|
||||
]
|
||||
attrs = "".join(al)
|
||||
|
|
|
|||
|
|
@ -208,8 +208,7 @@ class SpotifyPlugin(MetadataSourcePlugin, BeetsPlugin):
|
|||
"Retry-After", DEFAULT_WAITING_TIME
|
||||
)
|
||||
self._log.debug(
|
||||
f"Too many API requests. Retrying after "
|
||||
f"{seconds} seconds."
|
||||
f"Too many API requests. Retrying after {seconds} seconds."
|
||||
)
|
||||
time.sleep(int(seconds) + 1)
|
||||
return self._handle_response(
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class SubsonicPlaylistPlugin(BeetsPlugin):
|
|||
)[0]
|
||||
if playlists.attrib.get("code", "200") != "200":
|
||||
alt_error = (
|
||||
"error getting playlists," " but no error message found"
|
||||
"error getting playlists, but no error message found"
|
||||
)
|
||||
self._log.warn(playlists.attrib.get("message", alt_error))
|
||||
return
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ThePlugin(BeetsPlugin):
|
|||
else:
|
||||
if not (p.startswith("^") or p.endswith("$")):
|
||||
self._log.warning(
|
||||
'warning: "{0}" will not ' "match string start/end",
|
||||
'warning: "{0}" will not match string start/end',
|
||||
p,
|
||||
)
|
||||
if self.config["a"]:
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
)
|
||||
else:
|
||||
self._log.debug(
|
||||
"{1}x{1} thumbnail for {0} exists and is " "recent enough",
|
||||
"{1}x{1} thumbnail for {0} exists and is recent enough",
|
||||
album,
|
||||
size,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class ZeroPlugin(BeetsPlugin):
|
|||
self._log.error("invalid field: {0}", field)
|
||||
elif field in ("id", "path", "album_id"):
|
||||
self._log.warning(
|
||||
"field '{0}' ignored, zeroing " "it would be dangerous", field
|
||||
"field '{0}' ignored, zeroing it would be dangerous", field
|
||||
)
|
||||
else:
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ For packagers:
|
|||
Other changes:
|
||||
|
||||
{new_header}
|
||||
{'-' * len(new_header)}
|
||||
{"-" * len(new_header)}
|
||||
""",
|
||||
text,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ class ConvertMixin:
|
|||
self.assertIsFile(path)
|
||||
with open(path, "rb") as f:
|
||||
f.seek(-len(display_tag), os.SEEK_END)
|
||||
assert (
|
||||
f.read() == tag
|
||||
), f"{displayable_path(path)} is not tagged with {display_tag}"
|
||||
assert f.read() == tag, (
|
||||
f"{displayable_path(path)} is not tagged with {display_tag}"
|
||||
)
|
||||
|
||||
def assertNoFileTag(self, path, tag):
|
||||
"""Assert that the path is a file and the files content does not
|
||||
|
|
@ -80,9 +80,9 @@ class ConvertMixin:
|
|||
self.assertIsFile(path)
|
||||
with open(path, "rb") as f:
|
||||
f.seek(-len(tag), os.SEEK_END)
|
||||
assert (
|
||||
f.read() != tag
|
||||
), f"{displayable_path(path)} is unexpectedly tagged with {display_tag}"
|
||||
assert f.read() != tag, (
|
||||
f"{displayable_path(path)} is unexpectedly tagged with {display_tag}"
|
||||
)
|
||||
|
||||
|
||||
class ConvertTestCase(ConvertMixin, PluginTestCase):
|
||||
|
|
@ -124,9 +124,9 @@ class ImportConvertTest(AsIsImporterMixin, ImportHelper, ConvertTestCase):
|
|||
self.run_asis_importer()
|
||||
for path in self.importer.paths:
|
||||
for root, dirnames, filenames in os.walk(path):
|
||||
assert (
|
||||
len(fnmatch.filter(filenames, "*.mp3")) == 0
|
||||
), f"Non-empty import directory {util.displayable_path(path)}"
|
||||
assert len(fnmatch.filter(filenames, "*.mp3")) == 0, (
|
||||
f"Non-empty import directory {util.displayable_path(path)}"
|
||||
)
|
||||
|
||||
def get_count_of_import_files(self):
|
||||
import_file_count = 0
|
||||
|
|
|
|||
|
|
@ -153,9 +153,9 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase):
|
|||
self.run_command("embedart", "-y", "-f", self.abbey_differentpath)
|
||||
mediafile = MediaFile(syspath(item.path))
|
||||
|
||||
assert (
|
||||
mediafile.images[0].data == self.image_data
|
||||
), f"Image written is not {displayable_path(self.abbey_artpath)}"
|
||||
assert mediafile.images[0].data == self.image_data, (
|
||||
f"Image written is not {displayable_path(self.abbey_artpath)}"
|
||||
)
|
||||
|
||||
@require_artresizer_compare
|
||||
def test_accept_similar_art(self):
|
||||
|
|
@ -167,9 +167,9 @@ class EmbedartCliTest(PluginMixin, FetchImageHelper, BeetsTestCase):
|
|||
self.run_command("embedart", "-y", "-f", self.abbey_similarpath)
|
||||
mediafile = MediaFile(syspath(item.path))
|
||||
|
||||
assert (
|
||||
mediafile.images[0].data == self.image_data
|
||||
), f"Image written is not {displayable_path(self.abbey_similarpath)}"
|
||||
assert mediafile.images[0].data == self.image_data, (
|
||||
f"Image written is not {displayable_path(self.abbey_similarpath)}"
|
||||
)
|
||||
|
||||
def test_non_ascii_album_path(self):
|
||||
resource_path = os.path.join(_common.RSRC, b"image.mp3")
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class EmbyUpdateTest(PluginTestCase):
|
|||
|
||||
responses.add(
|
||||
responses.POST,
|
||||
("http://localhost:8096" "/Users/AuthenticateByName"),
|
||||
("http://localhost:8096/Users/AuthenticateByName"),
|
||||
body=body,
|
||||
status=200,
|
||||
content_type="application/json",
|
||||
|
|
|
|||
|
|
@ -64,6 +64,6 @@ class MBSubmitPluginTest(PluginMixin, TerminalImportMixin, ImportTestCase):
|
|||
|
||||
# Manually build the string for comparing the output.
|
||||
tracklist = (
|
||||
"Open files with Picard? " "02. Tag Track 2 - Tag Artist (0:01)"
|
||||
"Open files with Picard? 02. Tag Track 2 - Tag Artist (0:01)"
|
||||
)
|
||||
assert tracklist in output.getvalue()
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class PlayPluginTest(CleanupModulesMixin, PluginTestCase):
|
|||
with open(open_mock.call_args[0][0][0], "rb") as f:
|
||||
playlist = f.read().decode("utf-8")
|
||||
assert (
|
||||
f'{os.path.dirname(self.item.path.decode("utf-8"))}\n' == playlist
|
||||
f"{os.path.dirname(self.item.path.decode('utf-8'))}\n" == playlist
|
||||
)
|
||||
|
||||
def test_raw(self, open_mock):
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class EventsTest(PluginImportTestCase):
|
|||
|
||||
logs = [line for line in logs if not line.startswith("Sending event:")]
|
||||
assert logs == [
|
||||
f'Album: {displayable_path(os.path.join(self.import_dir, b"album"))}',
|
||||
f"Album: {displayable_path(os.path.join(self.import_dir, b'album'))}",
|
||||
f" {displayable_path(self.import_media[0].path)}",
|
||||
f" {displayable_path(self.import_media[1].path)}",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class ParseTest(unittest.TestCase):
|
|||
"""
|
||||
assert isinstance(obj, functemplate.Call), f"not a Call: {obj}"
|
||||
assert obj.ident == ident, f"wrong identifier: {obj.ident} vs. {ident}"
|
||||
assert (
|
||||
len(obj.args) == numargs
|
||||
), f"wrong argument count in {obj.ident}: {len(obj.args)} vs. {numargs}"
|
||||
assert len(obj.args) == numargs, (
|
||||
f"wrong argument count in {obj.ident}: {len(obj.args)} vs. {numargs}"
|
||||
)
|
||||
|
||||
def test_plain_text(self):
|
||||
assert list(_normparse("hello world")) == ["hello world"]
|
||||
|
|
|
|||
|
|
@ -1441,7 +1441,7 @@ class CompletionTest(TestPluginTestCase):
|
|||
assert tester.returncode == 0
|
||||
assert out == b"completion tests passed\n", (
|
||||
"test/test_completion.sh did not execute properly. "
|
||||
f'Output:{out.decode("utf-8")}'
|
||||
f"Output:{out.decode('utf-8')}"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue