Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import datetime
- import ConfigParser
- import csv
- import os
- from mako.template import Template
- # variables
- config = ConfigParser.ConfigParser()
- rconfig = ConfigParser.RawConfigParser()
- template = Template(filename='worklog.html')
- # load total time from .ini
- config.read("worklog.ini")
- rconfig.read("worklog.ini")
- total_time = config.get("time", "total")
- # calculate and write new total time
- new_total_time = int(total_time)
- total_time_human = str(datetime.timedelta(seconds=new_total_time))
- print "Your work total time is %s" % total_time_human
- # convert csv to dictionary
- input_file = csv.DictReader(open("worklog.csv"))
- # prepare lists
- work_start_var = []
- work_stop_var = []
- work_time_var = []
- work_note_var = []
- # prepare variables for mako
- for row in input_file:
- work_start_var.append(row["date_start"])
- work_stop_var.append(row["date_stop"])
- work_time_var.append(row["work_time"])
- work_note_var.append(row["note"])
- # create html with mako
- with open('index.html','w+') as webdesign:
- webdesign.write(template.render(total_time_html = total_time_human,date_start_html = '<br>'.join(map(str, work_start_var)),date_stop_html = '<br>'.join(map(str, work_stop_var)),work_time_html = '<br>'.join(map(str, work_time_var)),work_note_html = '<br>'.join(map(str, work_note_var))))
- os.system("cp index.html /home/jin/swl/")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement