<s> """<STR_LIT>""" <EOL> from django . conf import settings <EOL> from django . template . base import TemplateDoesNotExist <EOL> from django . template . loader import BaseLoader <EOL> from django . utils . _os import safe_join <EOL> class Loader ( BaseLoader ) : <EOL> is_usable = True <EOL> def get_template_sources ( self , template_name , template_dirs = None ) : <EOL> """<STR_LIT>""" <EOL> if not template_dirs : <EOL> template_dirs = settings . TEMPLATE_DIRS <EOL> for template_dir in template_dirs : <EOL> try : <EOL> yield safe_join ( template_dir , template_name ) <EOL> except UnicodeDecodeError : <EOL> raise <EOL> except ValueError : <EOL> pass <EOL> def load_template_source ( self , template_name , template_dirs = None ) : <EOL> tried = [ ] <EOL> for filepath in self . get_template_sources ( template_name , template_dirs ) : <EOL> try : <EOL> file = open ( filepath ) <EOL> try : <EOL> return ( file . read ( ) . decode ( settings . FILE_CHARSET ) , filepath ) <EOL> finally : <EOL> file . close ( ) <EOL> except IOError : <EOL> tried . append ( filepath ) <EOL> if tried : <EOL> error_msg = "<STR_LIT>" % tried <EOL> else : <EOL> error_msg = "<STR_LIT>" <EOL> raise TemplateDoesNotExist ( error_msg ) <EOL> load_template_source . is_usable = True <EOL> _loader = Loader ( ) </s>
