Skip to content

Commit

Permalink
Add t42html - generate html from t42 service.
Browse files Browse the repository at this point in the history
  • Loading branch information
ali1234 committed Mar 25, 2016
1 parent 4062fe5 commit 02cbbf5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions t42html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python

import sys
import os

from teletext.t42.pipeline import reader, make_service
from teletext.t42.packet import Packet

service = make_service(reader(open(sys.argv[1])))

for magazineno,magazine in service.magazines.iteritems():
for pageno,page in magazine.pages.iteritems():

outfile = open(os.path.join(sys.argv[2], '%d%02X.html' % (magazineno, pageno)), 'w')

outfile.write("""<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Page %d%02X</title><link rel="stylesheet" type="text/css" href="teletext.css" /></head>
<body><pre>""" % (magazineno, pageno))

for subpageno,subpage in page.subpages.iteritems():
outfile.write(subpage.to_html(magazineno, pageno, subpageno, magazine.header(magazineno, subpage)))


outfile.write("</pre></body>")

outfile.close()

0 comments on commit 02cbbf5

Please sign in to comment.