Coverage for pesummary/io/__init__.py: 100.0%
19 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1# Licensed under an MIT style license -- see LICENSE.md
3from .read import read
4from .write import write
6__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
9def available_formats():
10 """Return the available formats for reading and writing
12 Returns
13 -------
14 tuple: tuple of sets. First set are the available formats for reading.
15 Second set are the available sets for writing.
16 """
17 import pesummary.core.file.formats
18 import pesummary.gw.file.formats
19 import pkgutil
20 import importlib
22 read_formats, write_formats = [], []
23 modules = {
24 "gw": pesummary.gw.file.formats, "core": pesummary.core.file.formats
25 }
26 for package in ["core", "gw"]:
27 formats = [
28 a for _, a, _ in pkgutil.walk_packages(path=modules[package].__path__)
29 ]
30 for _format in formats:
31 _submodule = importlib.import_module(
32 "pesummary.{}.file.formats.{}".format(package, _format)
33 )
34 if hasattr(_submodule, "write_{}".format(_format)):
35 write_formats.append(_format)
36 if hasattr(_submodule, "read_{}".format(_format)):
37 read_formats.append(_format)
38 return set(read_formats), set(write_formats)