From 3a5db78e889399c31fe1fcf4606eb1001e75368a Mon Sep 17 00:00:00 2001 From: Paul Houser Date: Mon, 24 Aug 2020 01:12:34 -0700 Subject: [PATCH] wired up prettifyHTML to format the output nicely --- install.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/install.py b/install.py index c01b7fc..aa80a58 100755 --- a/install.py +++ b/install.py @@ -16,10 +16,9 @@ config_path = home + '/.config/StartTree/config.yaml' # get cache path cache_dir = home + '/.cache/StartTree' -def prettifyHTML(): - html = "

Hello

" +def prettifyHTML(html): soup = BeautifulSoup(html, 'html.parser') - prettyHTML = print(soup.prettify()) + prettyHTML = soup.prettify() return prettyHTML def setup(): @@ -77,7 +76,7 @@ def print_keys(dictionary): def gen_list_indices(html_file, file_dict): for key in file_dict: - print(key) + print() def gen_col_headers(html_file, file_dict): for key in file_dict: @@ -86,7 +85,7 @@ def gen_col_headers(html_file, file_dict): html_file.write(" \n") html_file.write("\n") @@ -111,7 +110,7 @@ def gen_html(file_dict): # open files skeleton_html = open('./skeletons/index.html', 'r') - cache_html = open(cache_dir + '/index.html', 'w') + cache_html = open(cache_dir + '/index.html', 'w+') # copy skeleton_html to cache_html until Column Start comment lines = skeleton_html.readlines() @@ -121,6 +120,14 @@ def gen_html(file_dict): else: cache_html.write(line) + # prettify + cache_html.seek(0) + pretty_string = cache_html.read() + pretty_string = prettifyHTML(pretty_string) + cache_html.close() + cache_html = open(cache_dir + '/index.html', 'w') + cache_html.write(pretty_string) + # close files skeleton_html.close() cache_html.close()