View on GitHub

Pythonpropertyfileloader

A python module to load property files. Similar to the Properties class in Java.

Download this project as a .zip file Download this project as a tar.gz file

pythonpropertyfileloader

Build Downloads

A python module to load property files

Install

Available on PyPI

pip install property

Example

my_file.properties

foo = I am awesome
bar = ${chocolate}-bar
chocolate = fudge
long = a very long property that is described in the property file which takes up \
multiple lines can be defined by the escape character as it is done here
url=example.com/api?auth_token=xyz
user_dir=${HOME}/test
unresolved = ${HOME}/files/${id}/${bar}/
fname_template = /opt/myapp/{arch}/ext/{objid}.dat

Code

from properties.p import Property


## set use_env to evaluate properties from shell / os environment
prop = Property(use_env = True)
dic_prop = prop.load_property_files('my_file.properties')


print(dic_prop)

# Output

# {'foo': 'I am awesome', 'bar': 'fudge-bar', 'chocolate': 'fudge',
#  'long': 'a very long property that is described in the property file which takes up multiple lines
#  can be defined by the escape character as it is done here', 'url': 'example.com/api?auth_token=xyz',
#  'user_dir': '/home/user/test',
#  'unresolved': '/home/user/files/${id}/fudge-bar/',
#  'fname_template': '/opt/myapp/{arch}/ext/{objid}.dat'}