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")
16 lines
696 B
Markdown
16 lines
696 B
Markdown
---
|
|
comments: true
|
|
date: 2015-06-30 00:28
|
|
layout: post
|
|
tags: blogging, octopress, meta
|
|
title: Static site generators
|
|
---
|
|
I use octopress with github hosting my pages.
|
|
Everytime I sit down to write, I have to look up commands in my bash history and read documentation. Its very distracting when you just want to write.
|
|
|
|
Maybe its my workflow thats wrong, I should replace all this with a set of small shell scripts :-P, maybe octopress 3.0 (insert another tool) will solve this.
|
|
|
|
But at this point I dont even remember which branch in my repo has what, and I should switch to a firendlier paltform (ghost or posthaven) or do a massive cleanup ASAP.
|
|
|
|
_EDIT: I finally managed to do that clean up_
|