import csv
import logging
import os
def wrap_url(u):
if u == '' or u.startswith("http"):
return u
return f'http://{u}'
if __name__ == '__main__':
subst = ''
with open('src/src.csv') as file:
logging.info('reading csv')
reader = csv.DictReader(file)
for row in reader:
subst += f'
| {row['service']} | '
if row['url'] == '':
subst += ' | '
else:
subst += f'{row["url"]} | '
if row['ip'] == '':
subst += ' | '
else:
subst += f'{row["ip"]} | '
if row['comment'] == '':
subst += ' | '
else:
subst += f'{row["comment"]} | '
logging.info('write file')
with open('template/template.html') as inf:
with open('index.html', 'w') as outf:
outf.write(inf.read().replace('',subst))
logging.info('done')