How to use the pyhocon.converter.HOCONConverter.convert_from_file function in pyhocon

To help you get started, we’ve selected a few pyhocon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chimpler / pyhocon / tests / test_tool.py View on Github external
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()]
github chimpler / pyhocon / pyhocon / tool.py View on Github external
# 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)