<s> from __future__ import unicode_literals <EOL> try : <EOL> from pkg_resources import resource_string <EOL> except ImportError : <EOL> resource_string = None <EOL> from django . conf import settings <EOL> from django . template . base import TemplateDoesNotExist <EOL> from django . template . loader import BaseLoader <EOL> from django . utils import six <EOL> class Loader ( BaseLoader ) : <EOL> is_usable = resource_string is not None <EOL> def load_template_source ( self , template_name , template_dirs = None ) : <EOL> """<STR_LIT>""" <EOL> if resource_string is not None : <EOL> pkg_name = '<STR_LIT>' + template_name <EOL> for app in settings . INSTALLED_APPS : <EOL> try : <EOL> resource = resource_string ( app , pkg_name ) <EOL> except Exception : <EOL> continue <EOL> if six . PY2 : <EOL> resource = resource . decode ( settings . FILE_CHARSET ) <EOL> return ( resource , '<STR_LIT>' % ( app , pkg_name ) ) <EOL> raise TemplateDoesNotExist ( template_name ) </s>
