forked from mongodb/docs-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sam Kleinman
committed
Aug 19, 2014
1 parent
4231325
commit bda44f7
Showing
8 changed files
with
96 additions
and
27 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 |
---|---|---|
@@ -1,2 +0,0 @@ | ||
|
||
|
||
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
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,76 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
flask_environments | ||
~~~~~~~~~~~~~~~~~~ | ||
Environment tools and configuration for Flask applications | ||
:copyright: (c) 2012 by Matt Wright. | ||
:license: MIT, see LICENSE for more details. | ||
:source: https://github.com/mattupstate/flask-environments | ||
""" | ||
|
||
import os | ||
|
||
import yaml | ||
from flask import current_app | ||
|
||
|
||
class Environments(object): | ||
|
||
def __init__(self, app=None, var_name=None, default_env=None): | ||
self.app = app | ||
self.var_name = var_name or 'FLASK_ENV' | ||
self.default_env = default_env or 'DEVELOPMENT' | ||
self.env = os.environ.get(self.var_name, self.default_env) | ||
|
||
if app is not None: | ||
self.init_app(app) | ||
|
||
def init_app(self, app): | ||
app.config['ENVIORNMENT'] = self.env | ||
|
||
if app.extensions is None: | ||
app.extensions = {} | ||
|
||
app.extensions['environments'] = self | ||
|
||
def get_app(self, reference_app=None): | ||
if reference_app is not None: | ||
return reference_app | ||
if self.app is not None: | ||
return self.app | ||
return current_app | ||
|
||
def from_object(self, config_obj): | ||
app = self.get_app() | ||
|
||
for name in self._possible_names(): | ||
try: | ||
obj = '%s.%s' % (config_obj, name) | ||
app.config.from_object(obj) | ||
return | ||
except: | ||
pass | ||
|
||
app.config.from_object(config_obj) | ||
|
||
def from_yaml(self, path): | ||
with open(path) as f: | ||
c = yaml.load(f) | ||
|
||
for name in self._possible_names(): | ||
try: | ||
c = c[name] | ||
except: | ||
pass | ||
|
||
app = self.get_app() | ||
|
||
for key in c.iterkeys(): | ||
if key.isupper(): | ||
app.config[key] = c[key] | ||
|
||
def _possible_names(self): | ||
return (self.env, self.env.capitalize(), self.env.lower()) |
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
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
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
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 |
---|---|---|
|
@@ -2,27 +2,27 @@ | |
|
||
from setuptools import setup, find_packages | ||
|
||
REQUIRES = ['argh', 'polib', 'flask', 'gunicorn', 'pymongo', | ||
'pyYAML', 'flask-environments'] | ||
REQUIRES = ['argh', 'polib', 'flask', 'gunicorn', 'pymongo', 'pyyaml', | ||
'flask-environments'] | ||
|
||
setup( | ||
name='pharaoh', | ||
maintainer='judahschvimer', | ||
maintainer_email='[email protected]', | ||
description='PO File Translation Verifier', | ||
maintainer='tychoish', | ||
maintainer_email='[email protected]', | ||
author='judahschvimer', | ||
author_email='[email protected]', | ||
description='PO File Translation Verification Web App', | ||
version=pharaoh.__version__, | ||
license='Apache 2.0', | ||
url='http://github.com/mongodb/docs-tools.git', | ||
packages=find_packages(), | ||
test_suite=None, | ||
install_requires=REQUIRES, | ||
package_data={'pharaoh': ['quickstart/*']}, | ||
classifiers=[ | ||
'Environment :: Console', | ||
'Intended Audience :: Developers', | ||
'Topic :: Documentation', | ||
'Topic :: Software Development :: Testing', | ||
'Topic :: Translation', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 2', | ||
'License :: OSI Approved :: Apache Software License', | ||
|
@@ -31,5 +31,5 @@ | |
'console_scripts': [ | ||
'pharaoh = pharaoh.cmdline:main', | ||
], | ||
}, | ||
) | ||
}, | ||
) |
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