Skip to content

Commit ab611ff

Browse files
committed
Updating with details and example of usage
1 parent 1b9c5c9 commit ab611ff

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

README.md

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1-
java-props-in-python
2-
====================
1+
# jprops
32

43
Read the key, element pairs from a java properties file
54

6-
Follows the [java properties file format](http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)) and tested against the Java 6 version of java.util.Properties
7-
8-
Args:
9-
propfile: a valid file object (as returned by open(filename))
10-
Returns:
11-
The property key and elements as a dict
12-
Raises:
13-
IOError: if file operation fails with I/O related reason
14-
Corresponds to java IOException in Properties.load()
15-
UnicodeDecodeError: if the property file has malformed \uxxxx encoding,
16-
Corresponds to java IllegalArgumentException in Properties.load()
17-
AttributeError: if invalid object was provided for file object
18-
Corresponds to java NullPointerException
5+
Follows the [java properties file format](http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html#load(java.io.Reader)) and tested against the Java 8 version of `java.util.Properties`
6+
7+
## Documentation
8+
9+
`dict getJavaProperties(file)`
10+
11+
- Args:
12+
- file: a valid file object (as returned by `open(filename)`)
13+
- Returns:
14+
- The property key and elements as a dict
15+
- Raises:
16+
- `IOError`: if file operation fails with I/O related reason
17+
- Corresponds to java `IOException` in `Properties.load()`
18+
- `UnicodeDecodeError`: if the property file has malformed `\uxxxx` encoding,
19+
- Corresponds to java `IllegalArgumentException` in `Properties.load()`
20+
- `AttributeError`: if invalid object was provided for file object
21+
- Corresponds to java `NullPointerException`
22+
23+
## Example
24+
25+
```
26+
import jprops
27+
28+
props = jprops.getJavaProperties(open("demo.properties"))
29+
print props['greeting']
30+
```
31+
32+
```
33+
$ cat demo.properties
34+
greeting = hello world
35+
```
36+
37+
```
38+
$ python demo.py
39+
hello world
40+
```

0 commit comments

Comments
 (0)