mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-12-22 12:50:23 +01:00
A bit of code clean up
This commit is contained in:
parent
502769882a
commit
65a0811e1d
0
generated.md → irrelevant/generated.md
vendored
0
generated.md → irrelevant/generated.md
vendored
0
initial.md → irrelevant/initial.md
vendored
0
initial.md → irrelevant/initial.md
vendored
@ -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"]
|
Loading…
x
Reference in New Issue
Block a user