Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warnings if nltk_data .zip files exist without any corresponding .xml files. #2908

Merged
merged 2 commits into from Dec 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions nltk/downloader.py
Expand Up @@ -167,6 +167,7 @@
import textwrap
import threading
import time
import warnings
import zipfile
from hashlib import md5
from xml.etree import ElementTree
Expand Down Expand Up @@ -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")
Expand Down