From bbf456c1f67328a1ce1cb5e2ca98b83299f11ec6 Mon Sep 17 00:00:00 2001 From: Tom Aarsen Date: Fri, 10 Dec 2021 12:55:03 +0100 Subject: [PATCH] Added warnings if .zip files exist without any corresponding .csv files. --- nltk/downloader.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nltk/downloader.py b/nltk/downloader.py index e513435a5a..d8b8db08ac 100644 --- a/nltk/downloader.py +++ b/nltk/downloader.py @@ -167,6 +167,7 @@ import textwrap import threading import time +import warnings import zipfile from hashlib import md5 from xml.etree import ElementTree @@ -2448,6 +2449,18 @@ def _find_packages(root): ) yield pkg_xml, zf, relpath + + elif filename.endswith(".zip"): + # Warn user in case a .xml does not exist for a .zip + resourcename = os.path.splitext(filename)[0] + xmlfilename = os.path.join(dirname, resourcename + ".xml") + if not os.path.exists(xmlfilename): + warnings.warn( + f"{filename} exists, but {resourcename + '.xml'} cannot be found! " + f"This could mean that {resourcename} can not be downloaded.", + stacklevel=2, + ) + # Don't recurse into svn subdirectories: try: subdirs.remove(".svn")