[](https://travis-ci.org/internap/python-config-probe)
[](http://badge.fury.io/py/config-probe)
Mission
=======
Provide an auto-discovery process of configurations for simple code use. Given a path and a list of pattern,
the result config will be a shortcut to any config.
## Usage
Setup:
config = probe(
path="path/to/my/files",
patterns=["path/(*)/file.yaml"]
)
Use it:
print config.mynamespace.key
## Parameters
- **path**
Initial path to probe. Patterns will be tested against the file structure underneath the path
and it will be ignored in determining the namespacing.
- **patterns**
A list of file paths containing (or not) placeholders "(\*)" o find where the configuration files are located.
The patterns definition order defines which keys has the priority, the last one being the most relevant.
Each placeholder in the path will result in a namespace in the resulting config. So let's say you have a pattern
dir1/(*)/dir2/(*).yaml
If this pattern finds the file : "dir1/**ns1**/dir2/**file**.yaml" that contains "key: 'value'", the resulting
config will be
config.ns1.file.key == "value"
now if the pattern was
dir1/ns1/dir2/file.yaml
for the same file, the resulting config would simply be
config.key == "value"
so you can use placeholders "(\*)" to namespace the resulting config and use "\*" without the parenthesis
to have a variable path without the namespacing
dir1/(*)/dir2/*.yaml
config.ns1.key == "value"
## Mocking the probing
Your unit test can have your code use fake_probe instead to which to give a dict and it will appear as if it
was just probed. Example:
config = fake_probe({
"ns1": {
"file": {
"key": "value"
}
}
})
# then
config.ns1.file.key == "value"
Contributing
============
Feel free to raise issues and send some pull request, we'll be happy to look at them!
[](http://badge.fury.io/py/config-probe)
Mission
=======
Provide an auto-discovery process of configurations for simple code use. Given a path and a list of pattern,
the result config will be a shortcut to any config.
## Usage
Setup:
config = probe(
path="path/to/my/files",
patterns=["path/(*)/file.yaml"]
)
Use it:
print config.mynamespace.key
## Parameters
- **path**
Initial path to probe. Patterns will be tested against the file structure underneath the path
and it will be ignored in determining the namespacing.
- **patterns**
A list of file paths containing (or not) placeholders "(\*)" o find where the configuration files are located.
The patterns definition order defines which keys has the priority, the last one being the most relevant.
Each placeholder in the path will result in a namespace in the resulting config. So let's say you have a pattern
dir1/(*)/dir2/(*).yaml
If this pattern finds the file : "dir1/**ns1**/dir2/**file**.yaml" that contains "key: 'value'", the resulting
config will be
config.ns1.file.key == "value"
now if the pattern was
dir1/ns1/dir2/file.yaml
for the same file, the resulting config would simply be
config.key == "value"
so you can use placeholders "(\*)" to namespace the resulting config and use "\*" without the parenthesis
to have a variable path without the namespacing
dir1/(*)/dir2/*.yaml
config.ns1.key == "value"
## Mocking the probing
Your unit test can have your code use fake_probe instead to which to give a dict and it will appear as if it
was just probed. Example:
config = fake_probe({
"ns1": {
"file": {
"key": "value"
}
}
})
# then
config.ns1.file.key == "value"
Contributing
============
Feel free to raise issues and send some pull request, we'll be happy to look at them!
Release files for config-probe 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| config-probe-0.2.0.tar.gz | 11.1 kB | Details |
Release files / config-probe-0.2.0.tar.gz
| Download URL | config-probe-0.2.0.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4a9050a3046fb5eef7f8ffb7593b33a8ac6a594122911c0a541ed573f1fbeae
|
|
BLAKE2b-256 checksum How to use checksums |
e2be17f796ed7c2d8da893b7bc68494a1377cce23e4dd92fe9a88776059ef5d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.4.6
|