本文整理汇总了Python中github3.GitHub.iter_repos方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.iter_repos方法的具体用法?Python GitHub.iter_repos怎么用?Python GitHub.iter_repos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github3.GitHub
的用法示例。
在下文中一共展示了GitHub.iter_repos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: str
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import iter_repos [as 别名]
offset = "0"
else:
offset = ""
v['sortbydate'] = str(v["startDate"]["year"]) + offset + str(v["startDate"]["month"])
sorted(values,key=lambda x: x["sortbydate"])
map(lambda x: x.pop("sortbydate"),values)
return values
def get_github_data():
try:
oauth_user=parser.get('github','user')
oauth_user_token=parser.get('github','oauth')
except NoSectionError,NoOptionError:
return None
gh = GitHub(oauth_user,token=oauth_user_token)
repos = list(gh.iter_repos())
repo_data = {}
for r in repos:
repo_name = getattr(r,'name')
current_repo = r.__dict__
new_repo = {}
new_repo['full_name'] = current_repo['full_name']
new_repo['url'] = current_repo['html_url']
repo_data[repo_name] = new_repo
return repo_data
def old_get_github_data():
oauth_user_token=parser.get('github','oauth_key')
oauth_user_secret=parser.get('github','oauth_secret')
示例2: run
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import iter_repos [as 别名]
def run():
# cli flags
upstream_on = args.flags.contains('--upstream')
only_type = args.grouped.get('--only', False)
organization = args[0]
os.chdir(GHSYNC_DIR)
# API Object
github = GitHub(login=GITHUB_USER, token=GITHUB_TOKEN)
# repo slots
repos = {}
if not organization:
repos['watched'] = [r for r in github.iter_subscribed()]
repos['private'] = []
repos['mirrors'] = []
repos['public'] = []
repos['forks'] = []
# Collect GitHub repos via API
for repo in github.iter_repos(organization):
if repo.is_private():
repos['private'].append(repo)
elif repo.is_fork():
repos['forks'].append(repo)
elif ('mirror' in repo.description.lower()) or (repo.source):
# mirrors owned by self if mirror in description...
repos['mirrors'].append(repo)
else:
repos['public'].append(repo)
for org, repos in repos.iteritems():
for repo in repos:
# create org directory (safely)
try:
os.makedirs(org)
except OSError:
pass
# enter org dir
os.chdir(org)
# I own the repo
is_private = (org in ('private', 'forks', 'mirror', 'public'))
is_fork = (org == 'forks')
if is_fork:
repo.refresh()
if not only_type or (org in only_type):
# just `git pull` if it's already there
if os.path.exists(repo.name):
os.chdir(repo.name)
puts(colored.red('Updating repo: {0.name}'.format(repo)))
os.system('git pull')
if is_fork and upstream_on:
#print repo.__dict__
puts(colored.red(
'Adding upstream: {0.parent}'.format(repo)))
os.system('git remote add upstream {0}'.format(
repo.parent.git_url
))
os.chdir('..')
else:
if is_private:
puts(colored.red(
'Cloning private repo: {repo.name}'.format(
repo=repo)))
os.system('git clone {0}'.format(repo.ssh_url))
print('git clone {0}'.format(repo.ssh_url))
if is_fork and upstream_on:
os.chdir(repo.name)
puts(colored.red('Adding upstream: {0}'.format(
repo.parent.name
)))
os.system('git remote add upstream {0}'.format(
repo.parent.git_url
))
os.chdir('..')
else:
puts(colored.red('Cloning repo: {repo.name}'.format(
repo=repo)))
os.system('git clone {0}'.format(repo.git_url))
print ('git clone {0}'.format(repo.git_url))
# return to base
os.chdir('..')