forked from karan/Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
56 lines (53 loc) · 1.35 KB
/
setup.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
48
49
50
51
52
53
54
55
56
# Python script to set up each directory
import os
import os.path
import re
import sys
import codecs
lineDelim = '-'
filenameRegex = "([\*\*])|([/])|(\s)"
filecommentRegex = "([\.\s]|"
#Creates the base file
#name is the name of the file to create without the suffix
#description is the description of the project to make
def createFile(name, desc):
file = open(name , 'w')
file.write("#" + desc)
file.flush()
file.close()
def parseFile(filename):
if(os.path.exists(filename)):
print("Opening project list: " + filename)
file = open(filename, 'r')
nameRegex = re.compile(filenameRegex)
while(True):
line = file.readline()
if(line == ""):
break
elif(nameRegex.match(line) == None or line == '\n'):
continue
else:
line = line.split(lineDelim)
#print(line)
name = nameRegex.subn("", line[0])
name = name[0]
name += ".py"
print(name)
comment = line[1].replace(". ", ".\n#")
createFile(name, comment)
else:
print("No project list")
print("Starting setup process")
#os.chdir(os.path.dirname(sys.argv[0]))
#os.chdir("D:\Dev\Projects\Personal\Python Projects")
print(os.getcwd())
for d in os.listdir(os.curdir):
print(os.path.abspath(d))
if(os.path.isdir(d)):
print("In directory:" + d)
os.chdir(d)
print("Reading project list")
parseFile("README.md")
os.chdir("..")
else:
print("Not a directory")