From 104aec3c2f9196637e90c63a6818c8e0cfd40f52 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 1 May 2012 20:03:01 -0700 Subject: [PATCH] cleanup and docs for regular expression queries --- beets/library.py | 85 +++++++++++++++++++++++++--------------- docs/changelog.rst | 3 ++ docs/reference/query.rst | 43 ++++++++++++-------- test/test_query.py | 5 +-- 4 files changed, 85 insertions(+), 51 deletions(-) diff --git a/beets/library.py b/beets/library.py index ef7af6dd2..f2aebcbd7 100644 --- a/beets/library.py +++ b/beets/library.py @@ -425,7 +425,7 @@ class RegexpQuery(FieldQuery): def match(self, item): value = getattr(item, self.field) or '' - return self.regexp.match(value) is not None + return self.regexp.search(value) is not None class BooleanQuery(MatchQuery): """Matches a boolean field. Pattern should either be a boolean or a @@ -476,24 +476,28 @@ class CollectionQuery(Query): subvals += subq_subvals clause = (' ' + joiner + ' ').join(clause_parts) return clause, subvals - - # regular expression for _parse_query_part, below - _pq_regex = re.compile(# non-grouping optional segment for the keyword - r'(?:' - r'(\S+?)' # the keyword - r'(?