Skip to content

Instantly share code, notes, and snippets.

@Yoplitein
Last active August 29, 2015 14:27
Show Gist options
  • Save Yoplitein/373f960e2b136eaab0d3 to your computer and use it in GitHub Desktop.
Save Yoplitein/373f960e2b136eaab0d3 to your computer and use it in GitHub Desktop.
Lists symbols that were added to a Mystcraft age by the grammar.
import difflib
import gzip
import sys
import pynbt
def main():
if len(sys.argv) < 2:
print "diff.py <agedata_x.dat>"
return
file = sys.argv[1]
nbt = None
with gzip.GzipFile(file) as f:
nbt = pynbt.NBTFile(f)
data = nbt["data"]
pages = map(lambda x: x["symbol"].value.encode("utf-8") + "\n", data["Pages"][1:])
symbols = map(lambda x: x.value.encode("utf-8") + "\n", data["Symbols"][:])
for line in difflib.context_diff(pages, symbols, fromfile="Pages", tofile="Resulting Symbols"):
print line,
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment