MCPcopy
hub / github.com/beetbox/beets / write

Method write

beets/util/m3u.py:75–95  ·  view source on GitHub ↗

Writes the m3u file to disk. Handles the creation of potential parent directories.

(self)

Source from the content-addressed store, hash-verified

73 self.extm3u = extm3u
74
75 def write(self):
76 """Writes the m3u file to disk.
77
78 Handles the creation of potential parent directories.
79 """
80 header = [b"#EXTM3U"] if self.extm3u else []
81 if not self.media_list:
82 raise EmptyPlaylistError
83 contents = header + self.media_list
84 pl_normpath = normpath(self.path)
85 mkdirall(pl_normpath)
86
87 try:
88 with open(syspath(pl_normpath), "wb") as pl_file:
89 for line in contents:
90 pl_file.write(line + b"\n")
91 pl_file.write(b"\n") # Final linefeed to prevent noeol file.
92 except OSError as exc:
93 raise FilesystemError(
94 exc, "create", (pl_normpath,), traceback.format_exc()
95 )

Callers 15

test_playlist_writeMethod · 0.95
convert_funcMethod · 0.95
bump_versionFunction · 0.45
create_archiveFunction · 0.45
test_unicode_pathMethod · 0.45

Calls 4

normpathFunction · 0.90
mkdirallFunction · 0.90
syspathFunction · 0.90
FilesystemErrorClass · 0.90