# 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
        path = gammacat_info.webpage_path / 'data/reference_list.rst'
        log.info(f'Writing {path}')
        path.write_text(txt)

    def make_source_detail_pages(self):
        path = gammacat_info.webpage_path / 'data/sources/'
        path.mkdir(exist_ok=True)
        for source in self.sources_data:
            self.make_source_detail_page(source)

    def make_reference_detail_pages(self):
        path = gammacat_info.webpage_path / 'data/references/'
        path.mkdir(exist_ok=True)
        for reference in self.references_data:
            self.make_reference_detail_page(reference)

    def make_source_detail_page(self, source):
        resources = [
            self.make_resource_info_for_template(resource)
            for resource in self.resource_index_output.resources
            if resource.source_id == source['source_id']
        ]
        # The first resource is the basic source info
        # We have that separately, so we skip it here
        resources = resources[1:]

        ctx = {
            'source': source,
            'resources': resources,
        }

# 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

        path = gammacat_info.webpage_path / 'data/reference_list.rst'
        log.info(f'Writing {path}')
        path.write_text(txt)

    def make_source_detail_pages(self):
        path = gammacat_info.webpage_path / 'data/sources/'
        path.mkdir(exist_ok=True)
        for source in self.sources_data:
            self.make_source_detail_page(source)

    def make_reference_detail_pages(self):
        path = gammacat_info.webpage_path / 'data/references/'
        path.mkdir(exist_ok=True)
        for reference in self.references_data:
            self.make_reference_detail_page(reference)

    def make_source_detail_page(self, source):
        resources = [
            self.make_resource_info_for_template(resource)
            for resource in self.resource_index_output.resources
            if resource.source_id == source['source_id']
        ]
        # The first resource is the basic source info
        # We have that separately, so we skip it here
        resources = resources[1:]

        ctx = {
            'source': source,
            'resources': resources,
        }

        template = jinja_env.get_template('source_detail.txt')