<commit_before>try:
    import json
except ImportError:
    import simplejson as json

import urlparse

import velruse.store.sqlstore
from velruse.store.sqlstore import KeyStorage

from pyramid.httpexceptions import HTTPFound
from pyramid.i18n import TranslationString as _
from pyramid.security import Allow
from pyramid.security import Everyone
from pyramid.security import Authenticated
from pyramid.threadlocal import get_current_registry
from pyramid.url import route_url

from pyramid_mailer import get_mailer
from pyramid_mailer.message import Message

from pyramid_apex.models import DBSession
from pyramid_apex.models import AuthUser
from pyramid_apex.models import AuthGroup

from pyramid_apex.forms import OpenIdLogin
from pyramid_apex.forms import GoogleLogin
from pyramid_apex.forms import FacebookLogin
from pyramid_apex.forms import YahooLogin
from pyramid_apex.forms import WindowsLiveLogin
from pyramid_apex.forms import TwitterLogin

auth_provider = {
    'G':'Google',
    'F':'Facebook',
    'T':'Twitter',
    'Y':'Yahoo',
}

def apexid_from_url(provider, identifier):
    id = None
    if provider == 'Google':
        id = '$G$%s' % \
             urlparse.parse_qs(urlparse.urlparse(identifier).query)['id'][0]
    if provider == 'Facebook':
        id = '$F$%s' % \
             urlparse.urlparse(identifier).path[1:]
    if provider == 'Twitter':
        id = '$T$%s' % \
             urlparse.parse_qs(urlparse.urlparse(identifier).query)['id'][0]. \
                               split('\'')[1]
    if provider == 'Yahoo':
        urlparts = urlparse.urlparse(identifier)        
        id = '$Y$%s#%s' % \
             (urlparts.path.split('/')[2], urlparts.fragment)
    return id

def apexid_from_token(token):
    dbsession = DBSession()<commit_msg>Added basic openid support to apex lib.<commit_after>try:
    import json
except ImportError:
    import simplejson as json

import urlparse

import velruse.store.sqlstore
from velruse.store.sqlstore import KeyStorage

from pyramid.httpexceptions import HTTPFound
from pyramid.i18n import TranslationString as _
from pyramid.security import Allow
from pyramid.security import Everyone
from pyramid.security import Authenticated
from pyramid.threadlocal import get_current_registry
from pyramid.url import route_url

from pyramid_mailer import get_mailer
from pyramid_mailer.message import Message

from pyramid_apex.models import DBSession
from pyramid_apex.models import AuthUser
from pyramid_apex.models import AuthGroup

from pyramid_apex.forms import OpenIdLogin
from pyramid_apex.forms import GoogleLogin
from pyramid_apex.forms import FacebookLogin
from pyramid_apex.forms import YahooLogin
from pyramid_apex.forms import WindowsLiveLogin
from pyramid_apex.forms import TwitterLogin

auth_provider = {
    'G':'Google',
    'F':'Facebook',
    'T':'Twitter',
    'Y':'Yahoo',
}

def apexid_from_url(provider, identifier):
    id = None
    if provider == 'Google':
        id = '$G$%s' % \
             urlparse.parse_qs(urlparse.urlparse(identifier).query)['id'][0]
    elif provider == 'Facebook':
        id = '$F$%s' % \
             urlparse.urlparse(identifier).path[1:]
    elif provider == 'Twitter':
        id = '$T$%s' % \
             urlparse.parse_qs(urlparse.urlparse(identifier).query)['id'][0]. \
                               split('\'')[1]
    elif provider == 'Yahoo':
        urlparts = urlparse.urlparse(identifier)        
        id = '$Y$%s#%s' % \
             (urlparts.path.split('/')[2], urlparts.fragment)
    elif provider == "OpenID":
        id = identifier
    return id

def apexid_from_token(token):
    dbsession = DBSession()
{'fraction_non_alphanumeric': 0.09937038050917055, 'fraction_numerical': 0.0038324664659184233, 'mean_word_length': 3.5278810408921935, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6685071', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1067, 'n_words': 278}