Example #1
0
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
Example #2
0
 def get_html_table(self):
     '''
         Get the python program as simple html table
     '''
     tbl = table()
 
     for key in sorted(self.lines().keys()):
         row = tr()
         extra_style = ''
         if key == self.current_line:
             extra_style = ' current_line'
         elif key in self.active_break_points:
             extra_style = ' active_break_point'
         elif key in self.break_points:
             extra_style = ' break_point'
         row.append(td(children=[str(key), 
                                 Content(tag_name='a', attrs = { 'name' : str(key)} ) ], 
                       attrs={'class': 'lineno' + extra_style}))
         row.append(td(children=self.lines()[key], 
                       attrs={'class': 'fill' + extra_style}))
         tbl.append(row)
         
     return tbl