# Path: sigal/signals.py

# 
# Path: sigal/settings.py
# def read_settings(filename=None):
#     """Read settings from a config file in the source_dir root."""
# 
#     logger = logging.getLogger(__name__)
#     logger.info("Reading settings ...")
#     settings = _DEFAULT_CONFIG.copy()
# 
#     if filename:
#         logger.debug("Settings file: %s", filename)
#         settings_path = os.path.dirname(filename)
#         tempdict = {}
# 
#         with open(filename) as f:
#             code = compile(f.read(), filename, 'exec')
#             exec(code, tempdict)
# 
#         settings.update(
#             (k, v) for k, v in tempdict.items() if k not in ['__builtins__']
#         )
# 
#         # Make the paths relative to the settings file
#         paths = ['source', 'destination', 'watermark']
# 
#         if os.path.isdir(join(settings_path, settings['theme'])) and os.path.isdir(
#             join(settings_path, settings['theme'], 'templates')
#         ):
#             paths.append('theme')
# 
#         for p in paths:
#             path = settings[p]
#             if path and not isabs(path):
#                 settings[p] = abspath(normpath(join(settings_path, path)))
#                 logger.debug("Rewrite %s : %s -> %s", p, path, settings[p])
# 
#     for key in ('img_size', 'thumb_size', 'video_size'):
#         if settings[key]:
#             w, h = settings[key]
#             if h > w:
#                 settings[key] = (h, w)
#                 logger.warning(
#                     "The %s setting should be specified with the largest value first.",
#                     key,
#                 )
# 
#     if not settings['img_processor']:
#         logger.info('No Processor, images will not be resized')
# 
#     logger.debug('Settings:\n%s', pformat(settings, width=120))
#     return settings


import os
import shutil
import blinker
import PIL
import pytest
from sigal import signals
from sigal.settings import read_settings



CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
BUILD_DIR = os.path.join(CURRENT_DIR, 'sample', '_build')


@pytest.fixture(scope='session', autouse=True)
def remove_build():
    """Ensure that build directory does not exists before each test."""
    if os.path.exists(BUILD_DIR):
        shutil.rmtree(BUILD_DIR)


@pytest.fixture
def settings():
    """Read the sample config file."""
    return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py'))


@pytest.fixture()
def disconnect_signals():
    # Reset plugins
    yield None
    for name in dir(signals):
        if not name.startswith('_'):
            try:

# Path: sigal/signals.py

# 
# Path: sigal/settings.py
# def read_settings(filename=None):
#     """Read settings from a config file in the source_dir root."""
# 
#     logger = logging.getLogger(__name__)
#     logger.info("Reading settings ...")
#     settings = _DEFAULT_CONFIG.copy()
# 
#     if filename:
#         logger.debug("Settings file: %s", filename)
#         settings_path = os.path.dirname(filename)
#         tempdict = {}
# 
#         with open(filename) as f:
#             code = compile(f.read(), filename, 'exec')
#             exec(code, tempdict)
# 
#         settings.update(
#             (k, v) for k, v in tempdict.items() if k not in ['__builtins__']
#         )
# 
#         # Make the paths relative to the settings file
#         paths = ['source', 'destination', 'watermark']
# 
#         if os.path.isdir(join(settings_path, settings['theme'])) and os.path.isdir(
#             join(settings_path, settings['theme'], 'templates')
#         ):
#             paths.append('theme')
# 
#         for p in paths:
#             path = settings[p]
#             if path and not isabs(path):
#                 settings[p] = abspath(normpath(join(settings_path, path)))
#                 logger.debug("Rewrite %s : %s -> %s", p, path, settings[p])
# 
#     for key in ('img_size', 'thumb_size', 'video_size'):
#         if settings[key]:
#             w, h = settings[key]
#             if h > w:
#                 settings[key] = (h, w)
#                 logger.warning(
#                     "The %s setting should be specified with the largest value first.",
#                     key,
#                 )
# 
#     if not settings['img_processor']:
#         logger.info('No Processor, images will not be resized')
# 
#     logger.debug('Settings:\n%s', pformat(settings, width=120))
#     return settings


# Path: tests/conftest.py
import os
import shutil
import blinker
import PIL
import pytest
from sigal import signals
from sigal.settings import read_settings




CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
BUILD_DIR = os.path.join(CURRENT_DIR, 'sample', '_build')


@pytest.fixture(scope='session', autouse=True)
def remove_build():
    """Ensure that build directory does not exists before each test."""
    if os.path.exists(BUILD_DIR):
        shutil.rmtree(BUILD_DIR)


@pytest.fixture
def settings():
    """Read the sample config file."""
    return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py'))


@pytest.fixture()
def disconnect_signals():
    # Reset plugins
    yield None
    for name in dir(signals):
        if not name.startswith('_'):
            try:

                sig = getattr(signals, name)