def create_html_table(data): rows = "" for item in data: row = "<tr><td bgcolor=\"#F5F5DC\">{}</td><td bgcolor=\"#F5F5DC\">{}</td><td bgcolor=\"#F5F5DC\">{}</td></tr>\n".format(item[0], ', '.join(item[1]), ', '.join(item[2])) rows += row table = "<table border=\"1\" >\ <tr><th bgcolor=\"#D2691E\"><h2>Path</h2></th>\ <th bgcolor=\"#D2691E\"><h2>Formats found</h2></th>\ <th bgcolor=\"#D2691E\"><h2>Example files</h2></th>\ </tr>\ %s\ </table>\ " %rows html_page ="<!DOCTYPE html>\ <html>\ <head>\ </head>\ <body>\ %s\ </body>\ </html>" %table util.save_to_file("html_file.htm", html_page) return table
def get_and_store_stats(): cfg = read_cfg() res = count_database_docs(cfg) start_time = time.strftime("%m-%d %H:%M", time.gmtime()) record = "Time,%s,files,%s\n" %(str(start_time), res) filename = os.path.join(cfg["core"]["log-path"], "fbs-stats.txt") util.save_to_file(filename, record)