made small changes to make pylint shut up
parent
e57c8f4e70
commit
d504156123
15
cli.py
15
cli.py
|
@ -1,14 +1,16 @@
|
|||
"""CLI module for converting YAML to tfscript"""
|
||||
# https://www.w3schools.io/file/yaml-arrays/
|
||||
import sys
|
||||
import os
|
||||
import yaml
|
||||
import argparse
|
||||
import tempfile
|
||||
import yaml
|
||||
|
||||
import classes
|
||||
import verify
|
||||
|
||||
def parseFile(inputFile):
|
||||
"""Parse, verify, and do the conversion."""
|
||||
config = {}
|
||||
|
||||
config = yaml.safe_load(inputFile)
|
||||
|
@ -24,26 +26,27 @@ def parseFile(inputFile):
|
|||
parseConfig(config)
|
||||
|
||||
def parseConfig(config):
|
||||
"""With validated data structure, write out all the files."""
|
||||
global args
|
||||
for currentClass in config:
|
||||
outfile = tempfile.NamedTemporaryFile( prefix=currentClass, delete=False )
|
||||
if args.debug:
|
||||
print( 'created {} '.format(outfile.name))
|
||||
|
||||
print( f'created {outfile.name} ')
|
||||
|
||||
classDict = config[currentClass]
|
||||
stringToWrite = classes.makeCFG(classDict)
|
||||
outfile.write(stringToWrite.encode("utf8"))
|
||||
|
||||
os.replace(outfile.name, './cfg/{}_nscript.txt'.format(currentClass))
|
||||
os.replace(outfile.name, f'./cfg/{currentClass}_nscript.txt')
|
||||
outfile.close()
|
||||
|
||||
# Main function
|
||||
if __name__ == "__main__":
|
||||
if __name__ == "__main__":
|
||||
# Handle command line
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Parse YAML file and produce TF2 config script."
|
||||
)
|
||||
parser.add_argument( '-d', '--debug', action='store_true',
|
||||
parser.add_argument( '-d', '--debug', action='store_true',
|
||||
help="Enable debugging messages.")
|
||||
parser.add_argument( '-n', '--dry-run', action='store_true',
|
||||
help="Parse input file, but don't write anything.")
|
||||
|
|
Loading…
Reference in New Issue