# Path: peanut/utils.py
# def get_resource(relative_path):
#     package_path = os.path.abspath(os.path.split(__file__)[0])
#     return os.path.join(package_path, relative_path)


from os import path
from jinja2 import FileSystemLoader, ChoiceLoader
from jinja2.exceptions import TemplateNotFound
from peanut.utils import get_resource
import jinja2
import peanut



class SmartLoader(FileSystemLoader):
    """A smart template loader"""

    available_extension = ['.html', '.xml']

    def get_source(self, environment, template):
        if template is None:
            raise TemplateNotFound(template)
        if '.' in template:
            return super(SmartLoader, self).get_source(environment, template)

        for extension in SmartLoader.available_extension:
            try:
                filename = template + extension
                return super(SmartLoader, self).get_source(environment, filename)
            except TemplateNotFound:
                pass

        raise TemplateNotFound(template)


class Template(object):
    """Template"""

    def __init__(self, path, filters=None, **kwargs):
        loader = ChoiceLoader([
            SmartLoader(path),

# Path: peanut/utils.py
# def get_resource(relative_path):
#     package_path = os.path.abspath(os.path.split(__file__)[0])
#     return os.path.join(package_path, relative_path)


# Path: peanut/template.py
from os import path
from jinja2 import FileSystemLoader, ChoiceLoader
from jinja2.exceptions import TemplateNotFound
from peanut.utils import get_resource
import jinja2
import peanut




class SmartLoader(FileSystemLoader):
    """A smart template loader"""

    available_extension = ['.html', '.xml']

    def get_source(self, environment, template):
        if template is None:
            raise TemplateNotFound(template)
        if '.' in template:
            return super(SmartLoader, self).get_source(environment, template)

        for extension in SmartLoader.available_extension:
            try:
                filename = template + extension
                return super(SmartLoader, self).get_source(environment, filename)
            except TemplateNotFound:
                pass

        raise TemplateNotFound(template)


class Template(object):
    """Template"""

    def __init__(self, path, filters=None, **kwargs):
        loader = ChoiceLoader([
            SmartLoader(path),

            SmartLoader(get_resource('themes/default')),