Skip to content

Commit d26a6b9

Browse files
committed
Test speaker names
1 parent fe0f243 commit d26a6b9

File tree

6 files changed

+65
-17
lines changed

6 files changed

+65
-17
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
name: CI
22

3-
on:
4-
push:
5-
branches: main
6-
pull_request:
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
env:
6+
FORCE_COLOR: 1
7+
PIP_DISABLE_PIP_VERSION_CHECK: 1
78

89
jobs:
910
test:
1011
runs-on: ubuntu-latest
1112

1213
steps:
13-
- uses: actions/checkout@v4
14+
- uses: actions/checkout@v5
1415

1516
- name: Set up Python
16-
uses: actions/setup-python@v5
17+
uses: actions/setup-python@v6
1718
with:
18-
python-version: 3.12
19+
python-version: 3.x
1920

2021
- name: Install
2122
run: make install-deps

.schemas/pathschema

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ tools/
1818

1919
.gitignore
2020
.editorconfig
21-
.travis.yml
2221
CONTRIBUTING.rst
2322
CONTRIBUTORS_WITHOUT_COMMITS.rst
2423
LICENSE

.tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ jsonschema
44
pathschema
55
pygments
66
six
7+
termcolor
78
unidecode

.tests/speaker_names.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import argparse
2+
import json
3+
import sys
4+
5+
from termcolor import colored, cprint
6+
7+
from tools.utils import get_json_files
8+
9+
10+
def check_speaker_names(data_root, verbose=False):
11+
_, video_paths = get_json_files(data_root)
12+
13+
invalid_names = []
14+
# Map of disallowed speaker names to their correct replacements
15+
replacements = {
16+
"Glyph Lefkowitz": "Glyph",
17+
}
18+
19+
for video_path in video_paths:
20+
with open(video_path, encoding="UTF-8") as fp:
21+
video_blob = json.load(fp)
22+
speakers = video_blob.get("speakers", [])
23+
24+
for speaker in speakers:
25+
if speaker in replacements:
26+
invalid_names.append((video_path, speaker, replacements[speaker]))
27+
28+
if invalid_names:
29+
cprint("Disallowed speaker names found:", "red")
30+
for path, speaker, replacement in invalid_names:
31+
speaker = colored(speaker, "red")
32+
print(f"\t{path}: {speaker}")
33+
print(f"\t\tUse {colored(replacement, 'green')} instead of {speaker}")
34+
sys.exit(1)
35+
36+
37+
def main():
38+
parser = argparse.ArgumentParser()
39+
parser.add_argument("-d", "--data-root",
40+
help="directory to search for JSON files")
41+
parser.add_argument("-v", "--verbose",
42+
type=int,
43+
help="increase output verbosity")
44+
args = parser.parse_args()
45+
46+
check_speaker_names(args.data_root, verbose=args.verbose)
47+
48+
49+
if __name__ == '__main__':
50+
main()

.travis.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ help:
2525
@echo ' '
2626

2727
.venv:
28-
python3 -m venv $(VENV)
28+
python3 -m venv $(VENV) --upgrade-deps
2929

3030
install-deps: .venv
3131
$(BIN)/pip install -r $(TESTSDIR)/requirements.txt
@@ -54,6 +54,9 @@ test-languages: install-deps
5454
test-filename-length: install-deps
5555
$(PYTHON) $(TESTSDIR)/filename_length.py -d $(BASEDIR) -v $(VERBOSE)
5656

57-
test: test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length
57+
test-speaker-names: install-deps
58+
$(PYTHON) $(TESTSDIR)/speaker_names.py -d $(BASEDIR) -v $(VERBOSE)
5859

59-
.PHONY: help test test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages
60+
test: test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length test-speaker-names
61+
62+
.PHONY: help test test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages test-speaker-names

0 commit comments

Comments
 (0)