<s> import json <EOL> import os <EOL> import urlparse <EOL> from funcy import distinct , remove <EOL> def parse_db_url ( url ) : <EOL> url_parts = urlparse . urlparse ( url ) <EOL> connection = { '<STR_LIT>' : True } <EOL> if url_parts . hostname and not url_parts . path : <EOL> connection [ '<STR_LIT:name>' ] = url_parts . hostname <EOL> else : <EOL> connection [ '<STR_LIT:name>' ] = url_parts . path [ <NUM_LIT:1> : ] <EOL> connection [ '<STR_LIT:host>' ] = url_parts . hostname <EOL> connection [ '<STR_LIT:port>' ] = url_parts . port <EOL> connection [ '<STR_LIT:user>' ] = url_parts . username <EOL> connection [ '<STR_LIT:password>' ] = url_parts . password <EOL> return connection <EOL> def fix_assets_path ( path ) : <EOL> fullpath = os . path . join ( os . path . dirname ( __file__ ) , path ) <EOL> return fullpath <EOL> def array_from_string ( str ) : <EOL> array = str . split ( '<STR_LIT:U+002C>' ) <EOL> if "<STR_LIT>" in array : <EOL> array . remove ( "<STR_LIT>" ) <EOL> return array <EOL> def set_from_string ( str ) : <EOL> return set ( array_from_string ( str ) ) <EOL> def parse_boolean ( str ) : <EOL> return json . loads ( str . lower ( ) ) <EOL> def all_settings ( ) : <EOL> from types import ModuleType <EOL> settings = { } <EOL> for name , item in globals ( ) . iteritems ( ) : <EOL> if not callable ( item ) and not name . startswith ( "<STR_LIT>" ) and not isinstance ( item , ModuleType ) : <EOL> settings [ name ] = item <EOL> return settings <EOL> NAME = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> LOGO_URL = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> REDIS_URL = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> PROXIES_COUNT = int ( os . environ . get ( '<STR_LIT>' , "<STR_LIT:1>" ) ) <EOL> STATSD_HOST = os . environ . get ( '<STR_LIT>' , "<STR_LIT:127.0.0.1>" ) <EOL> STATSD_PORT = int ( os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) ) <EOL> STATSD_PREFIX = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> DATABASE_CONFIG = parse_db_url ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> CELERY_BROKER = os . environ . get ( "<STR_LIT>" , REDIS_URL ) <EOL> CELERY_BACKEND = os . environ . get ( "<STR_LIT>" , CELERY_BROKER ) <EOL> QUERY_RESULTS_CLEANUP_ENABLED = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:true>" ) ) <EOL> QUERY_RESULTS_CLEANUP_COUNT = int ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:100>" ) ) <EOL> QUERY_RESULTS_CLEANUP_MAX_AGE = int ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> AUTH_TYPE = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> PASSWORD_LOGIN_ENABLED = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:true>" ) ) <EOL> ENFORCE_HTTPS = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> MULTI_ORG = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> GOOGLE_APPS_DOMAIN = set_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> GOOGLE_CLIENT_ID = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> GOOGLE_CLIENT_SECRET = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> GOOGLE_OAUTH_ENABLED = GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET <EOL> SAML_METADATA_URL = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> SAML_LOGIN_ENABLED = SAML_METADATA_URL != "<STR_LIT>" <EOL> SAML_CALLBACK_SERVER_NAME = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> REMOTE_USER_LOGIN_ENABLED = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> REMOTE_USER_HEADER = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> STATIC_ASSETS_PATHS = [ fix_assets_path ( path ) for path in os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) . split ( '<STR_LIT:U+002C>' ) ] <EOL> JOB_EXPIRY_TIME = int ( os . environ . get ( "<STR_LIT>" , <NUM_LIT> * <NUM_LIT:6> ) ) <EOL> COOKIE_SECRET = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> SESSION_COOKIE_SECURE = parse_boolean ( os . environ . get ( "<STR_LIT>" ) or str ( ENFORCE_HTTPS ) ) <EOL> LOG_LEVEL = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> MAIL_SERVER = os . environ . get ( '<STR_LIT>' , '<STR_LIT:localhost>' ) <EOL> MAIL_PORT = int ( os . environ . get ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> MAIL_USE_TLS = parse_boolean ( os . environ . get ( '<STR_LIT>' , '<STR_LIT:false>' ) ) <EOL> MAIL_USE_SSL = parse_boolean ( os . environ . get ( '<STR_LIT>' , '<STR_LIT:false>' ) ) <EOL> MAIL_USERNAME = os . environ . get ( '<STR_LIT>' , None ) <EOL> MAIL_PASSWORD = os . environ . get ( '<STR_LIT>' , None ) <EOL> MAIL_DEFAULT_SENDER = os . environ . get ( '<STR_LIT>' , None ) <EOL> MAIL_MAX_EMAILS = os . environ . get ( '<STR_LIT>' , None ) <EOL> MAIL_ASCII_ATTACHMENTS = parse_boolean ( os . environ . get ( '<STR_LIT>' , '<STR_LIT:false>' ) ) <EOL> HOST = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> HIPCHAT_API_TOKEN = os . environ . get ( '<STR_LIT>' , None ) <EOL> HIPCHAT_API_URL = os . environ . get ( '<STR_LIT>' , None ) <EOL> HIPCHAT_ROOM_ID = os . environ . get ( '<STR_LIT>' , None ) <EOL> WEBHOOK_ENDPOINT = os . environ . get ( '<STR_LIT>' , None ) <EOL> WEBHOOK_USERNAME = os . environ . get ( '<STR_LIT>' , None ) <EOL> WEBHOOK_PASSWORD = os . environ . get ( '<STR_LIT>' , None ) <EOL> ACCESS_CONTROL_ALLOW_ORIGIN = set_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> ACCESS_CONTROL_ALLOW_CREDENTIALS = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> ACCESS_CONTROL_REQUEST_METHOD = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ACCESS_CONTROL_ALLOW_HEADERS = os . environ . get ( "<STR_LIT>" , "<STR_LIT:Content-Type>" ) <EOL> default_query_runners = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> enabled_query_runners = array_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:U+002C>" . join ( default_query_runners ) ) ) <EOL> additional_query_runners = array_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> disabled_query_runners = array_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> QUERY_RUNNERS = remove ( set ( disabled_query_runners ) , distinct ( enabled_query_runners + additional_query_runners ) ) <EOL> EVENT_REPORTING_WEBHOOKS = array_from_string ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> SENTRY_DSN = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ALLOW_SCRIPTS_IN_USER_INPUT = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> DATE_FORMAT = os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> FEATURE_ALLOW_ALL_TO_EDIT_QUERIES = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:true>" ) ) <EOL> FEATURE_TABLES_PERMISSIONS = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> VERSION_CHECK = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:true>" ) ) <EOL> BIGQUERY_HTTP_TIMEOUT = int ( os . environ . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> SCHEMA_RUN_TABLE_SIZE_CALCULATIONS = parse_boolean ( os . environ . get ( "<STR_LIT>" , "<STR_LIT:false>" ) ) <EOL> COMMON_CLIENT_CONFIG = { <EOL> '<STR_LIT>' : ALLOW_SCRIPTS_IN_USER_INPUT , <EOL> '<STR_LIT>' : DATE_FORMAT , <EOL> '<STR_LIT>' : "<STR_LIT>" . format ( DATE_FORMAT ) , <EOL> '<STR_LIT>' : FEATURE_ALLOW_ALL_TO_EDIT_QUERIES , <EOL> '<STR_LIT>' : MAIL_DEFAULT_SENDER is None , <EOL> '<STR_LIT>' : LOGO_URL <EOL> } </s>
