# Path: foauth/providers.py
# class OAuthMeta(type):
#     def __init__(cls, name, bases, attrs):
#         if 'alias' not in attrs:
#             cls.alias = cls.__name__.lower()
#         if 'api_domain' in attrs and 'api_domains' not in attrs:
#             cls.api_domains = [cls.api_domain]
#         if 'provider_url' in attrs and 'favicon_url' not in attrs:
#             # Use a favicon service when no favicon is supplied
#             domain = urlparse.urlparse(cls.provider_url).netloc
#             cls.favicon_url = 'https://www.google.com/s2/favicons?domain=%s' % domain
# 
#         if 'name' not in attrs:
#             cls.name = cls.__name__


import glob
import os
from flask import Flask
from werkzeug.contrib.fixers import ProxyFix
from flask_sslify import SSLify
from foauth.providers import OAuthMeta


app = Flask(__name__)
app.secret_key = os.environ['SECRET_KEY']
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
app.config['DEBUG'] = 'DEBUG' in os.environ
app.wsgi_app = ProxyFix(app.wsgi_app)
if 'SSLIFY' in os.environ:
    SSLify(app)

 
def get_service_modules():
    for filename in glob.glob(os.path.join('services', '*.py')):
        module_name = os.path.splitext(os.path.split(filename)[1])[0]
        if not module_name.startswith('__'):
            yield module_name


def get_oauth_providers(module_name):
    module = getattr(__import__('services.%s' % module_name), module_name)
    for name, obj in module.__dict__.items():

# Path: foauth/providers.py
# class OAuthMeta(type):
#     def __init__(cls, name, bases, attrs):
#         if 'alias' not in attrs:
#             cls.alias = cls.__name__.lower()
#         if 'api_domain' in attrs and 'api_domains' not in attrs:
#             cls.api_domains = [cls.api_domain]
#         if 'provider_url' in attrs and 'favicon_url' not in attrs:
#             # Use a favicon service when no favicon is supplied
#             domain = urlparse.urlparse(cls.provider_url).netloc
#             cls.favicon_url = 'https://www.google.com/s2/favicons?domain=%s' % domain
# 
#         if 'name' not in attrs:
#             cls.name = cls.__name__


# Path: config.py
import glob
import os
from flask import Flask
from werkzeug.contrib.fixers import ProxyFix
from flask_sslify import SSLify
from foauth.providers import OAuthMeta



app = Flask(__name__)
app.secret_key = os.environ['SECRET_KEY']
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
app.config['DEBUG'] = 'DEBUG' in os.environ
app.wsgi_app = ProxyFix(app.wsgi_app)
if 'SSLIFY' in os.environ:
    SSLify(app)

 
def get_service_modules():
    for filename in glob.glob(os.path.join('services', '*.py')):
        module_name = os.path.splitext(os.path.split(filename)[1])[0]
        if not module_name.startswith('__'):
            yield module_name


def get_oauth_providers(module_name):
    module = getattr(__import__('services.%s' % module_name), module_name)
    for name, obj in module.__dict__.items():

        if isinstance(obj, OAuthMeta):