From 645f89d29006956c272f85b4357532063e302f49 Mon Sep 17 00:00:00 2001 From: Jordan Matelsky Date: Fri, 22 Mar 2024 10:37:52 -0400 Subject: [PATCH] Add workflow to make table --- .github/workflows/website.py | 45 +++++++++++++++++++++++++++++++++++ .github/workflows/website.yml | 22 +++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/website.py create mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/website.py b/.github/workflows/website.py new file mode 100644 index 0000000..ecd584a --- /dev/null +++ b/.github/workflows/website.py @@ -0,0 +1,45 @@ +#%% +# !pip3 install pandas +import pandas as pd +import re + +def to_link_if_markdown(cell_text: str) -> str: + # Matches [alt](url) with regex and converts to html : + cell_text = re.sub(r'\[(.*?)\]\((.*?)\)', r'\1', cell_text) + return cell_text + +text = open("../../README.md", "r").readlines() +table = [] +# | Year | Paper | Topic | Animal | Model? | Data? | Image/Video Count | +for line in text: + # If line has the correct number of columns + if len(re.findall("\|", line)) == 8: + table.append(line.split("|")[1:-1]) +table = pd.DataFrame(table[2:], columns=table[0]) + +# Substitutions: +table = table.applymap(to_link_if_markdown) + + +# %% +with open("index.html", "w") as f: + f.write(""" + + + + + + + +

Awesome Computational Primatology

+

Parodi et al., 2024

+ """) + f.write(table.to_html(table_id="table", escape=False, index=False)) + f.write(""" + + """) +# %% diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml new file mode 100644 index 0000000..6dfb3da --- /dev/null +++ b/.github/workflows/website.yml @@ -0,0 +1,22 @@ +name: Build Website + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Install dependencies + run: pip install pandas + - name: Run website.py + run: python .github/workflows/website.py + - uses: stefanzweifel/git-auto-commit-action@v5