From 65a0811e1d83aa7b7c20d4c06c235832739f5d23 Mon Sep 17 00:00:00 2001 From: Satwik Kansal Date: Mon, 22 Jan 2018 18:45:30 +0530 Subject: [PATCH] A bit of code clean up --- add_categories => irrelevant/add_categories | 0 .../generate_contributions.py | 0 generated.md => irrelevant/generated.md | 0 initial.md => irrelevant/initial.md | 0 parse_readme.py => irrelevant/parse_readme.py | 18 +++++++++++------- 5 files changed, 11 insertions(+), 7 deletions(-) rename add_categories => irrelevant/add_categories (100%) rename generate_contributions.py => irrelevant/generate_contributions.py (100%) rename generated.md => irrelevant/generated.md (100%) rename initial.md => irrelevant/initial.md (100%) rename parse_readme.py => irrelevant/parse_readme.py (91%) diff --git a/add_categories b/irrelevant/add_categories similarity index 100% rename from add_categories rename to irrelevant/add_categories diff --git a/generate_contributions.py b/irrelevant/generate_contributions.py similarity index 100% rename from generate_contributions.py rename to irrelevant/generate_contributions.py diff --git a/generated.md b/irrelevant/generated.md similarity index 100% rename from generated.md rename to irrelevant/generated.md diff --git a/initial.md b/irrelevant/initial.md similarity index 100% rename from initial.md rename to irrelevant/initial.md diff --git a/parse_readme.py b/irrelevant/parse_readme.py similarity index 91% rename from parse_readme.py rename to irrelevant/parse_readme.py index 8e9e9eb..6cfbebb 100644 --- a/parse_readme.py +++ b/irrelevant/parse_readme.py @@ -1,4 +1,15 @@ # -*- coding: utf-8 -*- + +""" +This inefficient module would parse the README.md in the initial version of +WTFPython, and enabl me to categorize and reorder a hell lot of examples with +the help of the file `add_categories` (part of which is automatically +generated). + +After the refactor, this module would not work now with necessary updates in +the code. +""" + fname = "README.md" snippets = [] @@ -11,7 +22,6 @@ with open(fname, 'r') as f: # check if it's a H3 if line.startswith("### "): title = line.replace("### ", "") - # print(title, "found") description = [] next_line = lines.next() @@ -20,8 +30,6 @@ with open(fname, 'r') as f: description.append(next_line) next_line = lines.next() - # print("Description captured", description[:10]) - explanation = [] # store lines again until --- or another H3 is encountered while not (next_line.startswith("---") or @@ -29,9 +37,6 @@ with open(fname, 'r') as f: explanation.append(next_line) next_line = lines.next() - # print("explanation captured", explanation[:10]) - - # Store the results finally snippets.append({ "title": title, @@ -75,7 +80,6 @@ with open("add_categories", "r") as f: } content.next() except StopIteration: - print("Done!") for idx, snip in enumerate(snippets): snippets[idx]["category"] = snips_by_title[snip["title"]]["category"]