'''
2021-05-22
To Dead Code
Created on Mar 7, 2019
@author: Brett Paufler
Copyright Brett Paufler
For use in Processing Fast Reads
Skip & Skim Book Revies
SF Books
Graphic Books
And the like
Input: iPhone notes email (no pictures)
Output: HTML Page Requiring Minimal Editing
2019-03-10: Looking Good
'''
from utilities_email_refactored import text_iterator_eml
from utilities_txt_files_refactored import text_iterator_txt
from utilities_text_refactored import label_text
from utilities_text_refactored import three_head_label_to_html
from utilities_text_refactored import escape_sequences
from datetime import date
from itertools import chain
YEAR = '2020'
PAGE_TITLE_TEMPLATE = None #title
COMMENT_TEMPLATE = '
\n
\n
\n\n\n' #comment
BOOK_TITLE_TEMPLATE = '\n
\n
\n%s
\n' #head_0
BOOK_TAG_TEMPLATE = '%s
\n' #head_1
AUTHOR_TEMPLATE = '%s
\n' #head_2
HEAD_TEMPLATE = '''
%s
Brett's
Books
A Fast Fifteen
%s
'''
FOOTER_TEMPLATE = '''
next
Brett's
Books
entry
Home
Brett's
Books
Index
© copyright %s Brett Paufler
Brett@Paufler.net
'''
text_iterators = chain(
text_iterator_eml(),
text_iterator_txt())
for text_in in text_iterators:
#Slice Off the Page Name
labelled = label_text(text_in)
name = labelled[0][1]
labelled = labelled[1:]
#Call Label Parser
html_body = three_head_label_to_html(
labeled_list=labelled,
page_title_template=PAGE_TITLE_TEMPLATE,
comment_template=COMMENT_TEMPLATE,
book_title_template=BOOK_TITLE_TEMPLATE,
book_tag_template=BOOK_TAG_TEMPLATE,
author_template=AUTHOR_TEMPLATE)
#Assemble the HTML PAGE
html_head = HEAD_TEMPLATE % (name, name)
html_footer = FOOTER_TEMPLATE % (YEAR)
html_page = html_head + html_body + html_footer
#A Bit of Correction
html_page = escape_sequences(html_page)
print html_page
#Create save_name
date_out = str(date.today()) #.replace('-', '_')
name_out = name.replace(' ', '_').lower()
save_name = './output/000_%s - %s - 1 - eclipse export.html' % (
name_out, date_out)
with open(save_name, 'w') as f:
f.write(html_page)
print name
#print date.isoformat()
print date.today()
\n