Skip to content

Commit

Permalink
cleanup: move template engine import to the top
Browse files Browse the repository at this point in the history
they’re hard deps now
  • Loading branch information
trehn committed Oct 2, 2017
1 parent 71d6485 commit 4e0df75
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions bundlewrap/items/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from sys import exc_info
from traceback import format_exception

from jinja2 import Environment, FileSystemLoader
from mako.lookup import TemplateLookup
from mako.template import Template

from bundlewrap.exceptions import BundleError, FaultUnavailable, TemplateError
from bundlewrap.items import BUILTIN_ITEM_ATTRIBUTES, Item
from bundlewrap.items.directories import validator_mode
Expand All @@ -30,14 +34,6 @@ def content_processor_base64(item):


def content_processor_jinja2(item):
try:
from jinja2 import Environment, FileSystemLoader
except ImportError:
raise TemplateError(_(
"Unable to load Jinja2 (required to render {item}). "
"You probably have to install it using `pip install Jinja2`."
).format(item=item.id))

loader = FileSystemLoader(searchpath=[item.item_data_dir, item.item_dir])
env = Environment(loader=loader)

Expand Down Expand Up @@ -80,8 +76,6 @@ def content_processor_jinja2(item):


def content_processor_mako(item):
from mako.lookup import TemplateLookup
from mako.template import Template
template = Template(
item._template_content.encode('utf-8'),
input_encoding='utf-8',
Expand Down

0 comments on commit 4e0df75

Please sign in to comment.