mirror of
https://github.com/beetbox/beets.git
synced 2025-12-24 01:25:47 +01:00
convert: playlist: Use syspath()
for file read and write operations.
This commit is contained in:
parent
7d121c390b
commit
8dc556d420
1 changed files with 5 additions and 2 deletions
|
|
@ -16,6 +16,9 @@
|
|||
"""
|
||||
|
||||
|
||||
from beets.util import syspath
|
||||
|
||||
|
||||
class EmptyPlaylistError(Exception):
|
||||
"""An error that should be raised when a playlist file without media files
|
||||
is saved or loaded.
|
||||
|
|
@ -41,7 +44,7 @@ class M3UFile():
|
|||
def load(self):
|
||||
"""Reads the m3u file from disk and sets the object's attributes.
|
||||
"""
|
||||
with open(self.path, "r") as playlist_file:
|
||||
with open(syspath(self.path), "r") as playlist_file:
|
||||
raw_contents = playlist_file.readlines()
|
||||
self.extm3u = True if raw_contents[0] == "#EXTM3U\n" else False
|
||||
for line in raw_contents[1:]:
|
||||
|
|
@ -72,6 +75,6 @@ class M3UFile():
|
|||
if not self.media_list:
|
||||
raise EmptyPlaylistError
|
||||
contents = header + self.media_list
|
||||
with open(self.path, "w") as playlist_file:
|
||||
with open(syspath(self.path), "w") as playlist_file:
|
||||
playlist_file.writelines('\n'.join(contents))
|
||||
playlist_file.write('\n') # Final linefeed to prevent noeol file.
|
||||
|
|
|
|||
Loading…
Reference in a new issue