pyjavaprops
Library to read Java style properties files. I don’t particularly like properties files but working with them in Java is very easy. I recently had to support reading Java properties files using Python.
This project is based on Benjamins Brent fork of pyjavaproperties.
The libraries main features are:
Reads properties files.
You can add new properties.
You can save properties to file.
It interprets variables in curly braces {} and dollar curly braces ${}.
Caveats
The library does not interpret unicode characters correctly. If you include charactes like u4500 it will interpret it as , letter y and the number 4500.
Installation
Requires Python 3.3 or better.
$ pip install pyjavaprops
Usage
Loading Java properties
filename = os.path.join(TEST_DATA_FOLDER, 'iso-8859-1.properties')
iso_8859_1_properties = JavaProperties()
with open(filename, encoding='iso-8859-1') as property_file:
iso_8859_1_properties.load(property_file)
name = iso_8859_1_properties['name']
Saving Java properties to file
filename = os.path.join(TEST_DATA_FOLDER, 'simple.properties')
simple_java_properties = JavaProperties()
with open(filename) as property_file:
simple_java_properties.load(property_file)
simple_java_properties['country'] = 'Angola'
output_filename = os.path.join(OUTPUT_FOLDER, 'simple_%s.properties' % datetime.now().strftime('%Y%m%d_%H%M'))
with open(output_filename, mode='w') as output:
simple_java_properties.store(output)
Exporting to json
output_filename = os.path.join(OUTPUT_FOLDER, 'simple_%s.json' % datetime.now().strftime('%Y%m%d_%H%M'))
export_to_json(output_filename, java_properties)
with open(output_filename) as json_data:
json_properties = json.load(json_data)
print(json_properties['Key10'])
Development
Virtual Environment
To create the virtual environment
$ cd ~/virtual_environments
$ python3 /usr/local/lib/python3.4/site-packages/virtualenv.py --no-site-packages pyjavaprops_env
$ source ./pyjavaprops_env/bin/activate
(pyjavaprops_env) $
Runnig Tests
$ coverage run --source pyjavaprops setup.py test
Metadata
Release files for pyjavaprops 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyjavaprops-1.0.2.tar.gz | 7.2 kB | Without provenance | Details for pyjavaprops-1.0.2.tar.gz |
Release files / pyjavaprops-1.0.2.tar.gz
| Download URL | pyjavaprops-1.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e1e54e203072e8c0753ac67f10b1c52446d7dc81fbf2b5adec7b9f6c6b9a0d0
|
|
BLAKE2b-256 checksum How to use checksums |
e6ff3ffbe8fc1cc30212e39aeec551863494731ea913f759b2eec84aca124ae4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyjavaprops 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.