Skip to content

Commit fc6cbbf

Browse files
committed
Fix collate script.
1 parent 95688d6 commit fc6cbbf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

uc_python/collate.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1+
import shutil
12
from pathlib import Path
23

34
folder = Path("repos")
4-
site = Path("site")
5+
site = Path("site").absolute()
56
site.mkdir(exist_ok=True)
7+
subfolders = [f for f in site.glob("*") if f.is_dir()]
8+
for s in subfolders:
9+
print(f"deleting {s}")
10+
shutil.rmtree(s)
611

712
# Build an index as we go
813
index = site / "index.html"
914
index.write_text("<h1>UC Python Slides</h1>")
1015
for repo in folder.glob("*"):
11-
(repo / "slides").rename(site / repo.name)
12-
index.write_text(f'<a href="/{repo.name}">{repo.name}</a>')
16+
slides_dir = (repo / "slides")
17+
if not slides_dir.exists():
18+
print(f"no slides in {slides_dir}, skipping")
19+
continue
20+
slides_dir.rename(site / repo.name)
21+
index.write_text(f'<a href="/{repo.name}">{repo.name}</a>\n')

0 commit comments

Comments
 (0)