|
| 1 | +import datasets |
| 2 | +import subprocess |
| 3 | + |
| 4 | +import requests |
| 5 | +from bs4 import BeautifulSoup |
| 6 | + |
| 7 | +def get_github_avatar(repo): |
| 8 | + """ |
| 9 | + Given a GitHub repo in the format 'owner/repo', get the avatar URL of the organization or user. |
| 10 | + """ |
| 11 | + try: |
| 12 | + org = repo.split("/")[0] |
| 13 | + # Construct the URL for the repo |
| 14 | + url = f"https://github.com/{org}" |
| 15 | + |
| 16 | + # Make a request to the page |
| 17 | + response = requests.get(url) |
| 18 | + |
| 19 | + # Check if the request was successful |
| 20 | + if response.status_code != 200: |
| 21 | + print(f"Failed to fetch page for {repo}. Status code: {response.status_code}") |
| 22 | + return None |
| 23 | + |
| 24 | + # Parse the HTML content using BeautifulSoup |
| 25 | + soup = BeautifulSoup(response.content, 'html.parser') |
| 26 | + |
| 27 | + # Find the meta tag with property "og:image" which contains the avatar URL |
| 28 | + meta_tag = soup.find('meta', property='og:image') |
| 29 | + |
| 30 | + if meta_tag and 'content' in meta_tag.attrs: |
| 31 | + avatar_url = meta_tag['content'] |
| 32 | + return avatar_url |
| 33 | + else: |
| 34 | + print(f"Avatar URL not found for {repo}") |
| 35 | + return None |
| 36 | + |
| 37 | + except Exception as e: |
| 38 | + print(f"An error occurred: {e}") |
| 39 | + return None |
| 40 | + |
| 41 | +d = datasets.load_dataset("wentingzhao/commit0_docstring", split="test") |
| 42 | + |
| 43 | +print(d) |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +print("| | Name | Repo | Commit0 | Tests | | ") |
| 48 | +print("|--|--------|-------|----|----|------| ") |
| 49 | +overload = { |
| 50 | + "simpy" : "https://simpy.readthedocs.io/en/4.1.1/_images/simpy-logo-small.png", |
| 51 | + "tinydb" : "https://raw.githubusercontent.com/msiemens/tinydb/master/artwork/logo.png", |
| 52 | + "bitstring": "https://bitstring.readthedocs.io/en/stable/_images/bitstring_logo.png", |
| 53 | + "seaborn": "https://raw.githubusercontent.com/mwaskom/seaborn/master/doc/_static/logo-wide-lightbg.svg", |
| 54 | + "statsmodels": "https://raw.githubusercontent.com/statsmodels/statsmodels/main/docs/source/images/statsmodels-logo-v2-horizontal.svg", |
| 55 | + "pyboy" : "https://github.com/Baekalfen/PyBoy/raw/master/extras/README/pyboy.svg", |
| 56 | +} |
| 57 | +skip = { |
| 58 | + "pyjwt", |
| 59 | + "wcwidth", |
| 60 | + "chardet", |
| 61 | + "dnspython", |
| 62 | + "imapclient", |
| 63 | + "pexpect", |
| 64 | + "dulwich", |
| 65 | + "voluptuous", |
| 66 | + "requests", |
| 67 | + "tlslite-ng", |
| 68 | + "more-itertools", |
| 69 | + "deprecated", |
| 70 | + "cachetools", |
| 71 | + "paramiko", |
| 72 | + "jedi", |
| 73 | + "sqlparse", |
| 74 | +} |
| 75 | +for i, ex in enumerate(d): |
| 76 | + img = get_github_avatar(ex["original_repo"]) |
| 77 | + |
| 78 | + name = ex["repo"].split("/")[1] |
| 79 | + result = subprocess.check_output(f"commit0 get-tests {name} | wc", shell=True, text=True) |
| 80 | + |
| 81 | + tests = int(result.split()[0]) |
| 82 | + if name.lower() not in skip and name.lower() not in overload: |
| 83 | + img = f"<img src='{img}' width='100px'/>" |
| 84 | + elif name.lower() in overload: |
| 85 | + img = f"<img src='{overload[name.lower()]}' width='100px'/>" |
| 86 | + else: |
| 87 | + img = f"<b>{name}</b>" |
| 88 | + print(f"| {img} | [{name}]({ex['setup']['specification']}) | [[orig](http://github.com/{ex['original_repo']})] | [[commit0](http://github.com/{ex['repo']})] | {tests} | <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAABkCAQAAADtJZLrAAAAD0lEQVR42mNkYGAcRcQhADxaAGWhD8eHAAAAAElFTkSuQmCC'/> |") |
0 commit comments