# HG changeset patch # User David Barts # Date 1558919654 25200 # Node ID 4c6d3704e51f4eca058ba40c4c6eb185739d1134 # Parent cf0e5207647689acccc52fc5c7cd52842c85da19 Fails; the thing apparently wants strings and not objects. diff -r cf0e52076476 -r 4c6d3704e51f tincan.py --- a/tincan.py Sun May 26 17:06:32 2019 -0700 +++ b/tincan.py Sun May 26 18:14:14 2019 -0700 @@ -207,9 +207,9 @@ if base is not None: encoding = config.get("encoding", "utf-8") if subdir is not None: - self.expression_types['load'] = \ + self.expression_types['lload'] = \ _LoaderFactory(base, subdir, encoding) - self.expression_types['lload'] = \ + self.expression_types['load'] = \ _LoaderFactory(os.path.join(base,_WINF,"tlib"), [], encoding) class _LoaderFactory(object): @@ -228,9 +228,10 @@ """ Two of two helper classes for the above. """ + _EXTEN = ".pt" def __init__(self, based_on, string): - if not (string.endswith(".pspx") or string.endswith(".pt")): - raise ValueError("loaded templates must end in .pspx or .pt") + if not string.endswith(self._EXTEN): + raise ValueError("loaded templates must end in {0}".format(self._EXTEN)) self.path = string self.params = based_on @@ -242,7 +243,9 @@ npath = os.path.join(self.params.base, *normalized) with open(npath, "r", encoding=self.params.encoding) as fp: contents = fp.read() - value = ast.Str(contents) + value = ast.Call(func=TinCanChameleon, args=[contents], + kwargs={"base": self.params.base, "subdir": self.params.subdir, + "encoding": self.params.encoding}) return [ast.Assign(targets=[target], value=value)] # U t i l i t i e s