Skip to content

Commit 441ca34

Browse files
committed
configuration
Former-commit-id: 1b81845b96a1fa37fce3671024d28d4be5964882
1 parent 20f9be8 commit 441ca34

File tree

6 files changed

+76
-1
lines changed

6 files changed

+76
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ venv
22
.DS_Store
33
*.pyc
44
fixtures
5+
brisera.yaml

Makefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Shell to use with Make
2+
SHELL := /bin/sh
3+
4+
# Set important Paths
5+
PROJECT := brisera
6+
LOCALPATH := $(CURDIR)/$(PROJECT)
7+
PYTHONPATH := $(LOCALPATH)/
8+
PYTHON_BIN := $(VIRTUAL_ENV)/bin
9+
10+
# Export targets not associated with files
11+
.PHONY: test bootstrap pip virtualenv clean virtual_env_set install
12+
13+
# Clean build files
14+
clean:
15+
find . -name "*.pyc" -print0 | xargs -0 rm -rf
16+
-rm -rf htmlcov
17+
-rm -rf .coverage
18+
-rm -rf build
19+
-rm -rf dist
20+
-rm -rf $(PROJECT).egg-info
21+
22+
# Targets for testing
23+
test:
24+
$(PYTHON_BIN)/nosetests -v --cover-package=$(PROJECT) tests
25+
26+
# Targets for installation
27+
install:
28+
$(PYTHON_BIN)/python setup.py install

brisera/config.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Uses confire to get meaningful configurations from a yaml file
3+
"""
4+
5+
##########################################################################
6+
## Imports
7+
##########################################################################
8+
9+
import os
10+
import confire
11+
12+
##########################################################################
13+
## Configuration
14+
##########################################################################
15+
16+
class BriseraConfiguration(confire.Configuration):
17+
"""
18+
Meaningful defaults and required configurations.
19+
20+
debug: the app will print or log debug statements
21+
testing: the app will not overwrite important resources
22+
"""
23+
24+
CONF_PATHS = [
25+
"/etc/brisera.yaml", # System configuration
26+
os.path.expanduser("~/.brisera.yaml"), # User specific config
27+
os.path.abspath("conf/brisera.yaml"), # Local configuration
28+
]
29+
30+
debug = True
31+
testing = True
32+
33+
34+
## Load settings immediately for import
35+
settings = BriseraConfiguration.load()
36+
37+
if __name__ == '__main__':
38+
print settings

conf/brisera-example.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example configuration file for the Brisera application
2+
# Copy and paste this into a file named "brisera.yaml" and add your
3+
# settings
4+
5+
debug: true
6+
testing: false

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
PyYAML==3.11
2+
confire==0.2.0
13
nose==1.3.4
24
python-dateutil==2.3
35
six==1.8.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
raise ImportError("Could not import \"setuptools\". Please install the setuptools package.")
88

99

10-
packages = find_packages(where=".", exclude=('tests', 'apps', 'docs', 'fixtures', 'venv'))
10+
packages = find_packages(where=".", exclude=('tests', 'apps', 'docs', 'fixtures', 'conf', 'venv'))
1111

1212
requires = []
1313

0 commit comments

Comments
 (0)