# Path: templar/api/rules/core.py
# class Rule:
#     """Represents a preprocessor or postprocessor rule. Rules are applied in the order that they
#     are listed in the Config.
# 
#     When constructing a rule, the arguments `src` and `dst` are regular expressions; Templar will
#     only apply a rule if the source and destination of the publishing pipeline match the regexes.
#     """
#     def __init__(self, src=None, dst=None):
#         if src is not None and not isinstance(src, str):
#             raise InvalidRule(
#                     "Rule's source pattern must be a string or None, "
#                     "but was type '{}'".format(type(src).__name__))
#         if dst is not None and not isinstance(dst, str):
#             raise InvalidRule(
#                     "Rule's destination pattern must be a string or None, "
#                     "but was type '{}'".format(type(src).__name__))
#         self._src_pattern = src
#         self._dst_pattern = dst
# 
#     def applies(self, src, dst):
#         """Checks if this rule applies to the given src and dst paths, based on the src pattern and
#         dst pattern given in the constructor.
# 
#         If src pattern was None, this rule will apply to any given src path (same for dst).
#         """
#         if self._src_pattern and (src is None or re.search(self._src_pattern, src) is None):
#             return False
#         elif self._dst_pattern and (dst is None or re.search(self._dst_pattern, dst) is None):
#             return False
#         return True
# 
#     def apply(self, content):
#         """Applies this rule to the given content. A rule can do one or more of the following:
# 
#         - Return a string; this is taken to be the transformed version of content, and will be used
#           as the new content after applying this rule.
#         - Modify variables (a dict). Usually, Rules that modify this dictionary will add new
#           variables. However, a Rule can also delete or update key/value pairs in the dictionary.
#         """
#         raise NotImplementedError
# 
# Path: templar/exceptions.py
# class TemplarError(Exception):
#     """Top-level exception for Templar."""
#     pass


from templar.api.rules.core import Rule
from templar.exceptions import TemplarError
import importlib.machinery
import os.path
    def append_compiler_rules(self, *compiler_rules):
        for rule in compiler_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'compiler_rule must be a Rule, but instead was: ' + repr(rule))
        self._compiler_rules.extend(compiler_rules)
        return self

    def prepend_compiler_rules(self, *compiler_rules):
        for rule in compiler_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'compiler_rule must be a Rule, but instead was: ' + repr(rule))
        self._compiler_rules = list(compiler_rules) + self._compiler_rules
        return self

    def clear_compiler_rules(self):
        self._compiler_rules = []
        return self

    def append_preprocess_rules(self, *preprocess_rules):
        for rule in preprocess_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'preprocess_rule must be a Rule object, but instead was: ' + repr(rule))
        self._preprocess_rules.extend(preprocess_rules)
        return self

    def prepend_preprocess_rules(self, *preprocess_rules):
        for rule in preprocess_rules:

# Path: templar/api/rules/core.py
# class Rule:
#     """Represents a preprocessor or postprocessor rule. Rules are applied in the order that they
#     are listed in the Config.
# 
#     When constructing a rule, the arguments `src` and `dst` are regular expressions; Templar will
#     only apply a rule if the source and destination of the publishing pipeline match the regexes.
#     """
#     def __init__(self, src=None, dst=None):
#         if src is not None and not isinstance(src, str):
#             raise InvalidRule(
#                     "Rule's source pattern must be a string or None, "
#                     "but was type '{}'".format(type(src).__name__))
#         if dst is not None and not isinstance(dst, str):
#             raise InvalidRule(
#                     "Rule's destination pattern must be a string or None, "
#                     "but was type '{}'".format(type(src).__name__))
#         self._src_pattern = src
#         self._dst_pattern = dst
# 
#     def applies(self, src, dst):
#         """Checks if this rule applies to the given src and dst paths, based on the src pattern and
#         dst pattern given in the constructor.
# 
#         If src pattern was None, this rule will apply to any given src path (same for dst).
#         """
#         if self._src_pattern and (src is None or re.search(self._src_pattern, src) is None):
#             return False
#         elif self._dst_pattern and (dst is None or re.search(self._dst_pattern, dst) is None):
#             return False
#         return True
# 
#     def apply(self, content):
#         """Applies this rule to the given content. A rule can do one or more of the following:
# 
#         - Return a string; this is taken to be the transformed version of content, and will be used
#           as the new content after applying this rule.
#         - Modify variables (a dict). Usually, Rules that modify this dictionary will add new
#           variables. However, a Rule can also delete or update key/value pairs in the dictionary.
#         """
#         raise NotImplementedError
# 
# Path: templar/exceptions.py
# class TemplarError(Exception):
#     """Top-level exception for Templar."""
#     pass


# Path: templar/api/config.py
from templar.api.rules.core import Rule
from templar.exceptions import TemplarError
import importlib.machinery
import os.path

    def append_compiler_rules(self, *compiler_rules):
        for rule in compiler_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'compiler_rule must be a Rule, but instead was: ' + repr(rule))
        self._compiler_rules.extend(compiler_rules)
        return self

    def prepend_compiler_rules(self, *compiler_rules):
        for rule in compiler_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'compiler_rule must be a Rule, but instead was: ' + repr(rule))
        self._compiler_rules = list(compiler_rules) + self._compiler_rules
        return self

    def clear_compiler_rules(self):
        self._compiler_rules = []
        return self

    def append_preprocess_rules(self, *preprocess_rules):
        for rule in preprocess_rules:
            if not isinstance(rule, Rule):
                raise ConfigBuilderError(
                        'preprocess_rule must be a Rule object, but instead was: ' + repr(rule))
        self._preprocess_rules.extend(preprocess_rules)
        return self

    def prepend_preprocess_rules(self, *preprocess_rules):
        for rule in preprocess_rules:

            if not isinstance(rule, Rule):