示例#1
0
    def test_parse_repo_url(self):
        testcases = [
            ('http://github.com/foo/bar', 'http://github.com/foo/bar'),
            ('https://github.com/foo/bar/baz', 'https://github.com/foo/bar'),
            ('git+https://github.com/foo/bar/baz',
             'https://github.com/foo/bar'),
            ('git+git://github.com/foo/bar.git#egg=foo',
             'git://github.com/foo/bar.git'),
            ('https://code.google.com/p/bar', 'https://code.google.com/p/bar'),
            ('https://code.google.com/p/bar/blah/blah',
             'https://code.google.com/p/bar'),
            ('git+https://code.google.com/p/bar/blah/blah',
             'https://code.google.com/p/bar'),
            ('git+git://code.google.com/p/bar.git#egg=foo',
             'git://code.google.com/p/bar.git'),
            ('https://bitbucket.org/foo/bar', 'https://bitbucket.org/foo/bar'),
            ('https://bitbucket.org/foo/bar/baz',
             'https://bitbucket.org/foo/bar'),
            ('hg+https://bitbucket.org/foo/bar',
             'https://bitbucket.org/foo/bar'),
            ('git+git://bitbucket.org/foo/bar', 'git://bitbucket.org/foo/bar'),
            ('https://google.com', None),
            ('file:///tmp/', None),
        ]

        for testcase in testcases:
            self.assertEqual(testcase[1], parse_repo_url(testcase[0]))
示例#2
0
文件: req.py 项目: davidhalter/pydep
 def __init__(self, install_req):
     self._install_req = install_req
     if install_req.url is None:
         raise 'No URL found in install_req: %s' % str(install_req)
     self.url = parse_repo_url(install_req.url)
     self.metadata = None
     self.vcs = None
     if install_req.url.find('+') >= 0:
         self.vcs = install_req.url[:install_req.url.find('+')]
     self.setuptools_req = install_req.req  # may be None
示例#3
0
    def to_dict(self):
        repo_url, py_modules, packages = None, None, None
        if self.metadata is not None:
            if 'url' in self.metadata:
                repo_url = parse_repo_url(self.metadata['url'])
            if repo_url is None and 'download_url' in self.metadata:
                repo_url = parse_repo_url(self.metadata['download_url'])
            py_modules = self.metadata['py_modules'] if 'py_modules' in self.metadata else None
            packages = self.metadata['packages'] if 'packages' in self.metadata else None

        return {
            'type': 'setuptools',
            'resolved': (self.metadata is not None),
            'project_name': self.req.project_name,
            'unsafe_name': self.req.unsafe_name,
            'key': self.req.key,
            'specs': self.req.specs,
            'extras': self.req.extras,
            'repo_url': repo_url,
            'packages': packages,
            'modules': py_modules,
        }
示例#4
0
文件: req.py 项目: brynary/pydep
 def __init__(self, install_req):
     self._install_req = install_req
     if install_req.link is None:
         raise 'No URL found in install_req: %s' % str(install_req)
     self.url = parse_repo_url(install_req.link.url)
     self.metadata = None
     self.vcs = None
     self.type = 'vcs'
     if install_req.link.url.find('+') >= 0:
         self.vcs = install_req.link.url[:install_req.link.url.find('+')]
     elif self._archive_regex.match(install_req.link.url) is not None:
         self.type = 'archive'
     self.setuptools_req = install_req.req  # may be None
示例#5
0
文件: vcs_test.py 项目: brynary/pydep
    def test_parse_repo_url(self):
        testcases = [
            ('http://github.com/foo/bar', 'http://github.com/foo/bar'),
            ('https://github.com/foo/bar/baz', 'https://github.com/foo/bar'),
            ('git+https://github.com/foo/bar/baz', 'https://github.com/foo/bar'),
            ('git+git://github.com/foo/bar.git#egg=foo', 'git://github.com/foo/bar.git'),

            ('https://code.google.com/p/bar', 'https://code.google.com/p/bar'),
            ('https://code.google.com/p/bar/blah/blah', 'https://code.google.com/p/bar'),
            ('git+https://code.google.com/p/bar/blah/blah', 'https://code.google.com/p/bar'),
            ('git+git://code.google.com/p/bar.git#egg=foo', 'git://code.google.com/p/bar.git'),

            ('https://bitbucket.org/foo/bar', 'https://bitbucket.org/foo/bar'),
            ('https://bitbucket.org/foo/bar/baz', 'https://bitbucket.org/foo/bar'),
            ('hg+https://bitbucket.org/foo/bar', 'https://bitbucket.org/foo/bar'),
            ('git+git://bitbucket.org/foo/bar', 'git://bitbucket.org/foo/bar'),

            ('https://google.com', None),
        ]

        for testcase in testcases:
            self.assertEqual(testcase[1], parse_repo_url(testcase[0]))