Skip to content

Commit

Permalink
renaming (#228)
Browse files Browse the repository at this point in the history
* renaming

* fix more strings
  • Loading branch information
malmans2 authored Oct 10, 2024
1 parent 26b5cc5 commit d5abad1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ repos:
exclude: ^templates/
- repo: local
hooks:
- id: fix-legacy-urls
name: fix-legacy-urls
entry: python scripts/fix-legacy-urls.py
- id: fix-markdown-strings
name: fix-markdown-strings
entry: python scripts/fix-markdown-strings.py
language: python
types: [jupyter]
additional_dependencies: [nbformat]
- repo: local
hooks:
- id: validate-headers
name: validate-headers
entry: python scripts/validate-headers.py
- id: validate-headings
name: validate-headings
entry: python scripts/validate-headings.py
language: python
types: [jupyter]
additional_dependencies: [nbformat]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

STRING_MAPPER = {
"/cdsapp#!/dataset/": "/datasets/",
"## Use case:": "## 🌍 Use case:",
"## Quality assessment question": "## ❓ Quality assessment question",
"## Quality assessment statement": "## 📢 Quality assessment statement",
"## Methodology": "## 📋 Methodology",
"## Analysis and results": "## 📈 Analysis and results",
"## If you want to know more": "## ℹ️ If you want to know more",
}


Expand Down
14 changes: 7 additions & 7 deletions scripts/validate-headers.py → scripts/validate-headings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import nbformat

HEADERS = (
HEADINGS = (
"## 🌍 Use case:",
"## ❓ Quality assessment question",
"## 📢 Quality assessment statement",
Expand All @@ -17,7 +17,7 @@ def validate_headers(path: Path) -> None:
notebook = nbformat.read(path, nbformat.NO_CONVERT)

title_count = 0
headers_count = dict.fromkeys(HEADERS, 0)
headings_count = dict.fromkeys(HEADINGS, 0)
for cell in notebook.cells:
if cell["cell_type"] != "markdown":
continue
Expand All @@ -28,16 +28,16 @@ def validate_headers(path: Path) -> None:
title_count += 1
continue

for header in headers_count:
if line.startswith(header):
headers_count[header] += 1
for heading in headings_count:
if line.startswith(heading):
headings_count[heading] += 1
break
else:
assert not line.startswith("## "), f"{path=!s}: Invalid H2 {line=}"

assert title_count == 1, f"{path=!s}: Invalid {title_count=}"
for header, header_count in headers_count.items():
assert header_count == 1, f"{path=!s}: Invalid {header_count=} of {header=}"
for heading, header_count in headings_count.items():
assert header_count == 1, f"{path=!s}: Invalid {header_count=} of {heading=}"


def main(paths: list[Path]) -> None:
Expand Down

0 comments on commit d5abad1

Please sign in to comment.