forked from lauris/awesome-scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lauris#485 from benash/improvements
Use GitHub Shields
- Loading branch information
Showing
7 changed files
with
1,449 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.8.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
name = "pypi" | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
[packages] | ||
pygithub = "*" | ||
|
||
[requires] | ||
python_version = "3.8" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# Usage: pipenv run python add-metadata.py < template.md > README.md | ||
|
||
import fileinput | ||
import os | ||
import re | ||
import sys | ||
|
||
from datetime import datetime, timedelta | ||
from github import Github | ||
|
||
g = Github(os.environ['GITHUB_TOKEN']) | ||
|
||
gh_repo_regex = re.compile('\[([\w\._-]+\/[\w\._-]+)\]\(@ghRepo\)') | ||
|
||
def github_table_row(repo): | ||
name = repo.name | ||
if repo.stargazers_count >= 500: | ||
name = f"**{name}**" | ||
|
||
project_link = f"[{name}]({repo.html_url})" | ||
stars_shield = f"![GitHub stars](https://img.shields.io/github/stars/{repo.full_name})" | ||
commit_shield = f"![GitHub commit activity](https://img.shields.io/github/commit-activity/y/{repo.full_name})" | ||
|
||
return f"{project_link} | {repo.description} | {stars_shield} {commit_shield}" | ||
|
||
|
||
def warn(str): | ||
print(f"Warn: {str}", file=sys.stderr) | ||
|
||
|
||
def retrieve_repo(name): | ||
repo = g.get_repo(name) | ||
print('.', file=sys.stderr, end='', flush=True) | ||
check_freshness(repo) | ||
return repo | ||
|
||
|
||
def check_freshness(repo): | ||
if repo.archived: | ||
warn(f"Repo {repo.full_name} is archived") | ||
elif repo.pushed_at < datetime.utcnow() - timedelta(days=180): | ||
warn(f"Repo {repo.full_name} has not been pushed to since {repo.pushed_at}") | ||
|
||
|
||
def parse(line): | ||
m = gh_repo_regex.search(line) | ||
if m: | ||
[repo_name] = m.groups() | ||
return github_table_row(retrieve_repo(repo_name)) | ||
else: | ||
return line.rstrip() | ||
|
||
|
||
def run(): | ||
print('<!--- This file is automatically generated. Do not edit directly. -->') | ||
for line in fileinput.input(): | ||
print(parse(line)) | ||
|
||
|
||
run() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.