예제 #1
0
파일: loaders.py 프로젝트: zmukwa/jinja
    def __init__(self, searchpath, encoding='utf-8', followlinks=False):
        if (
            not isinstance(searchpath, abc.Iterable)
            or isinstance(searchpath, string_types)
        ):
            searchpath = [searchpath]

        # In Python 3.5, os.path.join doesn't support Path. This can be
        # simplified to list(searchpath) when Python 3.5 is dropped.
        self.searchpath = [fspath(p) for p in searchpath]

        self.encoding = encoding
        self.followlinks = followlinks
예제 #2
0
파일: loaders.py 프로젝트: cav71/jinja
    def __init__(self, path):
        package_name = '_jinja2_module_templates_%x' % id(self)

        # create a fake module that looks for the templates in the
        # path given.
        mod = _TemplateModule(package_name)

        if (not isinstance(path, abc.Iterable)
                or isinstance(path, string_types)):
            path = [path]

        mod.__path__ = [fspath(p) for p in path]

        sys.modules[package_name] = weakref.proxy(
            mod, lambda x: sys.modules.pop(package_name, None))

        # the only strong reference, the sys.modules entry is weak
        # so that the garbage collector can remove it once the
        # loader that created it goes out of business.
        self.module = mod
        self.package_name = package_name