diff --git a/beets/dbcore/queryparse.py b/beets/dbcore/queryparse.py index bc9cc77ec..ce88fa3bd 100644 --- a/beets/dbcore/queryparse.py +++ b/beets/dbcore/queryparse.py @@ -89,7 +89,7 @@ def parse_query_part(part, query_classes={}, prefixes={}, assert match # Regex should always match negate = bool(match.group(1)) key = match.group(2) - term = match.group(3).replace('\:', ':') + term = match.group(3).replace('\\:', ':') # Check whether there's a prefix in the query and use the # corresponding query type. diff --git a/beets/plugins.py b/beets/plugins.py index 1bd2cacd5..6dec7ef2a 100644 --- a/beets/plugins.py +++ b/beets/plugins.py @@ -488,7 +488,7 @@ def feat_tokens(for_artist=True): feat_words = ['ft', 'featuring', 'feat', 'feat.', 'ft.'] if for_artist: feat_words += ['with', 'vs', 'and', 'con', '&'] - return '(?<=\s)(?:{0})(?=\s)'.format( + return r'(?<=\s)(?:{0})(?=\s)'.format( '|'.join(re.escape(x) for x in feat_words) ) diff --git a/beetsplug/bucket.py b/beetsplug/bucket.py index c4be2a3df..db993d612 100644 --- a/beetsplug/bucket.py +++ b/beetsplug/bucket.py @@ -60,7 +60,7 @@ def span_from_str(span_str): d = (yearfrom - yearfrom % 100) + d return d - years = [int(x) for x in re.findall('\d+', span_str)] + years = [int(x) for x in re.findall(r'\d+', span_str)] if not years: raise ui.UserError(u"invalid range defined for year bucket '%s': no " u"year found" % span_str) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 60f537597..6ecdbd1d0 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -131,7 +131,7 @@ def unescape(text): def replchar(m): num = m.group(1) return unichar(int(num)) - out = re.sub(u"&#(\d+);", replchar, out) + out = re.sub(u"&#(\\d+);", replchar, out) return out @@ -537,12 +537,12 @@ class Google(Backend): """ text = re.sub(r"[-'_\s]", '_', text) text = re.sub(r"_+", '_', text).strip('_') - pat = "([^,\(]*)\((.*?)\)" # Remove content within parentheses - text = re.sub(pat, '\g<1>', text).strip() + pat = r"([^,\(]*)\((.*?)\)" # Remove content within parentheses + text = re.sub(pat, r'\g<1>', text).strip() try: text = unicodedata.normalize('NFKD', text).encode('ascii', 'ignore') - text = six.text_type(re.sub('[-\s]+', ' ', text.decode('utf-8'))) + text = six.text_type(re.sub(r'[-\s]+', ' ', text.decode('utf-8'))) except UnicodeDecodeError: self._log.exception(u"Failing to normalize '{0}'", text) return text diff --git a/beetsplug/the.py b/beetsplug/the.py index cfb583ced..83d1089de 100644 --- a/beetsplug/the.py +++ b/beetsplug/the.py @@ -23,8 +23,8 @@ from beets.plugins import BeetsPlugin __author__ = 'baobab@heresiarch.info' __version__ = '1.1' -PATTERN_THE = u'^[the]{3}\s' -PATTERN_A = u'^[a][n]?\s' +PATTERN_THE = u'^[the]{3}\\s' +PATTERN_A = u'^[a][n]?\\s' FORMAT = u'{0}, {1}'