# Path: gammacat/input.py
# class BasicSourceList:
#     """
#     List of `BasicSourceInfo` objects.
#     """
#     column_spec = load_yaml(gammacat_info.base_dir / 'input/schemas/basic_source_list.schema.yaml')
# 
#     def __init__(self, data):
#         self.data = data
# 
#     @property
#     def source_ids(self):
#         return [source.data['source_id'] for source in self.data]
# 
#     def get_source_by_id(self, source_id):
#         idx = self.source_ids.index(source_id)
#         return self.data[idx]
# 
#     @classmethod
#     def read(cls):
#         path = gammacat_info.base_dir / 'input/sources'
#         paths = path.glob('*.yaml')
# 
#         data = []
#         for path in paths:
#             info = BasicSourceInfo.read(path)
#             data.append(info)
# 
#         return cls(data=data)
# 
#     def to_dict(self):
#         """Return data in format that can be written to JSON.
# 
#         A dict with `data` key.
#         """
#         return OrderedDict(data=self.data_per_row(filled=True))
# 
#     def data_per_row(self, filled=False):
#         """Data as list of dicts (per-row)"""
#         return [
#             source.to_dict(filled=filled)
#             for source in self.data
#         ]
# 
#     def validate(self):
#         # TODO: validate `column_spec` schema?
# 
#         log.info('Validating YAML files in `input/sources`')
#         [_.validate() for _ in self.data]
# 
# Path: gammacat/info.py
# class GammaCatInfo:
# class GammaCatStr:
#     def __init__(self):
#     def __str__(self):
#     def info_dict(self):
#     def reference_folder(meta):
#     def data_filename(meta):
#     def source_id_str(source_id):
#     def reference_id_str(reference_id):
# def rawgit_url(filename, location='master', mode='production'):
# 
# Path: gammacat/utils.py
# def _to_crab_flux():
#     def fill_value_array(shape):
#     def resize_sed_array(array, shape):
#     def fill_list(cls, data, key):
# def load_yaml(path):
# def write_yaml(data, path):
# def load_json(path):
# def write_json(data, path):
# def print_simbad_pos(name):
# def table_to_list_of_dict(table):
# def validate_schema(path, data, schema):
# def log_list_difference(actual, expected):
#     def __init__(self, table, resource):
#     def read(cls, filename, format='ascii.ecsv'):
#     def _read_resource_info(cls, table, location):
#     def validate_table_colnames(self, expected_colnames):
#     def make_table_columns_uniform(self, col_specs):
#     def validate_input_meta(self):
# FLUX_TO_CRAB = _to_crab_flux()
# E_INF = 1e6 * u.Unit('TeV')
# class ECSVFormatError(Exception):
# class NA:
# class TableProcessor:


import logging
import shutil
import urllib.parse
from gammapy.catalog import GammaCatResourceIndex
from .input import BasicSourceList
from .info import gammacat_info
from .utils import load_json, jinja_env, load_yaml
from pathlib import Path
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Make gamma-cat webpage (in combination with Sphinx).
"""

__all__ = [
    'WebpageConfig',
    'WebpageMaker',
]

log = logging.getLogger(__name__)


class WebpageConfig:
    """Config options for webpage maker."""

    def __init__(self, *, out_path):
        self.out_path = out_path


class WebpageMaker:
    """Make rst-files for gamma-cat webpage."""

    def __init__(self, config):
        self.config = config

        self.resource_index_input = GammaCatResourceIndex.from_list(load_json(
            gammacat_info.in_path / 'input-datasets.json'
        ))

# Path: gammacat/input.py
# class BasicSourceList:
#     """
#     List of `BasicSourceInfo` objects.
#     """
#     column_spec = load_yaml(gammacat_info.base_dir / 'input/schemas/basic_source_list.schema.yaml')
# 
#     def __init__(self, data):
#         self.data = data
# 
#     @property
#     def source_ids(self):
#         return [source.data['source_id'] for source in self.data]
# 
#     def get_source_by_id(self, source_id):
#         idx = self.source_ids.index(source_id)
#         return self.data[idx]
# 
#     @classmethod
#     def read(cls):
#         path = gammacat_info.base_dir / 'input/sources'
#         paths = path.glob('*.yaml')
# 
#         data = []
#         for path in paths:
#             info = BasicSourceInfo.read(path)
#             data.append(info)
# 
#         return cls(data=data)
# 
#     def to_dict(self):
#         """Return data in format that can be written to JSON.
# 
#         A dict with `data` key.
#         """
#         return OrderedDict(data=self.data_per_row(filled=True))
# 
#     def data_per_row(self, filled=False):
#         """Data as list of dicts (per-row)"""
#         return [
#             source.to_dict(filled=filled)
#             for source in self.data
#         ]
# 
#     def validate(self):
#         # TODO: validate `column_spec` schema?
# 
#         log.info('Validating YAML files in `input/sources`')
#         [_.validate() for _ in self.data]
# 
# Path: gammacat/info.py
# class GammaCatInfo:
# class GammaCatStr:
#     def __init__(self):
#     def __str__(self):
#     def info_dict(self):
#     def reference_folder(meta):
#     def data_filename(meta):
#     def source_id_str(source_id):
#     def reference_id_str(reference_id):
# def rawgit_url(filename, location='master', mode='production'):
# 
# Path: gammacat/utils.py
# def _to_crab_flux():
#     def fill_value_array(shape):
#     def resize_sed_array(array, shape):
#     def fill_list(cls, data, key):
# def load_yaml(path):
# def write_yaml(data, path):
# def load_json(path):
# def write_json(data, path):
# def print_simbad_pos(name):
# def table_to_list_of_dict(table):
# def validate_schema(path, data, schema):
# def log_list_difference(actual, expected):
#     def __init__(self, table, resource):
#     def read(cls, filename, format='ascii.ecsv'):
#     def _read_resource_info(cls, table, location):
#     def validate_table_colnames(self, expected_colnames):
#     def make_table_columns_uniform(self, col_specs):
#     def validate_input_meta(self):
# FLUX_TO_CRAB = _to_crab_flux()
# E_INF = 1e6 * u.Unit('TeV')
# class ECSVFormatError(Exception):
# class NA:
# class TableProcessor:


# Path: gammacat/webpage.py
import logging
import shutil
import urllib.parse
from gammapy.catalog import GammaCatResourceIndex
from .input import BasicSourceList
from .info import gammacat_info
from .utils import load_json, jinja_env, load_yaml
from pathlib import Path

# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Make gamma-cat webpage (in combination with Sphinx).
"""

__all__ = [
    'WebpageConfig',
    'WebpageMaker',
]

log = logging.getLogger(__name__)


class WebpageConfig:
    """Config options for webpage maker."""

    def __init__(self, *, out_path):
        self.out_path = out_path


class WebpageMaker:
    """Make rst-files for gamma-cat webpage."""

    def __init__(self, config):
        self.config = config

        self.resource_index_input = GammaCatResourceIndex.from_list(load_json(
            gammacat_info.in_path / 'input-datasets.json'
        ))

        self.resource_index_output = GammaCatResourceIndex.from_list(load_json(