def __init__(self, directories=None, module_directory=None, filesystem_checks=True, collection_size=-1, format_exceptions=False, error_handler=None, disable_unicode=False, bytestring_passthrough=False, output_encoding=None, encoding_errors='strict', cache_type=None, cache_dir=None, cache_url=None, cache_enabled=True, modulename_callable=None, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, input_encoding=None, preprocessor=None): self.directories = [ posixpath.normpath(d) for d in util.to_list(directories, ()) ] self.module_directory = module_directory self.modulename_callable = modulename_callable self.filesystem_checks = filesystem_checks self.collection_size = collection_size self.template_args = { 'format_exceptions': format_exceptions, 'error_handler': error_handler, 'disable_unicode': disable_unicode, 'bytestring_passthrough': bytestring_passthrough, 'output_encoding': output_encoding, 'encoding_errors': encoding_errors, 'input_encoding': input_encoding, 'module_directory': module_directory, 'cache_type': cache_type, 'cache_dir': cache_dir or module_directory, 'cache_url': cache_url, 'cache_enabled': cache_enabled, 'default_filters': default_filters, 'buffer_filters': buffer_filters, 'strict_undefined': strict_undefined, 'imports': imports, 'preprocessor': preprocessor } if collection_size == -1: self._collection = {} self._uri_cache = {} else: self._collection = util.LRUCache(collection_size) self._uri_cache = util.LRUCache(collection_size) self._mutex = threading.Lock()
def add_template_directories(self, *directories): """ Adds a directories to the lookup paths for the templates. :param directories: The directories to add. """ lookup = self.template_lookup # Process the directories to be "mako compatible." dirs = [posixpath.normpath(d) for d in to_list(directories, ())] lookup.directories += dirs
def __init__(self, directories=None, module_directory=None, filesystem_checks=True, collection_size=-1, format_exceptions=False, error_handler=None, disable_unicode=False, bytestring_passthrough=False, output_encoding=None, encoding_errors='strict', cache_type=None, cache_dir=None, cache_url=None, cache_enabled=True, modulename_callable=None, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, input_encoding=None, preprocessor=None): self.directories = [posixpath.normpath(d) for d in util.to_list(directories, ()) ] self.module_directory = module_directory self.modulename_callable = modulename_callable self.filesystem_checks = filesystem_checks self.collection_size = collection_size self.template_args = { 'format_exceptions':format_exceptions, 'error_handler':error_handler, 'disable_unicode':disable_unicode, 'bytestring_passthrough':bytestring_passthrough, 'output_encoding':output_encoding, 'encoding_errors':encoding_errors, 'input_encoding':input_encoding, 'module_directory':module_directory, 'cache_type':cache_type, 'cache_dir':cache_dir or module_directory, 'cache_url':cache_url, 'cache_enabled':cache_enabled, 'default_filters':default_filters, 'buffer_filters':buffer_filters, 'strict_undefined':strict_undefined, 'imports':imports, 'preprocessor':preprocessor} if collection_size == -1: self._collection = {} self._uri_cache = {} else: self._collection = util.LRUCache(collection_size) self._uri_cache = util.LRUCache(collection_size) self._mutex = threading.Lock()
def __init__(self, ui_paths, uis=None): """Init ui container, param ui_paths: the ui template paths. param uis: the dict like object, contains the ui module classes. """ self.ui_paths = [posixpath.normpath(d) for d in util.to_list(ui_paths, ()) ] self.uis = uis or dict() self.loader = None
def get_template(template, uri, directories): a_directories = [posixpath.normpath(d) for d in util.to_list(directories, ())] try: if template.filesystem_checks: return template._check(uri, template._collection[uri]) else: return template._collection[uri] except KeyError: u = re.sub(r'^\/+', '', uri) for dir in a_directories: srcfile = os.path.join(camoji.settings.APP_DIR, dir, u) if os.path.isfile(srcfile): return template._load(srcfile, uri) else: raise exceptions.TopLevelLookupException( "Cant locate template for uri %r" % uri)
def __init__( self, directories=None, module_directory=None, filesystem_checks=True, collection_size=-1, format_exceptions=False, error_handler=None, output_encoding=None, encoding_errors="strict", cache_args=None, cache_impl="beaker", cache_enabled=True, cache_type=None, cache_dir=None, cache_url=None, modulename_callable=None, module_writer=None, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, future_imports=None, enable_loop=True, input_encoding=None, preprocessor=None, lexer_cls=None, include_error_handler=None, ): self.directories = [ posixpath.normpath(d) for d in util.to_list(directories, ()) ] self.module_directory = module_directory self.modulename_callable = modulename_callable self.filesystem_checks = filesystem_checks self.collection_size = collection_size if cache_args is None: cache_args = {} # transfer deprecated cache_* args if cache_dir: cache_args.setdefault("dir", cache_dir) if cache_url: cache_args.setdefault("url", cache_url) if cache_type: cache_args.setdefault("type", cache_type) self.template_args = { "format_exceptions": format_exceptions, "error_handler": error_handler, "include_error_handler": include_error_handler, "output_encoding": output_encoding, "cache_impl": cache_impl, "encoding_errors": encoding_errors, "input_encoding": input_encoding, "module_directory": module_directory, "module_writer": module_writer, "cache_args": cache_args, "cache_enabled": cache_enabled, "default_filters": default_filters, "buffer_filters": buffer_filters, "strict_undefined": strict_undefined, "imports": imports, "future_imports": future_imports, "enable_loop": enable_loop, "preprocessor": preprocessor, "lexer_cls": lexer_cls, } if collection_size == -1: self._collection = {} self._uri_cache = {} else: self._collection = util.LRUCache(collection_size) self._uri_cache = util.LRUCache(collection_size) self._mutex = threading.Lock()
def __init__( self, directories=None, module_directory=None, filesystem_checks=True, collection_size=-1, format_exceptions=False, error_handler=None, disable_unicode=False, bytestring_passthrough=False, output_encoding=None, encoding_errors="strict", cache_args=None, cache_impl="beaker", cache_enabled=True, cache_type=None, cache_dir=None, cache_url=None, modulename_callable=None, module_writer=None, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, future_imports=None, enable_loop=True, input_encoding=None, preprocessor=None, lexer_cls=None, ): self.directories = [posixpath.normpath(d) for d in util.to_list(directories, ())] self.module_directory = module_directory self.modulename_callable = modulename_callable self.filesystem_checks = filesystem_checks self.collection_size = collection_size if cache_args is None: cache_args = {} # transfer deprecated cache_* args if cache_dir: cache_args.setdefault("dir", cache_dir) if cache_url: cache_args.setdefault("url", cache_url) if cache_type: cache_args.setdefault("type", cache_type) self.template_args = { "format_exceptions": format_exceptions, "error_handler": error_handler, "disable_unicode": disable_unicode, "bytestring_passthrough": bytestring_passthrough, "output_encoding": output_encoding, "cache_impl": cache_impl, "encoding_errors": encoding_errors, "input_encoding": input_encoding, "module_directory": module_directory, "module_writer": module_writer, "cache_args": cache_args, "cache_enabled": cache_enabled, "default_filters": default_filters, "buffer_filters": buffer_filters, "strict_undefined": strict_undefined, "imports": imports, "future_imports": future_imports, "enable_loop": enable_loop, "preprocessor": preprocessor, "lexer_cls": lexer_cls, } if collection_size == -1: self._collection = {} self._uri_cache = {} else: self._collection = util.LRUCache(collection_size) self._uri_cache = util.LRUCache(collection_size) self._mutex = threading.Lock()
def append_dirs(self, directories): self.directories = [posixpath.normpath(d) for d in util.to_list(directories, ()) ] + self.directories