from __future__ import print_function
import sys
def nad_extract(fn):
print_once = False
printing = False
for line in open(fn):
if line.startswith("NA Digest"):
print_once = True
fields = line.split()
line = "\n\n" % ('"', fn+".html", '"') + fields[1] + " for " + " ".join(fields[2:-5]) + "
" + "\n"
elif line.startswith("Today's Topics:"):
printing = True
line = "\n
\n"
elif line.startswith("Subscribe, "):
printing = False
line = ""
print_once = True
elif line.startswith(" "):
line = line.strip() + "\n"
elif line.startswith("\t"):
line = line.strip() + "\n"
elif line.startswith("\n"):
line = ""
if printing or print_once:
print(line, end="")
print_once = False
def main(argv):
file_names = argv[1:]
file_names.reverse()
for fn in file_names:
nad_extract(fn)
return 0
sys.exit(main(sys.argv))
.