Skip to content

Commit

Permalink
Added warnings if .zip files exist without any corresponding .csv fil…
Browse files Browse the repository at this point in the history
…es. (#2908)
  • Loading branch information
tomaarsen committed Dec 15, 2021
1 parent dea7b44 commit 72d9885
Showing 1 changed file with 13 additions and 0 deletions.
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

0 comments on commit 72d9885

Please sign in to comment.