1
0
mirror of https://github.com/satwikkansal/wtfpython synced 2024-11-22 02:54:25 +01:00

A bit of code clean up

This commit is contained in:
Satwik Kansal 2018-01-22 18:45:30 +05:30
parent 502769882a
commit 65a0811e1d
5 changed files with 11 additions and 7 deletions

View File

View File

@ -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"]