forked from xinyuecai2016/book
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetBookList.py
executable file
·47 lines (36 loc) · 1.47 KB
/
GetBookList.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
46
47
#!/usr/bin/env python3
import os
import sys
def getPWDFileAndDirs():
return os.listdir(os.getcwd())
def findPos(dir, fileAndDirs):
for i in range(len(fileAndDirs)):
if dir == fileAndDirs[i]:
return i
def PrintTitle(fileObject):
fileObject.write('# 书籍\n个人书籍收藏\n\n无论闲暇还是烦躁都可以坐下来感受纸上之美。:smile:\n')
def GetBookList(fileObject, EmojiMap):
directorys = {}
for eachFileAndDir in getPWDFileAndDirs():
if os.path.isdir(eachFileAndDir) and (not eachFileAndDir.startswith(".")):
directorys[eachFileAndDir] = []
for eachPDF in os.listdir(os.getcwd()+"/"+eachFileAndDir):
directorys[eachFileAndDir].append("[" + eachPDF + "](https://github.com/SuperCV/Book/blob/master/"
+ eachFileAndDir + "/" + eachPDF + ")")
for key, value in directorys.items():
fileObject.write("\n**"+key+"**\n")
for eachfile in value:
fileObject.write("* " + EmojiMap[key] + eachfile + "\n")
fileObject.write("\n")
if __name__ == '__main__':
Emoji = {"CXX" : ":rose:",
"Git" : ":octocat:",
"Python" : ":snake:",
"Qt" : ":battery:",
"JavaScript" : ":elephant:",
"OS" : ":computer:",
"DSAA" : ":anchor:",
}
fileObject = open("README.md", "tw")
PrintTitle(fileObject)
GetBookList(fileObject, Emoji)