Skip to content

Commit 0bc810e

Browse files
committed
Move util import to be consistent with other imports from util.
1 parent e41e4f0 commit 0bc810e

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

beets/ui/commands/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import os
44

5-
from beets import config, ui, util
5+
from beets import config, ui
6+
from beets.util import displayable_path, editor_command, interactive_open
67

78

89
def config_func(lib, opts, args):
@@ -25,7 +26,7 @@ def config_func(lib, opts, args):
2526
filenames.insert(0, user_path)
2627

2728
for filename in filenames:
28-
ui.print_(util.displayable_path(filename))
29+
ui.print_(displayable_path(filename))
2930

3031
# Open in editor.
3132
elif opts.edit:
@@ -45,11 +46,11 @@ def config_edit():
4546
An empty config file is created if no existing config file exists.
4647
"""
4748
path = config.user_config_path()
48-
editor = util.editor_command()
49+
editor = editor_command()
4950
try:
5051
if not os.path.isfile(path):
5152
open(path, "w+").close()
52-
util.interactive_open([path], editor)
53+
interactive_open([path], editor)
5354
except OSError as exc:
5455
message = f"Could not edit configuration: {exc}"
5556
if not editor:

beets/ui/commands/move.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
import os
44

5-
from beets import logging, ui, util
5+
from beets import logging, ui
6+
from beets.util import (
7+
MoveOperation,
8+
PathLike,
9+
displayable_path,
10+
normpath,
11+
syspath,
12+
)
613

714
from ._utils import do_query
815

@@ -28,8 +35,8 @@ def show_path_changes(path_changes):
2835
sources, destinations = zip(*path_changes)
2936

3037
# Ensure unicode output
31-
sources = list(map(util.displayable_path, sources))
32-
destinations = list(map(util.displayable_path, destinations))
38+
sources = list(map(displayable_path, sources))
39+
destinations = list(map(displayable_path, destinations))
3340

3441
# Calculate widths for terminal split
3542
col_width = (ui.term_width() - len(" -> ")) // 2
@@ -53,7 +60,7 @@ def show_path_changes(path_changes):
5360

5461
def move_items(
5562
lib,
56-
dest_path: util.PathLike,
63+
dest_path: PathLike,
5764
query,
5865
copy,
5966
album,
@@ -128,24 +135,22 @@ def isalbummoved(album):
128135
if export:
129136
# Copy without affecting the database.
130137
obj.move(
131-
operation=util.MoveOperation.COPY, basedir=dest, store=False
138+
operation=MoveOperation.COPY, basedir=dest, store=False
132139
)
133140
else:
134141
# Ordinary move/copy: store the new path.
135142
if copy:
136-
obj.move(operation=util.MoveOperation.COPY, basedir=dest)
143+
obj.move(operation=MoveOperation.COPY, basedir=dest)
137144
else:
138-
obj.move(operation=util.MoveOperation.MOVE, basedir=dest)
145+
obj.move(operation=MoveOperation.MOVE, basedir=dest)
139146

140147

141148
def move_func(lib, opts, args):
142149
dest = opts.dest
143150
if dest is not None:
144-
dest = util.normpath(dest)
145-
if not os.path.isdir(util.syspath(dest)):
146-
raise ui.UserError(
147-
f"no such directory: {util.displayable_path(dest)}"
148-
)
151+
dest = normpath(dest)
152+
if not os.path.isdir(syspath(dest)):
153+
raise ui.UserError(f"no such directory: {displayable_path(dest)}")
149154

150155
move_items(
151156
lib,

test/ui/commands/test_update.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
from mediafile import MediaFile
44

5-
from beets import library, util
5+
from beets import library
66
from beets.test import _common
77
from beets.test.helper import BeetsTestCase, IOMixin
88
from beets.ui.commands.update import update_items
9-
from beets.util import MoveOperation, syspath
9+
from beets.util import MoveOperation, remove, syspath
1010

1111

1212
class UpdateTest(IOMixin, BeetsTestCase):
@@ -29,7 +29,7 @@ def setUp(self):
2929
_common.touch(artfile)
3030
self.album.set_art(artfile)
3131
self.album.store()
32-
util.remove(artfile)
32+
remove(artfile)
3333

3434
def _update(
3535
self,
@@ -56,23 +56,23 @@ def _update(
5656

5757
def test_delete_removes_item(self):
5858
assert list(self.lib.items())
59-
util.remove(self.i.path)
60-
util.remove(self.i2.path)
59+
remove(self.i.path)
60+
remove(self.i2.path)
6161
self._update()
6262
assert not list(self.lib.items())
6363

6464
def test_delete_removes_album(self):
6565
assert self.lib.albums()
66-
util.remove(self.i.path)
67-
util.remove(self.i2.path)
66+
remove(self.i.path)
67+
remove(self.i2.path)
6868
self._update()
6969
assert not self.lib.albums()
7070

7171
def test_delete_removes_album_art(self):
7272
art_filepath = self.album.art_filepath
7373
assert art_filepath.exists()
74-
util.remove(self.i.path)
75-
util.remove(self.i2.path)
74+
remove(self.i.path)
75+
remove(self.i2.path)
7676
self._update()
7777
assert not art_filepath.exists()
7878

0 commit comments

Comments
 (0)