I have several hundred small HTML files. I want to convert these files to wx.richtext’s XML format.
I tried using the RichTextBuffer
:
buf = wx.richtext.RichTextBuffer()
ok = buf.LoadFile('/tmp/q.html', type=wx.richtext.RICHTEXT_TYPE_HTML)
print(f'load q {ok}')
ok = buf.SaveFile('/tmp/q.xml', type=wx.richtext.RICHTEXT_TYPE_XML)
print(f'save q {ok}')
del buf
buf = wx.richtext.RichTextBuffer()
ok = buf.LoadFile('/tmp/d.html', type=wx.richtext.RICHTEXT_TYPE_HTML)
print(f'load d {ok}')
ok = buf.SaveFile('/tmp/d.xml', type=wx.richtext.RICHTEXT_TYPE_XML)
print(f'save d {ok}')
But in all cases it output False
and didn’t load or save anything.
I know I could use one of Python’s HTML parsers, but don’t want to reinvent the wheel and surely this has been done?
Incidentally, the SaveFile
docs just say “Not all handlers will implement file saving.” They really ought to specify which formats are loadable and which savable.