-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetfiles.py
More file actions
38 lines (31 loc) · 1.19 KB
/
getfiles.py
File metadata and controls
38 lines (31 loc) · 1.19 KB
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
import os
import re
def getTitle(s):
# print(s)
for i in s:
if i.find("title") != -1:
return(i[i.find(">")+1:i.find("<",6)])
dirs = [ dir for dir in os.listdir() if os.path.isdir(dir) and dir[0]!='.' and dir!="Navbar"]
readme = open("README.md",'w')
index = open("index.html",'w')
navbar_data = "<h3><span> IP Assignments</span></h3>\n"
readme.write('# <a href="https://jayesh2812.github.io/Internet-Programming/">Internet-Programming</a>\n')
index.write('<h1> <a href="https://jayesh2812.github.io/Internet-Programming/">Internet-Programming</a></h1>\n')
index.write('<ol>\n')
readme.write('<ol>\n')
for dir in dirs:
html = open(f"{dir}/index.html")
code = html.readlines()
title = getTitle(code)
readme.write('\t<li> <a href="'+dir+'">'+title+'</a></li>\n')
index.write('\t<li> <a href="'+dir+'">'+title+'</a></li>\n')
navbar_data += '\t<li> <a href="../'+dir+'/">'+title+'</a></li>\n'
readme.write('</ol>\n')
index.write('</ol>\n')
index.close()
readme.close()
navbar = open("./Navbar/navbar.js",'r+')
data = "".join(navbar.readlines())
navbar.seek(0)
navbar.truncate()
navbar.write(data[:data.find("<ul>")+4] +navbar_data+ data[data.find("</ul>"):])