diff --git a/appPublic/myTE.py b/appPublic/myTE.py index 0728638..e33f7fb 100755 --- a/appPublic/myTE.py +++ b/appPublic/myTE.py @@ -82,3 +82,17 @@ def tmpTml(f, ns): wf.write(b) return p +if __name__ == '__main__': + import sys + import json + if len(sys.argv) < 3: + print(f'{sys.argv[0]} tmplfile jsonfile') + sys.exit(1) + + te = MyTemplateEngine('.') + with codecs.open(sys.argv[1], 'r', 'utf-8') as f: + tmpl = f.read() + with codecs.open(sys.argv[2], 'r', 'utf-8') as f1: + ns = json.loads(f1.read()) + print(te.renders(tmpl, ns)) + diff --git a/appPublic/sshx.py b/appPublic/sshx.py index 03ee364..1d84e84 100644 --- a/appPublic/sshx.py +++ b/appPublic/sshx.py @@ -113,7 +113,7 @@ class SSHNode: self.conn = await self._connect(**j) @asynccontextmanager - async def getconnector(self): + async def get_connector(self): refconn = None for jj in self.jumpers: j = jj.copy() diff --git a/test/test.json b/test/test.json new file mode 100644 index 0000000..d0b9a3c --- /dev/null +++ b/test/test.json @@ -0,0 +1,4 @@ +{ + "user":"John", + "who":"Thomas" +} diff --git a/test/test.tmpl b/test/test.tmpl new file mode 100644 index 0000000..9494b8e --- /dev/null +++ b/test/test.tmpl @@ -0,0 +1,2 @@ +this is a {{user}}'s documents +{{who}} want it