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
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 self.type = 'vcs' if install_req.url.find('+') >= 0: self.vcs = install_req.url[:install_req.url.find('+')] elif re.compile(r'^(http|https)://[^/]+/.+\.(zip|tar)(\.gz|)$', re.IGNORECASE).match(install_req.url) is not None: self.type = 'archive' self.setuptools_req = install_req.req # may be None
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']) if repo_url is None and self.req.key in _hardcoded_repo_urls: repo_url = _hardcoded_repo_urls[self.req.key] 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, }
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]))