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
dict getJavaProperties(file)
- Args:
- file: a valid file object (as returned by
open(filename)
)
- file: a valid file object (as returned by
- Returns:
- The property key and elements as a dict
- Raises:
IOError
: if file operation fails with I/O related reason- Corresponds to java
IOException
inProperties.load()
- Corresponds to java
UnicodeDecodeError
: if the property file has malformed\uxxxx
encoding,- Corresponds to java
IllegalArgumentException
inProperties.load()
- Corresponds to java
AttributeError
: if invalid object was provided for file object- Corresponds to java
NullPointerException
- Corresponds to java
import jprops
props = jprops.getJavaProperties(open("demo.properties"))
print props['greeting']
$ cat demo.properties
greeting = hello world
$ python demo.py
hello world