def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'): repo_url = self.project.repo if 'bitbucket' not in repo_url: return '' if not docroot: return '' # Normalize /docroot/ docroot = '/' + docroot.strip('/') + '/' user, repo = get_bitbucket_username_repo(repo_url) if not user and not repo: return '' repo = repo.rstrip('/') if not filename: # If there isn't a filename, we don't need a suffix source_suffix = '' return BITBUCKET_URL.format( user=user, repo=repo, version=self.commit_name, docroot=docroot, path=filename, source_suffix=source_suffix, )
def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'): repo_url = self.project.repo if 'bitbucket' not in repo_url: return '' if not docroot: return '' # Normalize /docroot/ docroot = '/' + docroot.strip('/') + '/' user, repo = get_bitbucket_username_repo(repo_url) if not user and not repo: return '' if not filename: # If there isn't a filename, we don't need a suffix source_suffix = '' return BITBUCKET_URL.format( user=user, repo=repo, version=self.commit_name, docroot=docroot, path=filename, source_suffix=source_suffix, )
def get_bitbucket_url(self, docroot, filename, source_suffix=".rst"): repo_url = self.project.repo if "bitbucket" not in repo_url: return "" if not docroot: return "" for regex in BITBUCKET_REGEXS: match = regex.search(repo_url) if match: user, repo = match.groups() break else: return "" repo = repo.rstrip("/") return BITBUCKET_URL.format( user=user, repo=repo, version=self.remote_slug, docroot=docroot, path=filename, source_suffix=source_suffix )
def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'): repo_url = self.project.repo if 'bitbucket' not in repo_url: return '' if not docroot: return '' user, repo = get_bitbucket_username_repo(repo_url) if not user and not repo: return '' repo = repo.rstrip('/') return BITBUCKET_URL.format( user=user, repo=repo, version=self.commit_name, docroot=docroot, path=filename, source_suffix=source_suffix, )
def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'): repo_url = self.project.repo if 'bitbucket' not in repo_url: return '' if not docroot: return '' for regex in BITBUCKET_REGEXS: match = regex.search(repo_url) if match: user, repo = match.groups() break else: return '' repo = repo.rstrip('/') return BITBUCKET_URL.format( user=user, repo=repo, version=self.commit_name, docroot=docroot, path=filename, source_suffix=source_suffix, )