-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombine_modset.py
More file actions
47 lines (41 loc) · 1.19 KB
/
combine_modset.py
File metadata and controls
47 lines (41 loc) · 1.19 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
#!/usr/bin/env python3
import os
import modset_common as common
import argparse
parser = argparse.ArgumentParser(
prog="combine_modset.py",
usage="%(prog)s [output] [options]",
description="Adds and subtracts modsets to produce a single preset.",
)
parser.add_argument("output")
parser.add_argument(
"-a",
"--add",
help="a modset to add",
nargs="+",
)
parser.add_argument(
"-s",
"--subtract",
help="a modset to subtract (any mods in these sets will not be included even if they are added more than once)",
nargs="+",
)
args = parser.parse_args()
mods = []
for addition in args.add:
modset = common.ModSet.from_collection_preset(addition)
for mod in modset.mods:
if not mod in mods:
mods.append(mod)
if len(mods) == 0:
raise Exception("No mods specified to add. Use the -a argument to add modsets.")
for subtraction in args.subtract:
modset = common.ModSet.from_collection_preset(subtraction)
for mod in modset.mods:
try:
mods.remove(mod)
except ValueError:
pass
name = os.path.splitext(os.path.basename(args.output))[0]
modset = common.ModSet(name, mods)
modset.export_preset(args.output)