58b20109cf
import sys import yaml with open(sys.argv[1]) as fp: data = fp.read() if not data.find("---") == 0: # no head print("NO YAML HEAD FOUND") sys.exit(-1) data = data[3:] head_end = data.find("---") head = data[0:head_end] data = data[head_end+3:] metadata = yaml.safe_load(head) cats = metadata.pop('categories', None) if cats != None: if type(cats) == list: tags = cats elif type(cats) == str: tags = cats.split() tags = list(map(lambda t: t.lower(), tags)) metadata["tags"] = ", ".join(tags) new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}" # write it print(f"coverted: categories to tags: {tags} - {sys.argv[1]}") with open(sys.argv[1], "w") as fp: fp.write(new_data) sys.exit(0) if not metadata.get("tags", None): metadata["tags"] = "untagged" new_data = f"---\n{yaml.dump(metadata, default_flow_style=False)}---{data}" print(f"untagged: {sys.argv[1]}") # write it with open(sys.argv[1], "w") as fp: fp.write(new_data) sys.exit(0) print("No changes needed")
862 B
862 B
author | comments | date | layout | slug | tags | title | wordpress_id |
---|---|---|---|---|---|---|---|
dhananjayishere | true | 2011-08-30 06:12:22 | post | what-you-do-when-you-get-a-free-day | thoughts | What you do when you get a free day? | 67570727 |
By free I never meant something like a holiday you get in ages which exactly pumps you up. By "free" I meant day you dont have a clue to do anything. You suddenly find yourself nothing interesting to do. Gets you bored to the bones. A couple of people can cheer me up these times but unfortunately none are around.
I hate it, because it breaks the barriers I've put in mind to the past. On a blink, mind gets filled with everything that has happened in the twenty years thats me, and most of them are not good things.
Writing never been my favorite, but its the only way left. So I am falling back to my little diary. Nobodys' been a good listener.