-
Notifications
You must be signed in to change notification settings - Fork 1
/
compatibilityCore.py
65 lines (56 loc) · 2.35 KB
/
compatibilityCore.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
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 13 15:16:51 2020
@author: AsteriskAmpersand
"""
from compatibility.cclCompatibility import CclCompatibilizer as ccl
from compatibility.ctcCompatibility import CtcCompatibilizer as ctc
from compatibility.materialCompatibility import MaterialCompatibilizer as mrl3
from compatibility.evCompatibility import EVCompatibilizer as ev
from compatibility.wpdatCompatibility import WpDatCompatibilizer as wpdat
class CompatibilityEngine():
def __init__(self,decider = None,inputHandler = None, output = print):
self.mrl3 = mrl3()
self.ctc = ctc()
self.ccl = ccl()
self.ev = ev(decider,inputHandler)
self.wpdat = wpdat()
self.output = output
def detectType(self,filePath):
return {".mrl3":self.mrl3,".ctc":self.ctc,".ccl":self.ccl,
".evwp":self.ev,".evhl":self.ev,".evbd":self.ev,
".wp_dat":self.wpdat, ".wp_dat_g":self.wpdat}[filePath.suffix]
def convert(self,path,debug):
if path.is_dir():
self.recursiveCompatibilize(path,debug)
else:
self.compatibilize(path,debug)
def recursiveCompatibilize(self,root,debug):
for extension in ["*.mrl3","*.ctc","*.ccl","*.evwp","*.evhl","*.evbd",
"*.wp_dat","*.wp_dat_g"]:
for file in root.rglob(extension):
self.compatibilize(file, debug)
def compatibilize(self,filepath,debug):
self.output("Converting %s"%filepath)
compatibilizer = self.detectType(filepath)
try:
compatibilizer.compatibilize(filepath)
except Exception as e:
if not(debug):
self.output("Error compatibilizing %s. Skipped."%filepath)
else:
self.output("Error compatibilizing %s. Error:\n%s"%(filepath,e))
if __name__== "__main__":
from pathlib import Path
import sys
debug = True#False
if len(sys.argv)<2:
path = Path(input("Drag file or directory to update to Iceborne (visuals only).\n").replace('"',"").replace("'",""))
else:
if len(sys.argv)>2:
if sys.argv[2] == "--debug":
debug = True
path = Path(sys.argv[1])
engine = CompatibilityEngine()
engine.convert(path, debug)
input("Conversion Process Completed.")