From cf7d55ce2496df22e37d7e25ea287e0fca58b571 Mon Sep 17 00:00:00 2001 From: Jon Banafato Date: Fri, 29 Aug 2025 12:43:09 -0400 Subject: [PATCH 1/2] Validate directory layout with pathschema This is a first pass at validating the PyVideo data directory layout with a schema validation tool. The included schema validates the data project as a whole and could be simplified by restructuring the repository to move data into a non-root directory to avoid the need to validate the existence of any other directories. This would be a good next step and require a coordinated change with the pyvideo/pyvideo repository. Resolves #1125. --- .schemas/pathschema | 37 +++++++++++++++++++++++++++++++++++++ .tests/requirements.txt | 3 ++- Makefile | 7 +++++-- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 .schemas/pathschema diff --git a/.schemas/pathschema b/.schemas/pathschema new file mode 100644 index 0000000000..fb4a879a3b --- /dev/null +++ b/.schemas/pathschema @@ -0,0 +1,37 @@ +.git/ + ... + +.github/ + ... + +.schemas/ + ... + +.tests/ + ... + +.venv/ + ... + +tools/ + ... + +.gitignore +.editorconfig +.travis.yml +CONTRIBUTING.rst +CONTRIBUTORS_WITHOUT_COMMITS.rst +LICENSE +Makefile +NO_PUBLISH.json +README.rst +redirects.txt + +*/ + +category.json + +videos/ + +*.json + +* +*/ + ... diff --git a/.tests/requirements.txt b/.tests/requirements.txt index 4fff00e6ab..ee44f5a75f 100644 --- a/.tests/requirements.txt +++ b/.tests/requirements.txt @@ -1,6 +1,7 @@ docutils jinja2 jsonschema +pathschema +pygments six unidecode -pygments diff --git a/Makefile b/Makefile index 3dfef9f035..644f8f9794 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,9 @@ help: install-deps: .venv $(BIN)/pip install -r $(TESTSDIR)/requirements.txt +test-directory-schemas: install-deps + $(PYTHON) -m pathschema $(SCHEMASDIR)/pathschema $(BASEDIR) --errors-only + test-schemas: install-deps $(PYTHON) $(TESTSDIR)/schemas.py -d $(BASEDIR) -s $(SCHEMASDIR) -v $(VERBOSE) @@ -51,6 +54,6 @@ test-languages: install-deps test-filename-length: install-deps $(PYTHON) $(TESTSDIR)/filename_length.py -d $(BASEDIR) -v $(VERBOSE) -test: test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length +test: test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length -.PHONY: help test test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages +.PHONY: help test test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages From 0faf6af4b6c51d57dc65a0aa2017b2e3cbd5b583 Mon Sep 17 00:00:00 2001 From: Jon Banafato Date: Fri, 29 Aug 2025 13:35:15 -0400 Subject: [PATCH 2/2] Remove unused files from videos directories to satisfy directory schema --- pycon-cz-2016/videos/private-video.yaml | 10 -------- pycon-jp-2019/videos/pyvideo-fix.py | 32 ------------------------- 2 files changed, 42 deletions(-) delete mode 100644 pycon-cz-2016/videos/private-video.yaml delete mode 100644 pycon-jp-2019/videos/pyvideo-fix.py diff --git a/pycon-cz-2016/videos/private-video.yaml b/pycon-cz-2016/videos/private-video.yaml deleted file mode 100644 index f32f8b5551..0000000000 --- a/pycon-cz-2016/videos/private-video.yaml +++ /dev/null @@ -1,10 +0,0 @@ -description: This video is private. -duration: 0 -recorded: '' -speakers: [] -thumbnail_url: -title: Private video -videos: -- type: youtube - url: https://www.youtube.com/watch?v=IBhSEN37jiY - diff --git a/pycon-jp-2019/videos/pyvideo-fix.py b/pycon-jp-2019/videos/pyvideo-fix.py deleted file mode 100644 index dc707f7d9f..0000000000 --- a/pycon-jp-2019/videos/pyvideo-fix.py +++ /dev/null @@ -1,32 +0,0 @@ -import glob -import json - -for fn in glob.glob('*.json'): - with open(fn) as f: - print(fn) - v = json.loads(f.read()) - title = v['title'] - - event_tag = " (Pyohio 2019)" - if title[len(title)-len(event_tag):] == event_tag: - title = title[:len(title)-len(event_tag)] - try: - title, speakers = title.rsplit(' - ', 1) - except ValueError: - title = title.rstrip(' - ') - speakers = None - title = title.strip('\"') - title = title.rstrip('\"') - - if speakers: - speakers = speakers.split(', ') - - print('Title was: ' + v['title']) - print('\tTitle is: ' + title) - print('\tAuthor is: ' + str(speakers)) - - v['title'] = title - v['speakers'] = speakers - - with open(fn, 'w') as f: - f.write(json.dumps(v))