2016 second

This commit is contained in:
Philip Sargent 2020-04-26 23:36:25 +01:00
parent 680b5dc8c0
commit 008c3c1c39

View File

@ -1,9 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
import os, operator, urllib, json, re import os, operator, urllib, json, re
loser_dir = "/home/expo/loser" loser_dir = "/home/expo/loser"
html_base = "<html><body>%(body)s</body></html>" html_base = "<html><body>%(body)s</body></html>"
html_year_index = html_base % {"body": "<H1>2015 surveys</H1><H2>Persons</H2><UL>%(persons)s</UL><H2>Wallets</H2><table>%(wallets)s</table><H2>Needing Scanning</H2><ul>%(needing scanning)s</ul><H2>Website needing updating</H2><ul>%(website needing updating)s</ul>"} html_year_index = html_base % {"body": "<H1>%(year)s surveys</H1><H2>Persons</H2><UL>%(persons)s</UL><H2>Wallets</H2><table>%(wallets)s</table><H2>Needing Scanning</H2><ul>%(needing scanning)s</ul><H2>Website needing updating</H2><ul>%(website needing updating)s</ul>"}
html_year_person = "<li><a href='%(person)s.html'>%(person)s</a><ul>%(complaints)s</ul></li>" html_year_person = "<li><a href='%(person)s.html'>%(person)s</a><ul>%(complaints)s</ul></li>"
html_year_wallet_entry = "<tr><td><a href='%(walletindex)s'>%(walletname)s %(cave)s %(name)s</a></td> <td>%(complaints)s</td></tr>" html_year_wallet_entry = "<tr><td><a href='%(walletindex)s'>%(walletname)s %(cave)s %(name)s</a></td> <td>%(complaints)s</td></tr>"
html_person_wallet_entry = "<li><a href='%(walletindex)s'>%(walletname)s</a> <ul>%(complaints)s</ul></li>" html_person_wallet_entry = "<li><a href='%(walletindex)s'>%(walletname)s</a> <ul>%(complaints)s</ul></li>"
@ -43,6 +44,9 @@ wallets_needing_scanning = set()
website_needing_updating = set() website_needing_updating = set()
people = {} people = {}
#use dir this file is in to get current year
path,year = os.path.split(os.path.dirname(os.path.realpath(__file__)))
for item in os.listdir("."): for item in os.listdir("."):
if os.path.isdir(item): if os.path.isdir(item):
files = [] files = []
@ -55,6 +59,7 @@ for item in os.listdir("."):
json.dump(blank_json, json_file, indent = 1) json.dump(blank_json, json_file, indent = 1)
json_file.close() json_file.close()
json_file = open(contents_path) json_file = open(contents_path)
print json_file
data = json.load(json_file) data = json.load(json_file)
json_file.close() json_file.close()
write_required = False write_required = False
@ -192,7 +197,7 @@ for person, person_wallets in people.items():
person_summary = dict(person_summary) person_summary = dict(person_summary)
year_index_file = open("index.html", "w") year_index_file = open("index.html", "w")
year_index_file.write(html_year_index % {"persons": reduce(operator.add, [html_year_person % {"person": person, year_index_file.write(html_year_index % {"year": year, "persons": reduce(operator.add, [html_year_person % {"person": person,
"complaints": reduce(operator.add, "complaints": reduce(operator.add,
[html_complaint_items % {"complaint": complaint, [html_complaint_items % {"complaint": complaint,
"count": count} "count": count}