Skip to content

Instantly share code, notes, and snippets.

@Xzonn
Created April 25, 2021 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xzonn/d07820dc1ca02b9510675f38a6ed7c75 to your computer and use it in GitHub Desktop.
Save Xzonn/d07820dc1ca02b9510675f38a6ed7c75 to your computer and use it in GitHub Desktop.
import os
import xml.dom.minidom as xmldom
w = os.walk("./")
f = open("export.txt", "w", 1024 * 16, "utf-8")
for root, dirs, files in w:
for file in files:
if file.endswith(".kup"):
dom = xmldom.parse(os.path.join(root, file))
entries = dom.getElementsByTagName("entry")
if len(entries) > 0:
f.write(os.path.join(root, file) + "\n")
for entry in entries:
name = entry.getAttribute("name")
text = entry.getElementsByTagName("original")[0].firstChild.data.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t")
f.write(f"{name}\t{text}\n")
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment