Last active
August 29, 2015 14:27
-
-
Save Yoplitein/373f960e2b136eaab0d3 to your computer and use it in GitHub Desktop.
Lists symbols that were added to a Mystcraft age by the grammar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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