From 51ef2e253fe1cc1e2f15742b253f0e139ca13ff3 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 24 Jan 2021 10:01:54 +0100 Subject: [PATCH] Put a proper warning when sankey is not installed Following multiple bug report in this sense. --- survey/exporter/tex/question2tex_sankey.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/survey/exporter/tex/question2tex_sankey.py b/survey/exporter/tex/question2tex_sankey.py index cab1017a..82795174 100755 --- a/survey/exporter/tex/question2tex_sankey.py +++ b/survey/exporter/tex/question2tex_sankey.py @@ -1,13 +1,17 @@ # -*- coding: utf-8 -*- import logging +import warnings from django.utils.translation import gettext_lazy as _ from pandas.core.frame import DataFrame -#try: -from pysankey import sankey -#except ModuleNotFoundError: -# from pySankey import sankey +try: + from pysankey import sankey +except ModuleNotFoundError: + warnings.warn( + "Cannot import 'sankey', please install the package using + "the sankey extra. (pip install django-survey-and-report[sankey])" + ) from survey.exporter.tex.question2tex import Question2Tex from survey.models.question import Question