-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunme.py
65 lines (57 loc) · 2 KB
/
runme.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
57
58
59
60
61
62
63
64
65
import os
import sys
import shutil
import argparse
import DPCM
import ROMImport
import ROMScramble
os.chdir(os.path.dirname(os.path.abspath(__file__)))
Folder = ""
FinalFile = ""
VerboseMode = False
PatchImport = False
if len(sys.argv) > 1:
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', type=str, default='input', help='Input folder')
parser.add_argument('-o', '--output', type=str, default='Final', help='Output filename')
parser.add_argument('-p', '--patches', action='store_true', help='Import patches')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose mode')
args = parser.parse_args()
Folder = args.input
if args.output.split('.')[0] == "Result":
FinalFile = "Final.bin"
else:
FinalFile = args.output.split('.')[0] + ".bin"
PatchImport = args.patches
VerboseMode = args.verbose
else:
Folder = input("Enter the name of the relative folder to import into a ROM image: ")
FinalFile = input("Enter the name of the resulting filename: ")
if FinalFile.split('.')[0] == "Result":
FinalFile = "Final.bin"
else:
FinalFile = FinalFile.split('.')[0] + ".bin"
PatchImportStr = input("Import Patches? (Y if yes) ")
if PatchImportStr == "y" or PatchImportStr == "Y":
PatchImport = True
VerboseModeStr = input("Verbose Mode? (Y if yes) ")
if VerboseModeStr == "y" or VerboseModeStr == "Y":
VerboseMode = True
pathDiv = "/"
if sys.platform == "win32":
pathDiv = "\\"
tmpDir = "tmp"
if os.path.exists(tmpDir):
shutil.rmtree(tmpDir)
shutil.copytree(Folder, tmpDir)
for path, dirc, files in os.walk(tmpDir):
for name in sorted(files):
if name.endswith(".wav"):
shutil.copy(Folder + pathDiv + name, tmpDir + pathDiv + name)
ROMImport.run(tmpDir, PatchImport, VerboseMode)
ROMScramble.run("Result.bin", FinalFile)
#os.remove("sampleList.txt")
os.remove("SampleTable.bin")
os.remove("MultiTable.bin")
shutil.rmtree(tmpDir)
print("Done!")