Skip to content

Commit

Permalink
Add try/except to catch ModuleNotFoundError when no openpyxl
Browse files Browse the repository at this point in the history
  • Loading branch information
baileythegreen committed Dec 17, 2021
1 parent 14a96f3 commit 630bcfd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyani/pyani_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"""Module providing functions for presenting analysis/db output."""

import sys
import logging

from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence
Expand Down Expand Up @@ -202,6 +203,8 @@ def write_dbtable(
colours are used for identity/coverage tables
"""
logger = logging.getLogger(__name__)

formatdict = {
"tab": (dfm.to_csv, {"sep": "\t", "index": show_index}, ".tab"),
"excel": (dfm.to_excel, {"index": show_index}, ".xlsx"),
Expand All @@ -215,4 +218,9 @@ def write_dbtable(
for fmt in formats:
func, args, ext = formatdict[fmt]
ofname = path.with_suffix(ext)
func(ofname, **args)
try:
func(ofname, **args)
except ModuleNotFoundError as e:
logger.warning("ModuleNotFoundError: %s", e)
logger.warning("Skipping %s output", fmt)
continue

0 comments on commit 630bcfd

Please sign in to comment.