Skip to main content

Python replacement for java.util.Properties.

Project description

About

This is a “fork” of the “python replacement for java.util.Properties” recipe on ASPN: <http://code.activestate.com/recipes/496795/> and uploaded by Anand Balachandran Pillai.

The project is primarily maintained by Jesse Noller.

License

As with all ASPN recipes not otherwise licensed, the original recipe is under the MIT License. For more information, see the ASPN terms of service here:

<http://code.activestate.com/help/terms/>

This project continues with the MIT License. No sense in changing it.

What this is

This module is designed to be a python equivalent to the java.util.Properties class. Currently, the basic input/output methods are supported, and there are plans to add the XML input/output methods found in J2SE 5.0.

Fundamentally, this module is designed so that users can easily parse and manipulate Java Properties files - that’s it. There’s a fair number of us pythonistas who work in multi-language shops, and constantly writing your own parsing mechanism is just painful. Not to mention Java guys are notoriously unwilling to use anything which is cross-language for configuration, unless it’s XML, which is a form of self-punishment. :)

Plans

Here is a rough plan of features:

  • Make the module compatible with the new methods in J2SE 5.0

  • Switch to/add python property access rather than direct dictionary get/set

  • Add unit tests

  • Add unicode support

  • When-Pigs-Fly: If running within Jython, switch to java.util.Properties under the hood

  • Coercion/conversion to python types for values

Usage

This is the easy part:

from pyjavaproperties import Properties
p = Properties()
p.load(open('test2.properties'))
p.list()
print p
print p.items()
print p['name3']
p['name3'] = 'changed = value'
print p['name3']
p['new key'] = 'new value'
p.store(open('test2.properties','w'))

See also the Properties.list() method, which will return an iterator over the property keys

Changes & News

0.1:
  • Initial release/fork.

  • Added setup/packaging and doc

  • added in {foo} style references for previous properties, thanks to N B on ASPN. Need to document.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjavaproperties-0.1.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file pyjavaproperties-0.1.tar.gz.

File metadata

File hashes

Hashes for pyjavaproperties-0.1.tar.gz
Algorithm Hash digest
SHA256 f6faae1dcf2da9474409ffbf4363f574b28fc8f419a710a5223602d8d2cb8b04
MD5 af9625deee8a70bcef5f0aa5dbffc802
BLAKE2b-256 30e4a5d0c7fec0ff9ca2b0fc73e1cacaac4678690b33fc1ef1a0916e6e551c6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page