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") |
||
---|---|---|
.. | ||
2011-03-21-long-time.markdown | ||
2011-03-24-school-memories.markdown | ||
2011-03-26-earth-hour-official-video.markdown | ||
2011-03-26-firefox.markdown | ||
2011-04-01-compski-night-firends-and-fun.markdown | ||
2011-04-05-sharing-the-posterous-way.markdown | ||
2011-04-19-bed-of-roses.markdown | ||
2011-04-20-happy.markdown | ||
2011-04-28-adept.markdown | ||
2011-05-02-the-story-of-linux.markdown | ||
2011-05-07-gsoc-2011-i-am-in.markdown | ||
2011-05-14-welcome-to-acm-courtesy-of-google.markdown | ||
2011-05-28-hmm-vacation-work-time.markdown | ||
2011-06-04-distributed-computing.markdown | ||
2011-06-05-random-reverbations.markdown | ||
2011-07-19-birthday-food-for-thought.markdown | ||
2011-08-23-sigsegv.markdown | ||
2011-08-30-what-you-do-when-you-get-a-free-day.markdown | ||
2011-09-10-good-to-be-back.markdown | ||
2011-09-11-nothing-else-matters.markdown | ||
2011-09-16-crazy.markdown | ||
2011-10-11-ffmepg-nokia-7210-video-clips.markdown | ||
2011-10-11-latex-on-the-go.markdown | ||
2011-10-28-falling-slowly.markdown | ||
2012-01-09-arrow-keys-input-in-python.markdown | ||
2012-03-18-progress-bar-in-mercurial-pushpull.markdown | ||
2012-03-29-thamarassery-mountain-pass-wayanad.markdown | ||
2012-11-21-netbsd-chronicles.markdown | ||
2012-11-24-my-perfect-terminal.markdown | ||
2012-12-06-rooting-a-nexus-7.markdown | ||
2012-12-12-name-your-servers.markdown | ||
2013-01-01-a-thank-you-note.markdown | ||
2013-05-03-new-home.markdown | ||
2013-05-28-getting-started-with-rtems-on-archlinux.markdown | ||
2013-05-28-summer-of-code-2013.markdown | ||
2013-06-23-debugging-rtems-with-gdb.markdown | ||
2014-08-16-automatic-log-in-for-act-broadband.markdown | ||
2015-02-21-syslog-on-mac-os-x-cheat-sheet.markdown | ||
2015-03-28-state-of-terminal-2015-edition.markdown | ||
2015-03-29-notes-on-cgo.markdown | ||
2015-06-30-static-site-generators.markdown | ||
2015-08-22-recursion.markdown | ||
2015-12-01-a-random-rant.markdown | ||
2015-12-28-swanthathralokam.markdown | ||
2016-01-14-golang-shorthand-operator-allows-accidental-shadowing-of-variable.markdown | ||
2017-08-02-linux-4.12.markdown | ||
2018-03-08-kuhs.markdown | ||
2018-08-04-freebsd-wifi-configuration.markdown | ||
2019-01-08-recurse-center-day-#-2.markdown | ||
2019-01-20-experiments-in-owning-data.markdown | ||
2019-01-23-experiments-in-owning-data:-software.markdown |