made small changes to make pylint shut up
parent
e57c8f4e70
commit
d504156123
9
cli.py
9
cli.py
|
@ -1,14 +1,16 @@
|
||||||
|
"""CLI module for converting YAML to tfscript"""
|
||||||
# https://www.w3schools.io/file/yaml-arrays/
|
# https://www.w3schools.io/file/yaml-arrays/
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import yaml
|
|
||||||
import argparse
|
import argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import yaml
|
||||||
|
|
||||||
import classes
|
import classes
|
||||||
import verify
|
import verify
|
||||||
|
|
||||||
def parseFile(inputFile):
|
def parseFile(inputFile):
|
||||||
|
"""Parse, verify, and do the conversion."""
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
config = yaml.safe_load(inputFile)
|
config = yaml.safe_load(inputFile)
|
||||||
|
@ -24,17 +26,18 @@ def parseFile(inputFile):
|
||||||
parseConfig(config)
|
parseConfig(config)
|
||||||
|
|
||||||
def parseConfig(config):
|
def parseConfig(config):
|
||||||
|
"""With validated data structure, write out all the files."""
|
||||||
global args
|
global args
|
||||||
for currentClass in config:
|
for currentClass in config:
|
||||||
outfile = tempfile.NamedTemporaryFile( prefix=currentClass, delete=False )
|
outfile = tempfile.NamedTemporaryFile( prefix=currentClass, delete=False )
|
||||||
if args.debug:
|
if args.debug:
|
||||||
print( 'created {} '.format(outfile.name))
|
print( f'created {outfile.name} ')
|
||||||
|
|
||||||
classDict = config[currentClass]
|
classDict = config[currentClass]
|
||||||
stringToWrite = classes.makeCFG(classDict)
|
stringToWrite = classes.makeCFG(classDict)
|
||||||
outfile.write(stringToWrite.encode("utf8"))
|
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()
|
outfile.close()
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
|
|
Loading…
Reference in New Issue