# Path: handroll/signals.py



from handroll import signals
# Copyright (c) 2017, Matt Layman



class Extension(object):
    """A base extension which hooks handler methods to handroll's signals."""

    handle_frontmatter_loaded = False
    handle_pre_composition = False
    handle_post_composition = False

    def __init__(self, config):
        self._config = config
        # Handler functions are put in a dictionary to keep references to them.
        # Blinker behaves in strange ways without the references.
        self._handlers = {}

        if self.handle_frontmatter_loaded:
            def _handle_frontmatter_loaded(source_file, **kwargs):
                self.on_frontmatter_loaded(source_file, kwargs['frontmatter'])
            self._handlers['frontmatter_loaded'] = _handle_frontmatter_loaded
            signals.frontmatter_loaded.connect(_handle_frontmatter_loaded)

        if self.handle_post_composition:
            def _handle_post_composition(director, **kwargs):
                self.on_post_composition(director)
            self._handlers['post_composition'] = _handle_post_composition

# Path: handroll/signals.py



# Path: handroll/extensions/base.py
from handroll import signals

# Copyright (c) 2017, Matt Layman



class Extension(object):
    """A base extension which hooks handler methods to handroll's signals."""

    handle_frontmatter_loaded = False
    handle_pre_composition = False
    handle_post_composition = False

    def __init__(self, config):
        self._config = config
        # Handler functions are put in a dictionary to keep references to them.
        # Blinker behaves in strange ways without the references.
        self._handlers = {}

        if self.handle_frontmatter_loaded:
            def _handle_frontmatter_loaded(source_file, **kwargs):
                self.on_frontmatter_loaded(source_file, kwargs['frontmatter'])
            self._handlers['frontmatter_loaded'] = _handle_frontmatter_loaded
            signals.frontmatter_loaded.connect(_handle_frontmatter_loaded)

        if self.handle_post_composition:
            def _handle_post_composition(director, **kwargs):
                self.on_post_composition(director)
            self._handlers['post_composition'] = _handle_post_composition

            signals.post_composition.connect(_handle_post_composition)