/
copy_files.py
64 lines (53 loc) · 1.6 KB
/
copy_files.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
import os
from shutil import copyfile
import argparse
def create_from_and_to(TargetDir, GameModFolder, ModName, file):
return ["%s\%s" % (TargetDir, file), "%s\%s\%s" % (GameModFolder, ModName, file)]
# Make the argument parser
parser = argparse.ArgumentParser(description="Perform copy operations")
parser.add_argument(
"--ModName", metavar="M", type=str, nargs=1, help="The name of the mod"
)
parser.add_argument(
"--TargetDir",
metavar="T",
type=str,
nargs=1,
help="The dir of the compiled results",
)
parser.add_argument(
"--GameModFolder",
metavar="G",
type=str,
nargs=1,
help="The path to the game directory",
)
# Parse the arguments
args = parser.parse_args()
ModName = args.ModName[0]
TargetDir = args.TargetDir[0]
GameModFolder = (
args.GameModFolder[0]
if args.GameModFolder != None and len(args.GameModFolder) > 0
else None
)
# Find the path to the game folder
if GameModFolder == None:
GameModFolder = (
"C:\Program Files (x86)\GOG Galaxy\Games\Pillars of Eternity II Deadfire\Mods"
)
# If we cannot find the game folder we can do nothing
if not os.path.exists(GameModFolder):
exit(0)
# Copy the files
files_to_copy = []
files_to_copy.append(
create_from_and_to(TargetDir, GameModFolder, ModName, "%s.dll" % ModName)
)
files_to_copy.append(create_from_and_to(TargetDir, GameModFolder, ModName, "info.json"))
path_name = "%s\%s" % (GameModFolder, ModName)
if not os.path.exists(path_name):
os.mkdir(path_name)
for file_copy in files_to_copy:
print("%s %s" % (file_copy[0], file_copy[1]))
copyfile(file_copy[0], file_copy[1])