Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _test_convert_from_file(self, input, expected_output, format):
with tempfile.NamedTemporaryFile('w') as fdin:
fdin.write(input)
fdin.flush()
with tempfile.NamedTemporaryFile('r') as fdout:
HOCONConverter.convert_from_file(fdin.name, fdout.name, format)
with open(fdout.name) as fdi:
converted = fdi.read()
assert [line.strip() for line in expected_output.split('\n') if line.strip()]\
== [line.strip() for line in converted.split('\n') if line.strip()]
# Python 2.6 support
def null_handler():
return logging.NullHandler() if hasattr(logging, 'NullHandler') else logging.FileHandler('/dev/null')
logger = logging.getLogger()
log_handler = logging.StreamHandler() if args.verbosity > 0 else null_handler()
log_handler.setFormatter(logging.Formatter(LOG_FORMAT))
logger.addHandler(log_handler)
if args.verbosity == 1:
logger.setLevel(logging.ERROR)
elif args.verbosity == 2:
logger.setLevel(logging.INFO)
elif args.verbosity >= 3:
logger.setLevel(logging.DEBUG)
HOCONConverter.convert_from_file(args.input, args.output, args.format.lower(), args.indent, args.compact)