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
""" | |
For reference wtforms.core.FloatField | |
------------------------------------- | |
class FloatField(Field): | |
widget = widgets.TextInput() | |
def __init__(self, label=None, validators=None, **kwargs): | |
super(FloatField, self).__init__(label, validators, **kwargs) |
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
import os | |
from cStringIO import StringIO | |
import tarfile | |
from flask import Flask, Response | |
app = Flask(__name__) | |
def get_string_io_len(s): |
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
existing_hash = {:foo=>"bar"} | |
other_hash.each_pair do |key, value| | |
if some_condition | |
existing_hash[key] = value | |
end | |
end |
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
import os | |
class WSGIApp(object): | |
def __init__(self): | |
setup_logger(os.environ.get('PYCSW_CONFIG')) | |
def __call__(self, env, start_repsonse): | |
""" Do reqeust stuff here """ | |
application = WSGIApp() |
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
def api_url_for(endpoint, **values): | |
# probably handle missing api_app key in some | |
# special exception. | |
api_app = current_app().config["api_app"] | |
with api_app.app_context(): | |
return url_for(end_point, **values) | |
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
from exampleapp import app | |
import IPython | |
app.testing = True | |
test_client = app.test_client() | |
welcome_message = """Welcome to your Flask CLI environment. | |
The following variables are available to use: | |
app -> Your Flask app instance. |
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
#!/bin/bash | |
DIR=$( cd "$( dirname "$0" )" && pwd ) | |
source $DIR/../env.sh | |
if [ ! X_OPENSHIFT_RUNNING_LOCAL ]; then | |
source $X_OPENSHIFT_VENV/bin/activate | |
fi |
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
#!/bin/bash | |
# | |
# .openshift/action_hooks/build | |
# | |
DIR=$( cd "$( dirname "$0" )" && pwd ) | |
source $DIR/../env.sh | |
if [ ! -d $X_OPENSHIFT_VENV ]; then | |
echo "[build] $(virtualenv --distribute $X_OPENSHIFT_VENV)" |
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
class BaseConverter(object): | |
""" | |
Class for encoding/decoding base 10 values to/from another base | |
""" | |
def __init__(self, base, base_digits): | |
""" | |
:param base: (int) the base (e.g 2, 16, 64) | |
:param base_digits: (iterator) of base digits (e.g "01" for base 2, etc) | |
""" | |
self.base = base |
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
def format_validation_error(error, parent=None, indent=""): | |
def recurse(e, parent): | |
return format_validation_error(e, parent=p(parent), | |
indent=indent + " ") | |
def p(child): | |
if parent is None: | |
return child |
OlderNewer