Skip to content

Commit

Permalink
Remove unused platform parameter in item.destination
Browse files Browse the repository at this point in the history
  • Loading branch information
snejus committed Dec 29, 2024
1 parent e593658 commit 43ceebd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions beets/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,6 @@ def destination(
self,
relative_to_libdir=False,
basedir=None,
platform=None,
path_formats=None,
) -> bytes:
"""Return the path in the library directory designated for the item
Expand All @@ -1035,7 +1034,6 @@ def destination(
library's base directory for the destination.
"""
db = self._check_db()
platform = platform or sys.platform
basedir = basedir or db.directory
path_formats = path_formats or db.path_formats

Expand Down Expand Up @@ -1065,7 +1063,7 @@ def destination(
subpath = self.evaluate_template(subpath_tmpl, True)

# Prepare path for output: normalize Unicode characters.
if platform == "darwin":
if sys.platform == "darwin":
subpath = unicodedata.normalize("NFD", subpath)
else:
subpath = unicodedata.normalize("NFC", subpath)
Expand Down
10 changes: 7 additions & 3 deletions test/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import time
import unicodedata
import unittest
from unittest.mock import patch

import pytest
from mediafile import MediaFile, UnreadableFileError
Expand Down Expand Up @@ -411,13 +412,15 @@ def test_albumartist_overrides_artist(self):
def test_unicode_normalized_nfd_on_mac(self):
instr = unicodedata.normalize("NFC", "caf\xe9")
self.lib.path_formats = [("default", instr)]
dest = self.i.destination(platform="darwin", relative_to_libdir=True)
with patch("sys.platform", "darwin"):
dest = self.i.destination(relative_to_libdir=True)
assert as_string(dest) == unicodedata.normalize("NFD", instr)

def test_unicode_normalized_nfc_on_linux(self):
instr = unicodedata.normalize("NFD", "caf\xe9")
self.lib.path_formats = [("default", instr)]
dest = self.i.destination(platform="linux", relative_to_libdir=True)
with patch("sys.platform", "linux"):
dest = self.i.destination(relative_to_libdir=True)
assert as_string(dest) == unicodedata.normalize("NFC", instr)

def test_non_mbcs_characters_on_windows(self):
Expand All @@ -436,7 +439,8 @@ def test_non_mbcs_characters_on_windows(self):
def test_unicode_extension_in_fragment(self):
self.lib.path_formats = [("default", "foo")]
self.i.path = util.bytestring_path("bar.caf\xe9")
dest = self.i.destination(platform="linux", relative_to_libdir=True)
with patch("sys.platform", "linux"):
dest = self.i.destination(relative_to_libdir=True)
assert as_string(dest) == "foo.caf\xe9"

def test_asciify_and_replace(self):
Expand Down

0 comments on commit 43ceebd

Please sign in to comment.