blogng/blog/2013-01-01-a-thank-you-note.markdown
Dhananjay Balan 58b20109cf Convert from old categories to tags
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")
2019-01-28 17:16:27 -05:00

19 lines
1.1 KiB
Markdown

---
author: dhananjayishere
comments: true
date: 2013-01-01 00:28:00
layout: post
slug: a-thank-you-note
tags: life
title: A Thank You Note.
wordpress_id: 173304734
---
[![4918647118_e1c7e4644f_d](http://dbalan.files.wordpress.com/2013/01/869b2-4918647118_e1c7e4644f_d.jpg)](http://dbalan.files.wordpress.com/2013/01/869b2-4918647118_e1c7e4644f_d.jpg)
Love makes you see the world a lot different than you used to. Life suddenly gets filled with warm glowing colors. Opens up the each and every long sealed corridors of you heart and makes them beat in rhythm, orchestrating a symphony of life. The amount of happiness your life gets filled with might be the real definition of infinity
Being in love is a privilege, Gifted by a heart indeed is the greatest ever. Even parting hearts cant take away your happiness. We loose and keep some fragments and memories weaved in golden threads. For me, they will be sufficient to push the emptiness of existence out for a life time. More than enough to remain in love
_[Photo](http://www.flickr.com/photos/juniperberry/4918647118/sizes/m/in/photostream/) reused under a cc license_