blogng/blog/2011-04-28-adept.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

28 lines
1.0 KiB
Markdown

---
author: dhananjayishere
comments: true
date: 2011-04-28 06:23:27
layout: post
slug: adept
tags: thoughts
title: Adept
wordpress_id: 51072398
---
We all want things to remain same, afraid of change always. set out to
live misery so we can be happy together. I wish I could explain
everything in my damn head and be out of the heavyness I feel now, but
being no natural speaker dont know how to do it without hurting the
dear ones whos life path crosses with mine.
One thing I learned from all this was to hope something that will
never happen was always an easy way out of the miseries in this world,
cheating is the only way to get out and usually cheating yourself.
Trying to let it go from my mind, staring at this screen and trying
not to express my feelings outside this window, I understand what is
mean by transfixing between emotions as someone told me before. I
never believed in saving for future but when it comes to taking hard
decisions its better to cry now than later because crying later means
some other is crying now.