mirror of
https://github.com/beetbox/beets.git
synced 2025-12-25 10:05:13 +01:00
Replace ur'' strings by r'' strings
Since we use unicode_literals they are equivalent, but ur'' strings are a syntax error in python 3.0+
This commit is contained in:
parent
be5fe4ae7f
commit
dbef31776f
3 changed files with 30 additions and 30 deletions
|
|
@ -27,29 +27,29 @@ import re
|
|||
# Filename field extraction patterns.
|
||||
PATTERNS = [
|
||||
# "01 - Track 01" and "01": do nothing
|
||||
ur'^(\d+)\s*-\s*track\s*\d$',
|
||||
ur'^\d+$',
|
||||
r'^(\d+)\s*-\s*track\s*\d$',
|
||||
r'^\d+$',
|
||||
|
||||
# Useful patterns.
|
||||
ur'^(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
ur'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
ur'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
ur'^(?P<artist>.+)-(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\.\s*(?P<artist>.+)-(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\s*-\s*(?P<artist>.+)-(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)$',
|
||||
ur'^(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\.\s*(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\s*-\s*(?P<title>.+)$',
|
||||
ur'^(?P<track>\d+)\s(?P<title>.+)$',
|
||||
ur'^(?P<title>.+) by (?P<artist>.+)$',
|
||||
r'^(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
r'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
r'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
|
||||
r'^(?P<artist>.+)-(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\.\s*(?P<artist>.+)-(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\s*-\s*(?P<artist>.+)-(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)$',
|
||||
r'^(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\.\s*(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\s*-\s*(?P<title>.+)$',
|
||||
r'^(?P<track>\d+)\s(?P<title>.+)$',
|
||||
r'^(?P<title>.+) by (?P<artist>.+)$',
|
||||
]
|
||||
|
||||
# Titles considered "empty" and in need of replacement.
|
||||
BAD_TITLE_PATTERNS = [
|
||||
ur'^$',
|
||||
ur'\d+?\s?-?\s*track\s*\d+',
|
||||
r'^$',
|
||||
r'\d+?\s?-?\s*track\s*\d+',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -413,14 +413,14 @@ class DestinationTest(_common.TestCase):
|
|||
def test_sanitize_with_custom_replace_overrides_built_in_sub(self):
|
||||
with _common.platform_posix():
|
||||
p = util.sanitize_path(u'a/.?/b', [
|
||||
(re.compile(ur'foo'), u'bar'),
|
||||
(re.compile(r'foo'), u'bar'),
|
||||
])
|
||||
self.assertEqual(p, u'a/.?/b')
|
||||
|
||||
def test_sanitize_with_custom_replace_adds_replacements(self):
|
||||
with _common.platform_posix():
|
||||
p = util.sanitize_path(u'foo/bar', [
|
||||
(re.compile(ur'foo'), u'bar'),
|
||||
(re.compile(r'foo'), u'bar'),
|
||||
])
|
||||
self.assertEqual(p, u'bar/bar')
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ class DestinationTest(_common.TestCase):
|
|||
|
||||
def test_destination_with_replacements(self):
|
||||
self.lib.directory = 'base'
|
||||
self.lib.replacements = [(re.compile(ur'a'), u'e')]
|
||||
self.lib.replacements = [(re.compile(r'a'), u'e')]
|
||||
self.lib.path_formats = [('default', '$album/$title')]
|
||||
self.i.title = 'foo'
|
||||
self.i.album = 'bar'
|
||||
|
|
@ -476,14 +476,14 @@ class DestinationTest(_common.TestCase):
|
|||
def test_sanitize_empty_component(self):
|
||||
with _common.platform_posix():
|
||||
p = util.sanitize_path(u'foo//bar', [
|
||||
(re.compile(ur'^$'), u'_'),
|
||||
(re.compile(r'^$'), u'_'),
|
||||
])
|
||||
self.assertEqual(p, u'foo/_/bar')
|
||||
|
||||
@unittest.skip('unimplemented: #359')
|
||||
def test_destination_with_empty_component(self):
|
||||
self.lib.directory = 'base'
|
||||
self.lib.replacements = [(re.compile(ur'^$'), u'_')]
|
||||
self.lib.replacements = [(re.compile(r'^$'), u'_')]
|
||||
self.lib.path_formats = [('default', '$album/$artist/$title')]
|
||||
self.i.title = 'three'
|
||||
self.i.artist = ''
|
||||
|
|
@ -495,7 +495,7 @@ class DestinationTest(_common.TestCase):
|
|||
@unittest.skip('unimplemented: #359')
|
||||
def test_destination_with_empty_final_component(self):
|
||||
self.lib.directory = 'base'
|
||||
self.lib.replacements = [(re.compile(ur'^$'), u'_')]
|
||||
self.lib.replacements = [(re.compile(r'^$'), u'_')]
|
||||
self.lib.path_formats = [('default', '$album/$title')]
|
||||
self.i.title = ''
|
||||
self.i.album = 'one'
|
||||
|
|
|
|||
|
|
@ -23,42 +23,42 @@ from beetsplug import bpd
|
|||
|
||||
class CommandParseTest(unittest.TestCase):
|
||||
def test_no_args(self):
|
||||
s = ur'command'
|
||||
s = r'command'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.name, u'command')
|
||||
self.assertEqual(c.args, [])
|
||||
|
||||
def test_one_unquoted_arg(self):
|
||||
s = ur'command hello'
|
||||
s = r'command hello'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.name, u'command')
|
||||
self.assertEqual(c.args, [u'hello'])
|
||||
|
||||
def test_two_unquoted_args(self):
|
||||
s = ur'command hello there'
|
||||
s = r'command hello there'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.name, u'command')
|
||||
self.assertEqual(c.args, [u'hello', u'there'])
|
||||
|
||||
def test_one_quoted_arg(self):
|
||||
s = ur'command "hello there"'
|
||||
s = r'command "hello there"'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.name, u'command')
|
||||
self.assertEqual(c.args, [u'hello there'])
|
||||
|
||||
def test_heterogenous_args(self):
|
||||
s = ur'command "hello there" sir'
|
||||
s = r'command "hello there" sir'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.name, u'command')
|
||||
self.assertEqual(c.args, [u'hello there', u'sir'])
|
||||
|
||||
def test_quote_in_arg(self):
|
||||
s = ur'command "hello \" there"'
|
||||
s = r'command "hello \" there"'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.args, [u'hello " there'])
|
||||
|
||||
def test_backslash_in_arg(self):
|
||||
s = ur'command "hello \\ there"'
|
||||
s = r'command "hello \\ there"'
|
||||
c = bpd.Command(s)
|
||||
self.assertEqual(c.args, [u'hello \ there'])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue