Mercurial > cgi-bin > hgweb.cgi > tincan
changeset 22:f6a1492fe56e draft
Template loading (includes) pass all tests.
author | David Barts <n5jrn@me.com> |
---|---|
date | Tue, 21 May 2019 16:01:53 -0700 |
parents | ca2029ce95c7 |
children | e8b6ee7e5b6b cf0e52076476 |
files | tincan.py |
diffstat | 1 files changed, 6 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/tincan.py Tue May 21 15:57:15 2019 -0700 +++ b/tincan.py Tue May 21 16:01:53 2019 -0700 @@ -210,7 +210,7 @@ self.expression_types['load'] = \ _LoaderFactory(base, subdir, encoding) self.expression_types['lload'] = \ - _LoaderFactory(os.path.join(base,_WINF,"tlib"), None, encoding) + _LoaderFactory(os.path.join(base,_WINF,"tlib"), [], encoding) class _LoaderFactory(object): """ @@ -235,14 +235,11 @@ self.params = based_on def __call__(self, target, engine): - if self.params.subdir is None: - npath = os.path.join(self.params.base, self.path.lstrip('/')) - else: - try: - normalized = _normpath(self.params.subdir, self.path) - except IndexError: - raise ValueError("invalid path: {0!s}".format(self.path)) - npath = os.path.join(self.params.base, *normalized) + try: + normalized = _normpath(self.params.subdir, self.path) + except IndexError: + raise ValueError("invalid path: {0!s}".format(self.path)) + 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)