# Path: templar/exceptions.py
# class TemplarError(Exception):
#     """Top-level exception for Templar."""
#     pass


from templar.exceptions import TemplarError
import os
import re

    def has_block(self, filename, block_name):
        return filename in self._blocks and block_name in self._blocks[filename]

    def get_block(self, filename, block_name):
        assert self.has_block(filename, block_name)
        return self._blocks[filename][block_name]

    def add_variable(self, variable, value):
        self._variables[variable] = value


class LinkStack(object):
    """A stack used for keeping track of link dependencies, detecting cycles if they appear."""
    def __init__(self, filename):
        self._stack = [filename]

    def push(self, filename):
        if filename in self._stack:
            raise CyclicalIncludeError(self._stack, filename)
        self._stack.append(filename)

    def pop(self):
        self._stack.pop()


ALL_BLOCK_NAME = 'all'

BLOCK_OPEN_REGEX = re.compile("""
^.*?<\s*block\s+

# Path: templar/exceptions.py
# class TemplarError(Exception):
#     """Top-level exception for Templar."""
#     pass


# Path: templar/linker.py
from templar.exceptions import TemplarError
import os
import re


    def has_block(self, filename, block_name):
        return filename in self._blocks and block_name in self._blocks[filename]

    def get_block(self, filename, block_name):
        assert self.has_block(filename, block_name)
        return self._blocks[filename][block_name]

    def add_variable(self, variable, value):
        self._variables[variable] = value


class LinkStack(object):
    """A stack used for keeping track of link dependencies, detecting cycles if they appear."""
    def __init__(self, filename):
        self._stack = [filename]

    def push(self, filename):
        if filename in self._stack:
            raise CyclicalIncludeError(self._stack, filename)
        self._stack.append(filename)

    def pop(self):
        self._stack.pop()


ALL_BLOCK_NAME = 'all'

BLOCK_OPEN_REGEX = re.compile("""
^.*?<\s*block\s+

([\w -]+)           # \1 is the block name