Skip to content

Commit

Permalink
pr suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD committed Aug 13, 2024
1 parent fdb42fe commit d2e3763
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
11 changes: 9 additions & 2 deletions src/nwbinspector/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
from ._version import __version__
from ._registration import available_checks, register_check
from ._types import Importance, Severity, InspectorMessage
from ._configuration import load_config, InspectorOutputJSONEncoder, validate_config, configure_checks
from ._configuration import load_config, validate_config, configure_checks
from ._inspection import (
inspect_all,
inspect_nwbfile,
inspect_nwbfile_object,
run_checks,
)
from ._inspection import inspect_nwb # TODO: remove after 7/1/2023
from ._formatting import format_messages, print_to_console, save_report, MessageFormatter, FormatterOptions
from ._formatting import (
format_messages,
print_to_console,
save_report,
MessageFormatter,
FormatterOptions,
InspectorOutputJSONEncoder,
)
from ._organization import organize_messages
from .checks import *

Expand Down
14 changes: 0 additions & 14 deletions src/nwbinspector/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@
INTERNAL_CONFIGS = dict(dandi=Path(__file__).parent / "internal_configs" / "dandi.inspector_config.yaml")


class InspectorOutputJSONEncoder(json.JSONEncoder):
"""Custom JSONEncoder for the NWBInspector."""

def default(self, o): # noqa D102
if isinstance(o, InspectorMessage):
return o.__dict__
if isinstance(o, Enum):
return o.name
if isinstance(o, Version):
return str(o)
else:
return super().default(o)


def validate_config(config: dict):
"""Validate an instance of configuration against the official schema."""
with open(file=Path(__file__).parent / "config.schema.json", mode="r") as fp:
Expand Down
14 changes: 14 additions & 0 deletions src/nwbinspector/_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
from .utils import get_package_version, FilePathType


class InspectorOutputJSONEncoder(json.JSONEncoder):
"""Custom JSONEncoder for the NWBInspector."""

def default(self, o): # noqa D102
if isinstance(o, InspectorMessage):
return o.__dict__
if isinstance(o, Enum):
return o.name
if isinstance(o, Version):
return str(o)
else:
return super().default(o)


def _get_report_header():
"""Grab basic information from system at time of report generation."""
return dict(
Expand Down

0 comments on commit d2e3763

Please sign in to comment.