website/extract-hinweise.py

29 lines
919 B
Python
Raw Normal View History

2018-07-24 13:31:39 +02:00
#! /usr/bin/python3
"""Extract the note texts from a notes.osn file to make them printable."""
import sys
def condprint(printstr):
if not printstr.isspace():
print(printstr.strip().replace(
""", '"').replace("newline", "\n"))
with open(sys.argv[1], "rt") as file:
useline = False
for line in file:
if useline:
if '</div>' in line:
condprint(line.split('</div>')[0])
useline = False
else:
condprint(line)
else:
if "<name>" in line:
condprint("newline" +
line.split('<name>')[1].split('</name>')[0])
if '<div class="note-comment-text">' in line:
condprint(line.split('<div class="note-comment-text">'
)[1].split('</div>')[0])
useline = '</div>' not in line