Python Shell Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test Adding python code coverage Jun 20, 2018
.travis.yml
README.md
demo.properties
demo.py
jprops.py

README.md

jprops

Linux build status codecov.io

Read the key, element pairs from a java properties file

Follows the java properties file format and tested against the Java 8 version of java.util.Properties

Documentation

dict getJavaProperties(file)

  • Args:
    • file: a valid file object (as returned by open(filename))
  • Returns:
    • The property key and elements as a dict
  • Raises:
    • IOError: if file operation fails with I/O related reason
      • Corresponds to java IOException in Properties.load()
    • UnicodeDecodeError: if the property file has malformed \uxxxx encoding,
      • Corresponds to java IllegalArgumentException in Properties.load()
    • AttributeError: if invalid object was provided for file object
      • Corresponds to java NullPointerException

Example

import jprops

props = jprops.getJavaProperties(open("demo.properties"))
print props['greeting']
$ cat demo.properties
greeting = hello world
$ python demo.py
hello world