2

Published on . Updated on .

I improved some Python code in one of the scripts that builds this website.

Here’s the new version:


# part 1
# merge new metadata entries with original metadata
new_metadata = orig_metadata.copy()
new_metadata.update(metadict)

# part 2

# write new metadata
with open(temp_location, "w+") as temp:
     temp.write("---\n")
        # sorting has multiple benefits:
        # make some Elisp tasks easier
        # prevent shuffling order of metadata each script run
        for k in sorted(new_metadata.keys()):
                temp.write(k)
                temp.write(": ")
                temp.write(new_metadata[k])
                temp.write("\n")
     temp.write("---\n")

Tags: upgrade
Go back to Blog Index