Beispiel #1
0
 def test_split_filename(self):
     self.assertIsNone(split_filename('abl.jquery'))
     self.assertEqual(split_filename('abl.jquery-1.4.2-2'),
                      ('abl.jquery', '1.4.2-2', None))
     self.assertEqual(split_filename('python-gnupg-0.1'),
                      ('python-gnupg', '0.1', None))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py3.2'),
                      ('baklabel', '1.0.3-2729', '3.2'))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py27'),
                      ('baklabel', '1.0.3-2729', '27'))
     self.assertEqual(split_filename('advpy-0.99b'),
                      ('advpy', '0.99b', None))
     self.assertEqual(split_filename('asv_files-dev-20120501-01', 'asv_files'),
                      ('asv_files', 'dev-20120501-01', None))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-win32'),
                      ('greenlet', '0.4.0', '27'))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-linux_x86_64'),
                      ('greenlet', '0.4.0', '27'))
Beispiel #2
0
def parse_filename(filename, name=None):
    """ Parse a name and version out of a filename """
    version = None
    for ext in ALL_EXTENSIONS:
        if filename.endswith(ext):
            trimmed = filename[:-len(ext)]
            parsed_name, version = split_filename(trimmed, name)[:2]
            break
    if version is None:
        raise ValueError("Cannot parse package file '%s'" % filename)
    if name is None:
        name = parsed_name
    return normalize_name(name), version
Beispiel #3
0
def parse_filename(filename, name=None):
    """ Parse a name and version out of a filename """
    version = None
    for ext in ALL_EXTENSIONS:
        if filename.endswith(ext):
            trimmed = filename[:-len(ext)]
            parsed_name, version = split_filename(trimmed, name)[:2]
            break
    if version is None:
        raise ValueError("Cannot parse package file '%s'" % filename)
    if name is None:
        name = parsed_name
    return normalize_name(name), version
Beispiel #4
0
def parse_filename(filename, name=None):
    """ Parse a name and version out of a filename """
    version = None
    for ext in ALL_EXTENSIONS:
        if filename.endswith(ext):
            if ext == '.whl':
                wheel = Wheel(filename)
                return wheel.name, wheel.version
            trimmed = filename[:-len(ext)]
            parsed = split_filename(trimmed, name)
            if parsed is None:
                break
            else:
                parsed_name, version = parsed[:2]
            break
    if version is None:
        raise ValueError("Cannot parse package file '%s'" % filename)
    if name is None:
        name = parsed_name
    return normalize_name(name), version
Beispiel #5
0
def parse_filename(filename, name=None):
    """ Parse a name and version out of a filename """
    version = None
    for ext in ALL_EXTENSIONS:
        if filename.endswith(ext):
            if ext == ".whl":
                wheel = Wheel(filename)
                return wheel.name, wheel.version
            trimmed = filename[: -len(ext)]
            parsed = split_filename(trimmed, name)
            if parsed is None:
                break
            else:
                parsed_name, version = parsed[:2]
            break
    if version is None:
        raise ValueError("Cannot parse package file '%s'" % filename)
    if name is None:
        name = parsed_name
    return normalize_name(name), version
Beispiel #6
0
 def test_split_filename(self):
     self.assertIsNone(split_filename('abl.jquery'))
     self.assertEqual(split_filename('abl.jquery-1.4.2-2'),
                      ('abl.jquery', '1.4.2-2', None))
     self.assertEqual(split_filename('python-gnupg-0.1'),
                      ('python-gnupg', '0.1', None))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py3.2'),
                      ('baklabel', '1.0.3-2729', '3.2'))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py27'),
                      ('baklabel', '1.0.3-2729', '27'))
     self.assertEqual(split_filename('advpy-0.99b'),
                      ('advpy', '0.99b', None))
     self.assertEqual(
         split_filename('asv_files-dev-20120501-01', 'asv_files'),
         ('asv_files', 'dev-20120501-01', None))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-win32'),
                      ('greenlet', '0.4.0', '27'))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-linux_x86_64'),
                      ('greenlet', '0.4.0', '27'))
     self.assertEqual(split_filename('django-altuser-v0.6.8'),
                      ('django-altuser', 'v0.6.8', None))
     self.assertEqual(split_filename('youtube_dl_server-alpha.1'),
                      ('youtube_dl_server', 'alpha.1', None))
     self.assertEqual(split_filename('pytest-xdist-dev'),
                      ('pytest-xdist', 'dev', None))
     self.assertEqual(split_filename('pytest_xdist-0.1_myfork', None),
                      ('pytest_xdist', '0.1_myfork', None))
     self.assertEqual(
         split_filename('pytest_xdist-0.1_myfork', 'pytest-xdist'),
         ('pytest_xdist', '0.1_myfork', None))
     self.assertEqual(
         split_filename('pytest_xdist-0.1_myfork', 'pytest_dist'),
         ('pytest_xdist', '0.1_myfork', None))
Beispiel #7
0
 def test_split_filename(self):
     self.assertIsNone(split_filename('abl.jquery'))
     self.assertEqual(split_filename('abl.jquery-1.4.2-2'),
                      ('abl.jquery', '1.4.2-2', None))
     self.assertEqual(split_filename('python-gnupg-0.1'),
                      ('python-gnupg', '0.1', None))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py3.2'),
                      ('baklabel', '1.0.3-2729', '3.2'))
     self.assertEqual(split_filename('baklabel-1.0.3-2729-py27'),
                      ('baklabel', '1.0.3-2729', '27'))
     self.assertEqual(split_filename('advpy-0.99b'),
                      ('advpy', '0.99b', None))
     self.assertEqual(split_filename('asv_files-dev-20120501-01', 'asv_files'),
                      ('asv_files', 'dev-20120501-01', None))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-win32'),
                      ('greenlet', '0.4.0', '27'))
     self.assertEqual(split_filename('greenlet-0.4.0-py27-linux_x86_64'),
                      ('greenlet', '0.4.0', '27'))
     self.assertEqual(split_filename('django-altuser-v0.6.8'),
                      ('django-altuser', 'v0.6.8', None))
     self.assertEqual(split_filename('youtube_dl_server-alpha.1'),
                      ('youtube_dl_server', 'alpha.1', None))
     self.assertEqual(split_filename('pytest-xdist-dev'),
                      ('pytest-xdist', 'dev', None))
     self.assertEqual(split_filename('pytest_xdist-0.1_myfork', None),
                      ('pytest_xdist', '0.1_myfork', None))
     self.assertEqual(split_filename('pytest_xdist-0.1_myfork',
                                     'pytest-xdist'),
                      ('pytest_xdist', '0.1_myfork', None))
     self.assertEqual(split_filename('pytest_xdist-0.1_myfork',
                                     'pytest_dist'),
                      ('pytest_xdist', '0.1_myfork', None))