forked from 7Cav/cScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_loadout_classnames.py
More file actions
34 lines (28 loc) · 964 Bytes
/
check_loadout_classnames.py
File metadata and controls
34 lines (28 loc) · 964 Bytes
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
#!/usr/bin/env python3
import sys, os, re, json, glob
__version__ = 1.0
# set projecty path
scriptPath = os.path.realpath(__file__)
scriptDir = os.path.dirname(scriptPath)
rootDir = os.path.dirname(os.path.dirname(scriptPath))
os.chdir(rootDir)
def strip_path_from_filename(pathfile=''):
filenamepath = pathfile.split('/')
filename = filenamepath[-1]
filename = str(filename)
return filename
def main():
data = {}
loadoutConfigs = glob.glob(rootDir + '/cScripts/Loadouts/*.hpp')
for loadout in loadoutConfigs:
cfgFile = open(loadout)
configName = os.path.basename(loadout)
data[configName] = []
CfgLoadout = cfgFile.read()
classnames = re.findall('%s(.*)%s' % ('class', ':'), CfgLoadout)
for classname in classnames:
classname = classname.strip()
data[configName].append(classname)
print(json.dumps(data))
if __name__ == "__main__":
sys.exit(main())