This repository was archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmt_convert.py
More file actions
57 lines (43 loc) · 1.41 KB
/
mt_convert.py
File metadata and controls
57 lines (43 loc) · 1.41 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python
import sys
import os.path
if len(sys.argv) == 1:
print("filepath not provided")
exit()
elif not os.path.exists(sys.argv[1]):
print("invalid file path")
exit()
elif os.path.exists(os.path.join(sys.argv[1], "mod.conf")):
print("mod.conf already exists!")
exit()
descpath = os.path.join(sys.argv[1], "description.txt")
deppath = os.path.join(sys.argv[1], "depends.txt")
conffile = open(os.path.join(sys.argv[1], "mod.conf"), "a")
if os.path.exists(descpath):
descfile = open(descpath, "r")
if len(open(descpath).readlines( )) == 1:
conffile.write("description = " + descfile.readline())
else:
conffile.write('description = """\n')
desclines = descfile.readlines()
for i in desclines:
conffile.write(i)
conffile.write('"""\n')
print("[mt_convert]: description.txt converted")
if os.path.exists(deppath):
depfile = open(deppath, "r")
deplines = depfile.readlines()
depends = []
odepends = []
for i in deplines:
i = i.strip()
if i.endswith("?"):
odepends.append(i.rstrip("?"))
else:
depends.append(i)
if depends != "":
conffile.write("depends = " + ", ".join(depends) + "\n")
if odepends != "":
conffile.write("depends = " + ", ".join(odepends) + "\n")
print("[mt_convert]: depends.txt converted")
conffile.close()