예제 #1
0
파일: py2html.py 프로젝트: rajadg/Python
 def get_full_html(self):
     '''
         Return the python program as full html
     '''
     content = Html(title=str(self.python_source))
     content.head().append(self.get_style_tag())
     content.body().append(self.get_html_table())
     return content
예제 #2
0
파일: py_as_html.py 프로젝트: rajadg/Python
def main():
    
    start = datetime.datetime.now()
    lines = dict()
    tokens = read_tokens()
    prev = None
    for token in tokens:
        make_tag(token, lines, prev)
        prev = token
#         print token
    
    content = Html()
    content.head().append(get_style_tag())
#     content.body().append(h2('source code'))
    tbl = table()
    content.body().append(tbl)

    for key in sorted(lines.keys()):
        row = tr()
        row.append(td(children=str(key), attrs={'class': 'lineno'}))
        row.append(td(children=lines[key], attrs={'class': 'fill'}))
        tbl.append(row)
        
    with open(r'D:\temp\\out.html', 'w') as fp:
        content.write_to(fp)

    time.sleep(1)
    duration = datetime.datetime.now() - start
    print duration