本文整理汇总了Python中github3.GitHub.search_repositories方法的典型用法代码示例。如果您正苦于以下问题:Python GitHub.search_repositories方法的具体用法?Python GitHub.search_repositories怎么用?Python GitHub.search_repositories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github3.GitHub
的用法示例。
在下文中一共展示了GitHub.search_repositories方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import search_repositories [as 别名]
class GithubSearch:
def __init__(self, query, language, user, password):
self.query = query
self.language = language
self.user = user
self.password = password
self.g = GitHub(self.user, self.password)
def search(self, num_results = 2):
return self.g.search_repositories(self.query + " language:" + self.language, number=num_results)
示例2: get_gh_repos
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import search_repositories [as 别名]
def get_gh_repos(user, repo_count):
"""
Get a user's repositories with a limit
:param user:
:param repo_count:
:return:
"""
repos = None
if user and repo_count:
try:
gh = GitHub()
repo_limit = int(repo_count) if repo_count else 5
repos = list(map(lambda r: r.repository, list(gh.search_repositories(
'user:' + user, sort='updated'))[:repo_limit]))
except GitHubError:
repos = None
return repos
示例3: generate
# 需要导入模块: from github3 import GitHub [as 别名]
# 或者: from github3.GitHub import search_repositories [as 别名]
def generate():
settings = json.load(open('settings.json'))
# Get all filenames
pages = _sorted_list_dir(os.path.join('content', 'pages'))
articles = _sorted_list_dir(os.path.join('content', 'articles'))
files = pages + articles
# BEGIN: Parse files
loader = jn.FileSystemLoader(os.path.join(os.getcwd(), 'templates'))
env = jn.Environment(loader=loader)
# Add GitHub repos
repos = None
if settings.get('github_user') and settings.get('github_repo_count'):
try:
gh = GitHub()
repo_limit_maybe = settings.get('github_repo_count')
repo_limit = int(repo_limit_maybe) if repo_limit_maybe else 5
repos = list(map(lambda r: r.repository, list(gh.search_repositories(
'user:' + settings['github_user'], sort='updated'))[:repo_limit]))
except GitHubError:
repos = None
print(
'GitHub search repositories error. Check "github_user" in settings.json')
print(' - Parsing articles and pages')
for f in files:
fp = f.open()
file_no_ext = f.name.split('.')[0]
rest, data = parse_metadata(fp)
html = markdown.markdown(''.join(rest))
target = data.get('layout') + 's'
target_dir = os.path.join('output', target)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
# Create file in output direction
layout = data.get('layout')
template = env.get_template(layout + '.html')
data['content'] = html
data['url'] = target + '/' + file_no_ext + '.html'
data['site'] = settings
data['site']['recent_articles'] = get_recent_articles(articles)
if repos:
data['gh_repos'] = repos
page = template.render(data) # Date and other things
file_out = open(
os.path.join('output', target, file_no_ext + '.html'), 'w')
file_out.write(page)
file_out.close()
# Copy index
print(' - Parsing index page')
parse_index(os.path.join('content', 'index.md'), {
'env': env,
'settings': settings,
'articles': articles,
'repos': repos
})
# END: Parse files
# Copy static directory
print(' - Generating static directory')
static = os.path.join('output', 'static')
if os.path.exists(static):
shutil.rmtree(static)
_copy_directory('static', os.path.join('output', 'static'))