# pythonpropertyfileloader
[![Downloads](https://static.pepy.tech/badge/property)](https://pepy.tech/project/property)
![Build](https://github.com/anandjoshi91/pythonpropertyfileloader/actions/workflows/python-package.yml/badge.svg)
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/anandjoshi91/a10c3bfcf9d174b0b0119bfd3d8d1c82/raw/pythonpropertyfileloader__main.json)
## A python module to load property files
- Load multiple property files
- Recursively define properties (Similar to [PropertyPlaceholderConfigurer](https://docs.spring.io/spring-framework/docs/2.5.x/javadoc-api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html)) 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](https://pypi.org/project/property/)
```bash
pip install property
```
## Example
### my_file.properties
```bash
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
```python
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
```bash
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/*
```
Raw data
{
"_id": null,
"home_page": "https://github.com/anandjoshi91/pythonpropertyfileloader",
"name": "property",
"maintainer": "",
"docs_url": "https://pythonhosted.org/property/",
"requires_python": "",
"maintainer_email": "",
"keywords": "property,read-property-file,property-interpolation",
"author": "Anand Joshi",
"author_email": "anandhjoshi@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/9f/c4/9b0c508e4482ff13fbff08c68bb532025685c2ca9b09ce206446de1ae904/property-2.6.2.tar.gz",
"platform": null,
"description": "# pythonpropertyfileloader\n\n\n[![Downloads](https://static.pepy.tech/badge/property)](https://pepy.tech/project/property)\n![Build](https://github.com/anandjoshi91/pythonpropertyfileloader/actions/workflows/python-package.yml/badge.svg)\n![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/anandjoshi91/a10c3bfcf9d174b0b0119bfd3d8d1c82/raw/pythonpropertyfileloader__main.json)\n\n## A python module to load property files\n\n- Load multiple property files\n- Recursively define properties (Similar to [PropertyPlaceholderConfigurer](https://docs.spring.io/spring-framework/docs/2.5.x/javadoc-api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html)) in spring which lets you use `${variable-reference}` to refer to already defined property)\n- 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)\n\n## Install\n\nAvailable on [PyPI](https://pypi.org/project/property/)\n\n```bash\npip install property\n```\n\n## Example\n\n### my_file.properties\n\n```bash\nfoo = I am awesome\nbar = ${chocolate}-bar\nchocolate = fudge\nlong = a very long property that is described in the property file which takes up \\\nmultiple lines can be defined by the escape character as it is done here\nurl=example.com/api?auth_token=xyz\nuser_dir=${HOME}/test\nunresolved = ${HOME}/files/${id}/${bar}/\nfname_template = /opt/myapp/{arch}/ext/{objid}.dat\n```\n\n### Code\n\n```python\nfrom properties.p import Property\n\n\n## set use_env to evaluate properties from shell / os environment\nprop = Property(use_env = True)\ndic_prop = prop.load_property_files('my_file.properties')\n\n## Read multiple files\n## dic_prop = prop.load_property_files('file1', 'file2')\n\n\nprint(dic_prop)\n\n# Output\n\n# {'foo': 'I am awesome', 'bar': 'fudge-bar', 'chocolate': 'fudge',\n# 'long': 'a very long property that is described in the property file which takes up multiple lines\n# can be defined by the escape character as it is done here', 'url': 'example.com/api?auth_token=xyz',\n# 'user_dir': '/home/user/test',\n# 'unresolved': '/home/user/files/${id}/fudge-bar/',\n# 'fname_template': '/opt/myapp/{arch}/ext/{objid}.dat'}\n```\n\n## Develop\n\n```bash\ngit clone https://github.com/anandjoshi91/pythonpropertyfileloader.git\ncd pythonpropertyfileloader\n\n## make your changes and open a PR - https://github.com/anandjoshi91/pythonpropertyfileloader/pulls\n## Ensure all tests pass\n\n## Check Dependencies\npip install pipreqs\npipreqs .\n\n## Test\npip install pytest\npytest\n\n## Publish to PyPi\npip install twine\n\nupdate setup.py\npython setup.py sdist bdist_wheel\ntwine check dist/*\ntwine upload dist/*\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A python module to load property files. Recursively define properties, load from env.",
"version": "2.6.2",
"split_keywords": [
"property",
"read-property-file",
"property-interpolation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4c65d7cc19c16cac55d464843b8d5c40bd19e3a196f5d9f81fde1d686087e22f",
"md5": "6a829e24ad0ca58e1b0e00c0f6a17c0a",
"sha256": "643c36a4f072e158d87f67da1a946a581eca4059b356cd6f557f33d3bb1be693"
},
"downloads": -1,
"filename": "property-2.6.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6a829e24ad0ca58e1b0e00c0f6a17c0a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4907,
"upload_time": "2023-02-23T13:21:40",
"upload_time_iso_8601": "2023-02-23T13:21:40.856081Z",
"url": "https://files.pythonhosted.org/packages/4c/65/d7cc19c16cac55d464843b8d5c40bd19e3a196f5d9f81fde1d686087e22f/property-2.6.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9fc49b0c508e4482ff13fbff08c68bb532025685c2ca9b09ce206446de1ae904",
"md5": "f99b25260e88d26484f0059f7699bd22",
"sha256": "9e4a44b554f3d045ee2f8260c15bdd262e658cd98a0a136b30ee96690933cf21"
},
"downloads": -1,
"filename": "property-2.6.2.tar.gz",
"has_sig": false,
"md5_digest": "f99b25260e88d26484f0059f7699bd22",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4468,
"upload_time": "2023-02-23T13:21:42",
"upload_time_iso_8601": "2023-02-23T13:21:42.989656Z",
"url": "https://files.pythonhosted.org/packages/9f/c4/9b0c508e4482ff13fbff08c68bb532025685c2ca9b09ce206446de1ae904/property-2.6.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-23 13:21:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "anandjoshi91",
"github_project": "pythonpropertyfileloader",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "property"
}