Skip to content

Commit

Permalink
Fixed NLTK resource dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
markgw committed Jul 8, 2020
1 parent 7dd7a14 commit 2009362
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/python/pimlico/core/dependencies/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,19 @@ class NLTKResource(SoftwareDependency):
def problems(self, local_config):
problems = super(NLTKResource, self).problems(local_config)
# Check whether the resource is available
from nltk.downloader import _downloader
try:
resource_installed = _downloader.is_installed(self.name)
except Exception as e:
problems.append("Error checking NLTK resource status for {}: {}".format(self.name, e))
from nltk.downloader import _downloader
except:
# If NLTK isn't even installed, we can't check whether the resource is there
problems.append("NLTK not installed: cannot check for resource '{}'".format(self.name))
else:
if not resource_installed:
problems.append("NLTK resource '{}' not installed".format(self.name))
try:
resource_installed = _downloader.is_installed(self.name)
except Exception as e:
problems.append("Error checking NLTK resource status for {}: {}".format(self.name, e))
else:
if not resource_installed:
problems.append("NLTK resource '{}' not installed".format(self.name))
return problems

def installable(self):
Expand Down

0 comments on commit 2009362

Please sign in to comment.