How to use the javaproperties.reading.load function in javaproperties

To help you get started, we’ve selected a few javaproperties 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 jwodder / javaproperties / javaproperties / __main__.py View on Github external
def getproperties(fp, keys):
    keys = set(keys)
    def getprops(seq):
        props = {}
        for k,v in seq:
            if k in keys:
                props[k] = v
        return props
    return load(fp, object_pairs_hook=getprops)
github jwodder / javaproperties / javaproperties / tojson.py View on Github external
def tojson(infile, outfile, encoding):
    """Convert a Java .properties file to JSON"""
    with click.open_file(infile, encoding=encoding) as fp:
        props = load(fp)
    with outfile:
        json.dump(props, outfile, sort_keys=True, indent=4,
                  separators=(',', ': '))
        outfile.write('\n')
github jwodder / javaproperties / javaproperties / __main__.py View on Github external
def format(outfile, separator, file, encoding):
    """ Format/"canonicalize" a Java .properties file """
    with click.open_file(file, encoding=encoding) as fpin:
        with click.open_file(outfile, 'w', encoding=encoding) as fpout:
            dump(load(fpin), fpout, sort_keys=True, separator=separator)