Skip to content

Commit

Permalink
optional scooby
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Jun 2, 2020
1 parent 8c60e89 commit 30d86c9
Showing 1 changed file with 61 additions and 40 deletions.
101 changes: 61 additions & 40 deletions tephi/utils/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

import os
from subprocess import check_output, CalledProcessError
import warnings

import scooby
try:
import scooby
except ImportError:
scooby = None


class CondaInfo:
Expand Down Expand Up @@ -74,43 +78,60 @@ def get_info(self):
)


class Report(scooby.Report):
"""
Generate a :class:`scooby.Report` of platform and package dependencies.
Parameters
----------
additional : list of ModuleType, list of str, optional
List of packages or package names to add to output information.
ncol : int, optional
Number of package-columns in HTML table. Has no effect in text-version
(default is 3).
text_width : int, optional
The text width for non-HTML display modes (default is 80).
sort : bool, optional
Sort the packages when the report is shown (default is False).
conda : bool, optional
Gather information about conda (default is False).
"""

def __init__(
self, additional=None, ncol=3, text_width=80, sort=False, conda=False
):
# Mandatory packages.
core = ["tephi", "matplotlib", "numpy", "scipy"]

# Gather conda information.
if conda:
extra_meta = CondaInfo().get_info()
else:
extra_meta = None

super().__init__(
additional=additional,
core=core,
ncol=ncol,
text_width=text_width,
sort=sort,
extra_meta=extra_meta,
if scooby is not None:

class Report(scooby.Report):
"""
Generate a :class:`scooby.Report` of platform and package dependencies.
Parameters
----------
additional : list of ModuleType, list of str, optional
List of packages or package names to add to output information.
ncol : int, optional
Number of package-columns in HTML table. Has no effect in text-version
(default is 3).
text_width : int, optional
The text width for non-HTML display modes (default is 80).
sort : bool, optional
Sort the packages when the report is shown (default is False).
conda : bool, optional
Gather information about conda (default is False).
"""

def __init__(
self,
additional=None,
ncol=3,
text_width=80,
sort=False,
conda=False,
):
# Mandatory packages.
core = ["tephi", "matplotlib", "numpy", "scipy"]

# Gather conda information.
if conda:
extra_meta = CondaInfo().get_info()
else:
extra_meta = None

super().__init__(
additional=additional,
core=core,
ncol=ncol,
text_width=text_width,
sort=sort,
extra_meta=extra_meta,
)


else:

def Report(*args, **kwargs):
wmsg = (
'Cannot generate a report. Please first install the "scooby" '
"package from either conda-forge or PyPI."
)
warnings.warn(wmsg)

0 comments on commit 30d86c9

Please sign in to comment.