Passes commandline args to other files
parent
1f2bb280d5
commit
f86e41b68e
|
@ -0,0 +1,57 @@
|
|||
# https://www.w3schools.io/file/yaml-arrays/
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
import classes
|
||||
import verify
|
||||
|
||||
def main(argv):
|
||||
if len(argv) > 1:
|
||||
parseFile(argv[1])
|
||||
else:
|
||||
raise Exception("Error: must provide a source file")
|
||||
|
||||
def parseFile(fileName):
|
||||
config = {}
|
||||
|
||||
with open(fileName, 'r') as file:
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
aliases = bool("aliases" in config)
|
||||
|
||||
# See verify.py
|
||||
config = verify.verifyConfig(config)
|
||||
if "errors" in config:
|
||||
for e in config["errors"]:
|
||||
print(e,file=sys.stderr)
|
||||
return
|
||||
|
||||
parseConfig(config)
|
||||
|
||||
def parseConfig(config):
|
||||
for currentClass in ["scout", "soldier", "pyro", "demo", "heavy", "sniper", "default"]:
|
||||
if currentClass in config:
|
||||
outfile = open("cfg/temp_"+currentClass+".cfg", "w")
|
||||
outfile.write(classes.regularClass(config.pop(currentClass)))
|
||||
|
||||
if "engi" in config:
|
||||
outfile = open("cfg/temp_engi.cfg", "w")
|
||||
outfile.write( classes.engi(config.pop("engi")) )
|
||||
config.pop("engi")
|
||||
|
||||
elif "medic" in config:
|
||||
outfile = open("cfg/temp_medic.cfg", "w")
|
||||
outfile.write( classes.getMedicConfig(config) )
|
||||
config.pop("medic")
|
||||
|
||||
elif "spy" in config:
|
||||
outfile = open("cfg/temp_spy.cfg", "w")
|
||||
outfile.write( classes.getSpyConfig(config) )
|
||||
config.pop("spy")
|
||||
|
||||
elif "default" in config:
|
||||
outfile = open("cfg/temp_default.cfg", "w")
|
||||
outfile.write( classes.getDefaultConfig(config) )
|
||||
config.pop("default")
|
||||
|
||||
main(sys.argv)
|
Loading…
Reference in New Issue