From abbe91cf86e4ef38118fb2f7277299ba260442db Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 4 Dec 2020 12:08:23 -0500 Subject: [PATCH] feat: generator --- bin/projects.py | 101 +++++++++++++++++++++++++++++++++++++++++++ bin/projects.yml | 93 +++++++++++++++++++++++++++++++++++++++ requirements-dev.txt | 1 + 3 files changed, 195 insertions(+) create mode 100755 bin/projects.py create mode 100644 bin/projects.yml diff --git a/bin/projects.py b/bin/projects.py new file mode 100755 index 00000000..8be4f4ce --- /dev/null +++ b/bin/projects.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python3 + +import json +from typing import Dict, Any, List + +import click +import requests +import yaml + + +def get_info(gh: str) -> Dict[str, Any]: + url = f"https://api.github.com/repos/{gh}" + req = requests.get(url) + return json.loads(req.content) + + +class Project: + NAME: int = 0 + STARS: int = 0 + NOTES: int = 5 + + def __init__(self, config: Dict[str, Any]): + self.name: str = config["name"] + self.gh: str = config["gh"] + self.stars_repo: str = config.get("stars", self.gh) + self.notes: str = config.get("notes", "") + self.ci: List[str] = config.get("ci", []) + self.os: List[str] = config.get("os", []) + + info = get_info(self.stars_repo) + self.num_stars = info["stargazers_count"] + + name_len = len(self.name) + 4 + stars_len = name_len + 6 + + self.__class__.NAME = max(self.__class__.NAME, name_len) + self.__class__.STARS = max(self.__class__.STARS, stars_len) + + def __lt__(self, other: "Project") -> bool: + return self.num_stars < other.num_stars + + @classmethod + def header(cls): + return ( + f"| {'Name':{cls.NAME}} | {'Stars':{cls.STARS}} | {'Notes':{cls.NOTES}} |\n" + f"|{'':-^{cls.NAME+2}}|{'':-^{cls.STARS+2}}|:{'':-^{cls.NOTES+1}}|" + ) + + @property + def namelink(self) -> str: + return f"[{self.name}][]" + + @property + def starslink(self) -> str: + return f"[{self.name} stars][]" + + @property + def url(self) -> str: + return f"https://github.com/{self.gh}" + + @property + def starsimg(self) -> str: + return f"https://img.shields.io/github/stars/{self.gh}label=%20&style=social" + + def table_row(self) -> str: + return f"| {self.namelink: <{self.NAME}} | {self.starslink: <{self.STARS}} | {self.notes: <{self.NOTES}} |" + + def links(self) -> str: + return f"[{self.name}]: {self.url}\n" f"[{self.name} stars]: {self.starsimg}" + + def info(self) -> str: + return f"" + + +def print_projects(config: List[Dict[str, Any]], *, debug: bool = False) -> None: + projects = sorted((Project(item) for item in config), reverse=True) + + print(Project.header()) + for project in projects: + print(project.table_row()) + + print() + for project in projects: + print(project.links()) + + if debug: + print() + for project in projects: + print(project.info()) + + +@click.command() +@click.argument("input", type=click.File("r")) +@click.option("--debug/--no-debug") +def projects(input, debug): + config = yaml.safe_load(input) + print_projects(config, debug=debug) + + +if __name__ == "__main__": + projects() diff --git a/bin/projects.yml b/bin/projects.yml new file mode 100644 index 00000000..73127f93 --- /dev/null +++ b/bin/projects.yml @@ -0,0 +1,93 @@ +# Fields: +# name: required, printed name +# gh: Github repo (eventually a url: could be added for non-github projects) +# stars: Github repo (optional, if different from package, such as for Twisted) +# os: Operating system list, [windows, macos, linux] (optional) +# ci: [appveyor, github, azure-pipelines, circleci, gitlab, travisci] (optional) +# notes: (text, optional) + +- name: Matplotlib + gh: matplotlib/matplotlib + notes: The venerable Matplotlib, a Python library with C++ portions + ci: [github] + os: [windows, macos, linux] + +- name: pyinstrument_cext + gh: joerick/pyinstrument_cext + ci: [travisci, appveyor] + notes: A simple C extension, without external dependencies + +- name: websockets + gh: aaugustin/websockets + +- name: Parselmouth + gh: YannickJadoul/Parselmouth + notes: A Python interface to the Praat software package, using pybind11, C++17 and CMake, with the core Praat static library built only once and shared between wheels. + ci: [github] + os: [windows, macos, linux] + +- name: python-admesh + gh: admesh/python-admesh + +- name: pybase64 + gh: mayeut/pybase64 + +- name: KDEpy + gh: tommyod/KDEpy + +- name: AutoPy + gh: autopilot-rs/autopy + +- name: apriltags2-ethz + gh: safijari/apriltags2_ethz + +- name: TgCrypto + gh: pyrogram/tgcrypto + +- name: twisted-iocpsupport + gh: twisted/twisted-iocpsupport + stars: twisted/twisted + notes: A submodule of Twisted that hooks into native C APIs using Cython. + ci: [github] + os: [windows] + +- name: gmic-py + gh: dtschump/gmic-py + +- name: creme + gh: creme-ml/creme + +- name: PyAV + gh: PyAV-Org/PyAV + +- name: aiortc + gh: aiortc/aiortc + +- name: aioquic + gh: aiortc/aioquic + +- name: pikepdf + gh: pikepdf/pikepdf + +- name: fathon + gh: stfbnc/fathon + +- name: etebase-py + gh: etesync/etebase-py + notes: Python bindings to a Rust library using `setuptools-rust`, and `sccache` for improved speed. + ci: [travisci] + +- name: xmlstarlet + gh: dimitern/xmlstarlet + notes: Python 3.6+ CFFI bindings with true MSVC build. + ci: [github] + +- name: bx-python + gh: bxlab/bx-python + notes: A library that includes Cython extensions. + ci: [travisci] + os: [macos, linux] + +- name: coverage.py + gh: nedbat/coveragepy + notes: The coverage tool for Python diff --git a/requirements-dev.txt b/requirements-dev.txt index e6129684..a4417881 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,4 +7,5 @@ pip-tools requests click mypy +pyyaml typing-extensions