From 9630714fac1b37e455f2bea92b06d8e03e941ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Wed, 26 Jun 2013 13:41:42 +0200 Subject: [PATCH] Fix location parsing issue with short paths --- darc/helpers.py | 8 ++++---- darc/testsuite/helpers.py | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/darc/helpers.py b/darc/helpers.py index 10e46175d..18a38feb1 100644 --- a/darc/helpers.py +++ b/darc/helpers.py @@ -245,17 +245,17 @@ def group2gid(group): return None -class Location(object): +class Location: """Object representing a repository / archive location """ proto = user = host = port = path = archive = None ssh_re = re.compile(r'(?Pssh)://(?:(?P[^@]+)@)?' r'(?P[^:/#]+)(?::(?P\d+))?' - r'(?P[^:]*)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?') file_re = re.compile(r'(?Pfile)://' - r'(?P[^:]*)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?') scp_re = re.compile(r'((?:(?P[^@]+)@)?(?P[^:/]+):)?' - r'(?P[^:]*)(?:::(?P.+))?') + r'(?P[^:]+)(?:::(?P.+))?') def __init__(self, text): self.orig = text diff --git a/darc/testsuite/helpers.py b/darc/testsuite/helpers.py index b9a152c8b..63dcd2454 100644 --- a/darc/testsuite/helpers.py +++ b/darc/testsuite/helpers.py @@ -19,8 +19,16 @@ class LocationTestCase(DarcTestCase): "Location(proto='ssh', user='user', host='host', port=22, path='/some/path', archive='archive')" ) self.assert_equal( - repr(Location('/some/path::archive')), - "Location(proto='file', user=None, host=None, port=None, path='/some/path', archive='archive')" + repr(Location('mybackup.darc::archive')), + "Location(proto='file', user=None, host=None, port=None, path='mybackup.darc', archive='archive')" + ) + self.assert_equal( + repr(Location('/some/absolute/path::archive')), + "Location(proto='file', user=None, host=None, port=None, path='/some/absolute/path', archive='archive')" + ) + self.assert_equal( + repr(Location('some/relative/path::archive')), + "Location(proto='file', user=None, host=None, port=None, path='some/relative/path', archive='archive')" )