From 60e945a516b1b1e956d9e7f4208b69d41bebeafa Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Fri, 9 Apr 2010 23:07:20 -0700 Subject: [PATCH] dedup query-joining code --- bts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bts b/bts index e71c1a8ca..a243fdcc6 100755 --- a/bts +++ b/bts @@ -109,6 +109,11 @@ def tag_album(items, lib, copy=True, write=True): if write: item.write() +def make_query(criteria): + """Make query string for the list of criteria.""" + return ' '.join(criteria).strip() or None + + class BeetsApp(cmdln.Cmdln): name = "bts" @@ -188,10 +193,7 @@ class BeetsApp(cmdln.Cmdln): ${cmd_usage} ${cmd_option_list} """ - q = ' '.join(criteria) - if not q.strip(): - q = None # no criteria => match anything - + q = make_query(criteria) if opts.album: for artist, album in self.lib.albums(query=q): _print(artist + ' - ' + album) @@ -210,7 +212,7 @@ class BeetsApp(cmdln.Cmdln): ${cmd_usage} ${cmd_option_list} """ - q = ' '.join(criteria).strip() or None + q = make_query(criteria) # Get the matching items. if opts.album: