本文整理汇总了Python中github3.GitHub.iter_subscribed方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.iter_subscribed方法的具体用法?Python GitHub.iter_subscribed怎么用?Python GitHub.iter_subscribed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github3.GitHub
的用法示例。
在下文中一共展示了GitHub.iter_subscribed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import iter_subscribed [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('..')