Created
February 2, 2020 02:46
-
-
Save Iduoad/0ea5a9d71aa31369628ee7ebd71e677c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def extract_talks(json_file): | |
talks = json.load(json_file) | |
return talks.values() | |
def slugify(a_str): | |
slug = a_str.lower().replace(" ", "-").replace("/", "_")[:50] | |
return slug | |
def to_markdown(a_dict): | |
title = a_dict.get("title") | |
if title: | |
filename = "talks/" + slugify(title) + ".md" | |
print(filename) | |
with open(filename, "w") as fd: | |
fd.write("---\n") | |
for k, v in a_dict.items(): | |
if k != "ideas": | |
fd.write("{}: {}\n".format(k, str(v))) | |
fd.write("---\n") | |
ideas = a_dict.get("ideas") | |
if ideas: | |
ideas_md = list(map(lambda x: "- {}\n".format(x), ideas)) | |
fd.write("".join(ideas_md)) | |
if __name__ == "__main__": | |
with open("notes.json", "r") as fd: | |
talks = extract_talks(fd) | |
for talk in talks: | |
to_markdown(talk) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment