Fix minor location parser bug.

Make sure the entire input is parsed.
This commit is contained in:
Jonas Borgström 2014-08-08 23:34:27 +02:00
parent 9f64e39d9f
commit 21e03af56b
2 changed files with 4 additions and 3 deletions

View File

@ -412,11 +412,11 @@ class Location:
proto = user = host = port = path = archive = None
ssh_re = re.compile(r'(?P<proto>ssh)://(?:(?P<user>[^@]+)@)?'
r'(?P<host>[^:/#]+)(?::(?P<port>\d+))?'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
file_re = re.compile(r'(?P<proto>file)://'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
scp_re = re.compile(r'((?:(?P<user>[^@]+)@)?(?P<host>[^:/]+):)?'
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?')
r'(?P<path>[^:]+)(?:::(?P<archive>.+))?$')
def __init__(self, text):
self.orig = text

View File

@ -49,6 +49,7 @@ class LocationTestCase(AtticTestCase):
repr(Location('some/relative/path::archive')),
"Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='archive')"
)
self.assert_raises(ValueError, lambda: Location('ssh://localhost:22/path:archive'))
class FormatTimedeltaTestCase(AtticTestCase):