refactor python to support multiple actions

* executable, license header
* prefer `with open` style to auto-close file handles
* keep hardcoding within __main__
This commit is contained in:
Phil Morrell 2022-04-17 14:14:22 +01:00
parent 585fde2898
commit e451a10bf3
Signed by: emorrp1
GPG Key ID: DBCA65091F248E6C
1 changed files with 11 additions and 6 deletions

17
script.py Normal file → Executable file
View File

@ -1,10 +1,15 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: CC0-1.0
from mako.template import Template
import json
import itertools
import argparse
appTemplate = Template(filename='./spaces.html')
f = open('libregamingspaces.json')
spaces=json.load(f)
def render(spaces, template):
appTemplate = Template(filename=template)
print(appTemplate.render(s=spaces))
print(appTemplate.render(s=spaces))
if __name__ == '__main__':
with open('libregamingspaces.json') as f:
spaces = json.load(f)
render(spaces, './spaces.html')