-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTodo.py
45 lines (34 loc) · 1.05 KB
/
Todo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
This is a program that will gather all of our "#TODO:" arguments in code, and put them
in one place!
"""
#WIP
import os
todos = {}
for i in os.listdir("./"):
if i.endswith(".py") and i != "Todo.py":
with open(f"./{i}") as file:
content = file.read()
content = content.split("\n")
linenum = 1
for line in content:
if "#TODO:" in line:
temp = line.split("#TODO:")
if len(temp) > 1:
todos["#TODO: " + temp[1]] = {"line": linenum, "file": i}
else:
todos["#TODO: " + temp[0]] = {"line": linenum, "file": i}
linenum += 1
mainstring = "## TODO (auto generated):\n"
for i in todos:
mainstring += f"- {i} at line {todos[i]['line']} in file {todos[i]['file']}\n\n"
with open("plan.md", "r") as file:
content = file.read()
content2 = content.split("## TODO (auto generated):")
if len(content2) > 2:
content = content + mainstring
else:
content = content2[0] + mainstring
with open("plan.md", "w") as file:
file.write(content)
print("[*] Registered todo comments")