Ejemplo n.º 1
0
        A handle to the github user is obtained by calling
        github.get_user(username)

        Keyword arguments:
        username -- The Github username.
        """
        super().__init__(username)
        self.github = Github()
        self.user = self.github.get_user(username)

    def get_repos(self):
        """Wrapper around github.get_repos()."""
        # Obtain a list of github repos of the user
        g_repos = self.user.get_repos()
        repos = []

        # Iterate over the list of "github repos" and
        # prepare a list of "repos" with properties of interest initialised.
        for g_repo in g_repos:
            raw_base_url = 'http://github.com/' + g_repo.full_name + '/blob/' + g_repo.default_branch + '/'
            repo_url = 'http://github.com/' + g_repo.full_name
            repos.append(
                repobase.Repo(g_repo.full_name, raw_base_url, repo_url,
                              g_repo.default_branch, g_repo.fork))
        return repos


# Register this Github repo provider with ghlicense
repobase.register_provider("github", GitHubProvider, PROVIDER_PLUGIN_LOADED)
Ejemplo n.º 2
0
from ghlicense import repobase

PROVIDER_PLUGIN_LOADED = True

try:
    from github import Github
except:
    PROVIDER_PLUGIN_LOADED = False

class GitHubProvider(repobase.Provider):
    def __init__(self, username):
        self.g = Github()
        self.user = self.g.get_user(username)
    
    def get_repos(self):
        g_repos = self.user.get_repos()
        repos = []
        for g_repo in g_repos:
            raw_base_url = 'http://github.com/' + g_repo.full_name + '/blob/' + g_repo.default_branch + '/'
            repo_url = 'http://github.com/' + g_repo.full_name
            repos.append(repobase.Repo(g_repo.full_name, raw_base_url, repo_url, g_repo.default_branch, g_repo.fork))
        return repos

repobase.register_provider("github", GitHubProvider, PROVIDER_PLUGIN_LOADED)
Ejemplo n.º 3
0
except:
    PROVIDER_PLUGIN_LOADED = False


class BitBucketProvider(repobase.Provider):
    def __init__(self, username):
        self.bb = Bitbucket()
        self.username = username

    def get_repos(self):
        self.bb_repos_resp = self.bb.repository.public(self.username)
        if not self.bb_repos_resp[0]:
            print("ERROR: BitBucket username not found!")
            sys.exit(1)
        self.bb_repos = self.bb_repos_resp[1]

        repos = []
        for bb_repo in self.bb_repos:
            full_name = self.username + "/" + bb_repo['slug']
            default_branch = "master"
            raw_base_url = 'http://bitbucket.com/' + full_name + '/raw/' + default_branch + '/'
            repo_url = 'http://bitbucket.com/' + full_name
            repos.append(
                repobase.Repo(full_name, raw_base_url, repo_url,
                              default_branch, bb_repo['is_fork']))
        return repos


repobase.register_provider("bitbucket", BitBucketProvider,
                           PROVIDER_PLUGIN_LOADED)
Ejemplo n.º 4
0
PROVIDER_PLUGIN_LOADED = True

try:
    from bitbucket.bitbucket import Bitbucket
except:
    PROVIDER_PLUGIN_LOADED = False

class BitBucketProvider(repobase.Provider):
    def __init__(self, username):
        self.bb = Bitbucket()
        self.username = username
    
    def get_repos(self):
        self.bb_repos_resp = self.bb.repository.public(self.username)
        if not self.bb_repos_resp[0]:
            print("ERROR: BitBucket username not found!")
            sys.exit(1)
        self.bb_repos = self.bb_repos_resp[1]
        
        repos = []
        for bb_repo in self.bb_repos:
            full_name = self.username + "/" + bb_repo['slug']
            default_branch = "master"
            raw_base_url = 'http://bitbucket.com/' + full_name + '/raw/' + default_branch + '/'
            repo_url = 'http://bitbucket.com/' + full_name
            repos.append(repobase.Repo(full_name, raw_base_url, repo_url, default_branch, bb_repo['is_fork']))
        return repos


repobase.register_provider("bitbucket", BitBucketProvider, PROVIDER_PLUGIN_LOADED)