Skip to content

Commit

Permalink
Packaging fix: a recent commit made requests and beautifulsoup4 optio…
Browse files Browse the repository at this point in the history
…nal dependencies, but did not also make them optional imports.
  • Loading branch information
ceball committed Dec 22, 2019
1 parent be86e2e commit 2e2597f
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions nbsmoke/verify.py
Expand Up @@ -17,6 +17,18 @@

class VerifyNb(pytest.Item):
def runtest(self):

###################################################
# quick hacks to handle missing optional modules
_missing = []
if BeautifulSoup is None:
_missing.append(" * BeautifulSoup not available - please install beautifulsoup4")
if requests is None:
_missing.append(" * requests not available - please install requests")
if _missing:
raise Exception("nbsmoke verify failed to execute because of missing modules:\n"+"\n".join(_missing))
###################################################

filename = self.name

bad_modules = check_modules(filename)
Expand All @@ -31,6 +43,17 @@ def runtest(self):
warnings.warn("%s:\n***** invalid modules: %s\n\n***** bad links: %s\n\n***** bad images: %s\n\n"%(filename,bad_modules,bad_links,bad_images) + "-"*20)


try:
import requests, requests.exceptions
except:
requests = None

try:
from bs4 import BeautifulSoup
except:
# TODO: capture or log the error
BeautifulSoup = None

###################################################
###################################################
# rest of this file is quickly copied in code from datashader
Expand All @@ -42,10 +65,6 @@ def runtest(self):
# https://www.earthsystemcog.org/projects/esmf/regridding is a bad
# link).


import requests, requests.exceptions
from bs4 import BeautifulSoup

def export_as_html(filename):
html_exporter = nbconvert.HTMLExporter()
html_exporter.template_file = 'basic'
Expand Down Expand Up @@ -123,3 +142,4 @@ def check_urls(notebook, name, attribute):
bad_urls.add(url)

return bad_urls

0 comments on commit 2e2597f

Please sign in to comment.