mirror of
https://github.com/mave12/awesome-malware-resources
synced 2024-06-20 13:48:01 +00:00
Add files via upload
This commit is contained in:
parent
7efa58be8e
commit
6bccecd40b
40
create_toc.py
Normal file
40
create_toc.py
Normal file
@ -0,0 +1,40 @@
|
||||
def cleanup(len_of_prefix, line):
|
||||
line = line[line.find(" ")+1:]
|
||||
line = line.lower().strip()
|
||||
line = line.replace(" ","-")
|
||||
line = line.replace("/","")
|
||||
return line
|
||||
|
||||
def add_to_toc(prefix, line):
|
||||
link_description = line[line.find(" ")+1:]
|
||||
pointer = cleanup(len(prefix), line)
|
||||
return prefix + "[" + link_description +"](" + root_path + "#" + pointer + ")"
|
||||
|
||||
root_path = "https://github.com/Sokow86/awesome-malware-resources/blob/main/README.md"
|
||||
f = open("C:\\Users\\ddegroot\\Documents\\GitHub\\awesome-malware-resources\\README.md")
|
||||
toc = "# Table of Contents\n"
|
||||
if(f):
|
||||
line = f.readline() # ignore first line
|
||||
while True:
|
||||
line = f.readline()
|
||||
if(line):
|
||||
if line.startswith("# Table of Contents"):
|
||||
continue
|
||||
elif line.startswith("# "):
|
||||
prefix = "* "
|
||||
elif line.startswith("## "):
|
||||
prefix = " * "
|
||||
elif line.startswith("### "):
|
||||
prefix = " * "
|
||||
elif line.startswith("#### "):
|
||||
prefix = " * "
|
||||
elif line.startswith("##### "):
|
||||
prefix = " * "
|
||||
elif line.startswith("###### "):
|
||||
prefix = " * "
|
||||
else:
|
||||
continue
|
||||
toc = toc + add_to_toc(prefix, line) + "\n"
|
||||
else:
|
||||
break
|
||||
print toc
|
Loading…
Reference in New Issue
Block a user