website/extract-hinweise.py
2019-11-01 23:28:53 +01:00

28 lines
919 B
Python
Executable file

#! /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