mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 02:24:33 +01:00
Resolve W605: invalid escape sequence
This came up in lots of regexes that weren't using "raw" literals.
This commit is contained in:
parent
966108b72c
commit
bac8faad78
5 changed files with 9 additions and 9 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}'
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue