Compare commits
3 Commits
a289440187
...
5358fb09b7
Author | SHA1 | Date |
---|---|---|
|
5358fb09b7 | |
|
641cc16250 | |
|
dd78d62f86 |
23
classes.py
23
classes.py
|
@ -1,25 +1,6 @@
|
|||
import keywords
|
||||
|
||||
def regularClass(cfg):
|
||||
def makeCFG(cfg):
|
||||
ret = ''
|
||||
for key, data in cfg.items():
|
||||
ret += keywords.branch("scout", key, data)
|
||||
return ret
|
||||
|
||||
def getEngiConfig(cfg):
|
||||
ret = ''
|
||||
for key, data in cfg["engi"].items():
|
||||
ret += keywords.branch("engi", key, data)
|
||||
return ret
|
||||
|
||||
def getMedicConfig(cfg):
|
||||
ret = ''
|
||||
for key, data in cfg["medic"].items():
|
||||
ret += keywords.branch("medic", key, data)
|
||||
return ret
|
||||
|
||||
def getSpyConfig(cfg):
|
||||
ret = ''
|
||||
for key, data in cfg["spy"].items():
|
||||
ret += keywords.branch("spy", key, data)
|
||||
ret += keywords.branch("foo", "bar")
|
||||
return ret
|
43
cli.py
43
cli.py
|
@ -1,5 +1,6 @@
|
|||
# https://www.w3schools.io/file/yaml-arrays/
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
import tempfile
|
||||
|
@ -19,38 +20,22 @@ def parseFile(inputFile):
|
|||
if "errors" in config:
|
||||
for e in config["errors"]:
|
||||
print(e,file=sys.stderr)
|
||||
# return
|
||||
|
||||
parseConfig(config)
|
||||
else:
|
||||
parseConfig(config)
|
||||
|
||||
def parseConfig(config):
|
||||
for currentClass in ["scout", "soldier", "pyro", "demo", "heavy", "sniper", "default"]:
|
||||
if currentClass in config:
|
||||
outfile = tempfile.NamedTemporaryFile( prefix=currentClass, delete=False )
|
||||
global args
|
||||
for currentClass in config:
|
||||
outfile = tempfile.NamedTemporaryFile( prefix=currentClass, delete=False )
|
||||
if args.debug:
|
||||
print( 'created {} '.format(outfile.name))
|
||||
outfile.write(classes.regularClass(config.pop(currentClass)))
|
||||
os.replace(outfile, './{}_nscript.txt'.format(currentClass))
|
||||
close(outfile)
|
||||
|
||||
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")
|
||||
|
||||
classDict = config[currentClass]
|
||||
stringToWrite = classes.makeCFG(classDict)
|
||||
outfile.write(stringToWrite.encode("utf8"))
|
||||
|
||||
os.replace(outfile.name, './cfg/{}_nscript.txt'.format(currentClass))
|
||||
outfile.close()
|
||||
|
||||
# Main function
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
def branch(className, key, data):
|
||||
return not (True is not (not False))
|
||||
def branch(key, data):
|
||||
return 'placeholder'
|
Loading…
Reference in New Issue