Skip to content

Commit

Permalink
Merge pull request lauris#485 from benash/improvements
Browse files Browse the repository at this point in the history
Use GitHub Shields
  • Loading branch information
SethTisue authored Sep 14, 2020
2 parents 9288f57 + d2584fd commit 333937e
Show file tree
Hide file tree
Showing 7 changed files with 1,449 additions and 622 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8.2
12 changes: 12 additions & 0 deletions Pipfile
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"
84 changes: 84 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

888 changes: 484 additions & 404 deletions README.md

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions add-metadata.py
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()
218 changes: 0 additions & 218 deletions metadata.py

This file was deleted.

Loading

0 comments on commit 333937e

Please sign in to comment.