Skip to main content

pythonpropertyfileloader

Downloads Build Coverage Badge

A python module to load property files

  • Load multiple property files
  • Recursively define properties (Similar to PropertyPlaceholderConfigurer) in spring which lets you use ${variable-reference} to refer to already defined property)
  • Placeholders are also resolved using env variables, like the spring property loader does, if the class is instantiated with the use_env argument (defaults to false for backward compatibility)

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')

## Read multiple files
## dic_prop = prop.load_property_files('file1', 'file2')


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'}

Develop

git clone https://github.com/anandjoshi91/pythonpropertyfileloader.git
cd pythonpropertyfileloader

## make your changes and open a PR - https://github.com/anandjoshi91/pythonpropertyfileloader/pulls
## Ensure all tests pass

## Check Dependencies
pip install pipreqs
pipreqs .

## Test
pip install pytest
pytest

## Publish to PyPi
pip install twine

update setup.py
python setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*

Metadata

Release files for property 2.6.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for property 2.6.2
File Size Uploaded
property-2.6.2.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for property 2.6.2
File Interpreter ABI Platform
property-2.6.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / property-2.6.2.tar.gz

Download URL property-2.6.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e4a44b554f3d045ee2f8260c15bdd262e658cd98a0a136b30ee96690933cf21
BLAKE2b-256 checksum
How to use checksums
9fc49b0c508e4482ff13fbff08c68bb532025685c2ca9b09ce206446de1ae904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.0

Release files / property-2.6.2-py3-none-any.whl

Download URL property-2.6.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
643c36a4f072e158d87f67da1a946a581eca4059b356cd6f557f33d3bb1be693
BLAKE2b-256 checksum
How to use checksums
4c65d7cc19c16cac55d464843b8d5c40bd19e3a196f5d9f81fde1d686087e22f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.0

Release history Release notifications | RSS feed

This release

2.6.2 This release

2 release files

2.6.1

2 release files

2.6

1 release file

2.5

1 release file

2.4

1 release file

2.2

1 release file

2.1

1 release file

2.0

1 release file

1.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page