MCPcopy Create free account
hub / github.com/EasyIME/PIME / DictLoader

Class DictLoader

python/python3/tornado/template.py:481–500  ·  view source on GitHub ↗

A template loader that loads from a dictionary.

Source from the content-addressed store, hash-verified

479
480
481class DictLoader(BaseLoader):
482 """A template loader that loads from a dictionary."""
483
484 def __init__(self, dict: Dict[str, str], **kwargs: Any) -> None:
485 super().__init__(**kwargs)
486 self.dict = dict
487
488 def resolve_path(self, name: str, parent_path: Optional[str] = None) -> str:
489 if (
490 parent_path
491 and not parent_path.startswith("<")
492 and not parent_path.startswith("/")
493 and not name.startswith("/")
494 ):
495 file_dir = posixpath.dirname(parent_path)
496 name = posixpath.normpath(posixpath.join(file_dir, name))
497 return name
498
499 def _create_template(self, name: str) -> Template:
500 return Template(self.dict[name], name=name, loader=self)
501
502
503class _Node(object):

Calls

no outgoing calls