# Path: coolisf/common.py
# def read_file(file_path, mode='rt'):
#     file_path = FileHelper.abspath(file_path)  # normalize path
#     if not os.path.isfile(file_path):
#         raise Exception("Input file not found: {}".format(file_path))
#     if file_path.endswith('.gz'):
#         with gzip.open(file_path, mode) as infile:
#             return infile.read()
#     else:
#         return FileHelper.read(file_path, mode)


import os
import logging
from coolisf.common import read_file

# This code is a part of coolisf library: https://github.com/letuananh/intsem.fx
# :copyright: (c) 2014 Le Tuan Anh <tuananh.ke@gmail.com>
# :license: MIT, see LICENSE for more details.


# -------------------------------------------------------------------------------
# Configuration
# -------------------------------------------------------------------------------

MY_DIR = os.path.dirname(__file__)
CCBY30_PATH = os.path.join(MY_DIR, 'CCBY30_template.txt.gz')
CONFIG_JSON_TEMPLATE = os.path.join(MY_DIR, 'config.template.json.gz')


def getLogger():
    return logging.getLogger(__name__)


# -------------------------------------------------------------------------------
# functions
# -------------------------------------------------------------------------------

def read_ccby30():
    getLogger().debug("Reading CCBY30 license text from {}".format(CCBY30_PATH))
    return read_file(CCBY30_PATH)


def read_config_template():
    getLogger().debug("Reading CCBY30 license text from {}".format(CONFIG_JSON_TEMPLATE))

# Path: coolisf/common.py
# def read_file(file_path, mode='rt'):
#     file_path = FileHelper.abspath(file_path)  # normalize path
#     if not os.path.isfile(file_path):
#         raise Exception("Input file not found: {}".format(file_path))
#     if file_path.endswith('.gz'):
#         with gzip.open(file_path, mode) as infile:
#             return infile.read()
#     else:
#         return FileHelper.read(file_path, mode)


# Path: coolisf/data/reader.py
import os
import logging
from coolisf.common import read_file


# This code is a part of coolisf library: https://github.com/letuananh/intsem.fx
# :copyright: (c) 2014 Le Tuan Anh <tuananh.ke@gmail.com>
# :license: MIT, see LICENSE for more details.


# -------------------------------------------------------------------------------
# Configuration
# -------------------------------------------------------------------------------

MY_DIR = os.path.dirname(__file__)
CCBY30_PATH = os.path.join(MY_DIR, 'CCBY30_template.txt.gz')
CONFIG_JSON_TEMPLATE = os.path.join(MY_DIR, 'config.template.json.gz')


def getLogger():
    return logging.getLogger(__name__)


# -------------------------------------------------------------------------------
# functions
# -------------------------------------------------------------------------------

def read_ccby30():
    getLogger().debug("Reading CCBY30 license text from {}".format(CCBY30_PATH))
    return read_file(CCBY30_PATH)


def read_config_template():
    getLogger().debug("Reading CCBY30 license text from {}".format(CONFIG_JSON_TEMPLATE))

    return read_file(CONFIG_JSON_TEMPLATE)