-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d7641d
commit bfcbff3
Showing
71 changed files
with
2,417 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
*.local | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache/ | ||
.hypothesis/ | ||
coverage.xml | ||
|
||
# IPython Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
venv/ | ||
ENV/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: python | ||
|
||
python: | ||
- "2.7" | ||
- "3.4" | ||
- "3.5" | ||
- "3.6" | ||
|
||
install: | ||
- "pipenv install --dev" | ||
- "pip install -U -e ." | ||
|
||
script: | ||
- "pipenv run pytest tests" | ||
- "pipenv run flake8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2018 Vladislav Blinov | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[[source]] | ||
url = "https://pypi.python.org/simple" | ||
verify_ssl = true | ||
|
||
[dev-packages] | ||
|
||
pytest = "*" | ||
hypothesis = "*" | ||
"flake8" = "*" | ||
|
||
[packages] | ||
|
||
"e1839a8" = {path = ".", editable = true} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Granula: Multi-file Configurations for Python Applications | ||
============================================== | ||
|
||
.. image:: https://travis-ci.org/chomechome/granula.svg?branch=master | ||
:target: https://travis-ci.org/chomechome/granula | ||
:alt: TravisCI status | ||
|
||
--------------- | ||
|
||
**Granula** is a tool that aims to help maintain multi-file configurations for | ||
Python applications (with environments and more). | ||
|
||
Installation | ||
------------ | ||
|
||
:: | ||
|
||
$ pipenv install granula | ||
|
||
or, in a more familiar way to some (though you should take a look at `pipenv http://pipenv.readthedocs.io/en/latest/`) | ||
|
||
$ pip install granula | ||
|
||
🌈🌈🌈 | ||
|
||
☤ Features | ||
---------- | ||
|
||
- Gathers configurations from multiple files or directories. | ||
- Supports widely used file formats (YAML, JSON). | ||
- Offers a small DSL that allows to load environment variables into config | ||
files. | ||
- Manages different configuration environments (e.g. testing, production). | ||
|
||
☤ Usage | ||
------- | ||
|
||
.. code-block:: python | ||
>> config = granula.Config.from_directory('examples/multi-file/settings') | ||
>> config | ||
Config({'name': 'Darth Vader', ...}) | ||
>> config.name | ||
'Darth Vader' | ||
>> config.occupation | ||
'sith lord' | ||
>> config.family | ||
Config({'fiancee': 'Padme Amidala', 'children': ['Luke', 'Leia']}) | ||
where ``examples/multi-file/settings`` is a directory that contains multiple | ||
configuration files. | ||
|
||
``granula.Config.from_directory`` parses files in the lexicographic order. | ||
Every file is expected to contain a mapping. The values specified in the | ||
preceding files can be overwritten in the succeeding files | ||
(``config.name`` in the example above). | ||
|
||
``granula.Config.from_directory`` takes a ``pattern`` parameter which is used | ||
to match filenames. If a string is passed, it is considered to be a shell-style | ||
wildcard pattern. An object that implements ``granula.pattern.IFilenamePattern`` | ||
can also be passed. See ``examples/environments/`` on how to manage | ||
configuration environments using ``pattern`` parameter. | ||
|
||
Also see ``examples/dsl/`` for examples on how to load environment variables in | ||
config files using ``granula`` DSL. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import os | ||
|
||
import granula | ||
|
||
|
||
if __name__ == '__main__': | ||
# use default value here, specified using 'val' operator | ||
default = granula.Config.from_directory('settings') | ||
|
||
# add SECRET variable to the environment and parse again | ||
os.environ['SECRET'] = 'secret' | ||
secret = granula.Config.from_directory('settings') | ||
|
||
print(default) | ||
print(secret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config: | ||
variable: ${env SECRET|val 'variable'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config: | ||
reference: ${ref config variable} |
Oops, something went wrong.