Convert freedesktop plugin logging: func → method

This serves as an introduction for many plugin updates to come.
Multiple functions have to turn into methods -- and this is one of the
shortest plugins.
This commit is contained in:
Bruno Cauet 2015-01-05 21:10:46 +01:00
parent e14a54df05
commit 1be3dade04

View file

@ -22,21 +22,6 @@ from beets.ui import decargs
import os
def process_query(lib, opts, args):
for album in lib.albums(decargs(args)):
process_album(album)
def process_album(album):
albumpath = album.item_dir()
if album.artpath:
fullartpath = album.artpath
artfile = os.path.split(fullartpath)[1]
create_file(albumpath, artfile)
else:
log.debug(u'album has no art')
def create_file(albumpath, artfile):
file_contents = "[Desktop Entry]\nIcon=./" + artfile
outfilename = os.path.join(albumpath, ".directory")
@ -58,11 +43,24 @@ class FreedesktopPlugin(BeetsPlugin):
def commands(self):
freedesktop_command = Subcommand("freedesktop",
help="Create .directory files")
freedesktop_command.func = process_query
freedesktop_command.func = self.process_query
return [freedesktop_command]
def imported(self, lib, album):
automatic = self.config['auto'].get(bool)
if not automatic:
return
process_album(album)
self.process_album(album)
def process_query(self, lib, opts, args):
for album in lib.albums(decargs(args)):
self.process_album(album)
def process_album(self, album):
albumpath = album.item_dir()
if album.artpath:
fullartpath = album.artpath
artfile = os.path.split(fullartpath)[1]
create_file(albumpath, artfile)
else:
self._log.debug(u'album has no art')