def get_github_organization_plugins(self, organization, no_forks=False):
"""
Returns a dict with all plugins from a GitHub organization
inspired from: https://gist.github.com/ralphbean/5733076
:param organization: GitHub organization name
:param no_forks: include / not include forks
"""
plugins_dict = OrderedDict()
try:
gh = github.Github()
all_repos = gh.get_organization(organization).get_repos()
except github.RateLimitExceededException:
raise IRException("Github API rate limit exceeded")
for repo in all_repos:
try:
# Don't print the urls for repos that are forks.
if no_forks and repo.fork:
continue
spec_file = repo.get_contents('plugin.spec').decoded_content
plugin = SpecValidator.validate_from_content(spec_file)
plugin_name = plugin["subparsers"].keys()[0]
plugin_src = repo.clone_url
plugin_type = plugin["config"]["plugin_type"] \
if "config" in plugin \
else plugin["plugin_type"]
plugin_desc = plugin["description"] \
if "description" in plugin \
and plugin["description"] is not None \
else "-"
if plugin_type not in plugins_dict:
plugins_dict[plugin_type] = {}
plugins_dict[plugin_type][plugin_name] = {
"src": plugin_src,
"desc": plugin_desc,
}
except github.RateLimitExceededException:
raise IRException("Github API rate limit exceeded")
except Exception:
# skip repo failures
continue
return plugins_dict
评论列表
文章目录