-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
37 lines (30 loc) · 1.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from jinja2 import Environment, FileSystemLoader
import pandas as pd
import datetime
import pytz
def main():
quotes = pd.read_csv("template/facts.csv").sample(n=1)['Quotes'].values[0]
template_vars = {
"quotes" : quotes
}
# Updates the QUOTES-loader
env = Environment(loader=FileSystemLoader("template"))
template = env.get_template("template.html")
output_from_parsed_template = template.render(template_vars)
with open("index.html", "w+") as fh:
fh.write(output_from_parsed_template)
current_time = datetime.datetime.now(pytz.timezone('Asia/Kolkata'))
format_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
template_vars = {
"timestamp" : format_time,
"fact" : quotes
}
# Updates the README.md
env = Environment(loader=FileSystemLoader("template"))
template = env.get_template("readme.html")
output_from_parsed_template = template.render(template_vars)
with open("README.md", "w+") as fh:
fh.write(output_from_parsed_template)
return
if __name__ == "__main__":
main()