<commit_before># -*- coding: utf-8 -*-

import re
from datetime import datetime
import unicodecsv
from cStringIO import StringIO

from flask import (
    render_template,
    redirect,
    request,
    g,
    url_for,
    Markup,
    abort,
    flash,
    escape,
    Response)
from flask.ext.mail import Message
from coaster.views import get_next_url, jsonp
from coaster.gfm import markdown

from app import app
from website import mail, lastuser
from models import *
from forms import (
    ProposalSpaceForm,
    SectionForm,
    UserGroupForm,
    ProposalForm,
    CommentForm,
    DeleteCommentForm,
    ConfirmDeleteForm,
    ConfirmSessionForm)
from utils import makename

jsoncallback_re = re.compile(r'^[a-z$_][0-9a-z$_]*$', re.I)

# From http://daringfireball.net/2010/07/improved_regex_for_matching_urls
url_re = re.compile(ur'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''')

proposal_headers = [
    'id',
    'title',
    'url',
    'proposer',
    'speaker',
    'email',
    'phone',
    'section',
    'type',
    'level',
    'votes',
    'comments',
    'submitted',
    'confirmed'
    ]

# --- Routes ------------------------------------------------------------------


@app.route('/')
def index():
    spaces = ProposalSpace.query.filter(ProposalSpace.status >= 1).filter(ProposalSpace.status <= 4).order_by(ProposalSpace.date.desc()).all()
    return render_template('index.html', spaces=spaces)


@app.route('/favicon.ico')
def favicon():
    return url_for('static', filename='img/favicon.ico')


@app.route('/login')
@lastuser.login_handler
def login():
    return {'scope': 'id email'}


@app.route('/logout')
@lastuser.logout_handler
def logout():
    flash("You are now logged out", category='info')
    return get_next_url()


@app.route('/login/redirect')
@lastuser.auth_handler
def lastuserauth():
    # Save the user object
    db.session.commit()
    return redirect(get_next_url())


@app.route('/login/notify')
@lastuser.notification_handler
def lastusernotify(user):
    # Save the user object
    db.session.commit()


@lastuser.auth_error_handler
def lastuser_error(error, error_description=None, error_uri=None):
    if error == 'access_denied':<commit_msg>Use POST.<commit_after># -*- coding: utf-8 -*-

import re
from datetime import datetime
import unicodecsv
from cStringIO import StringIO

from flask import (
    render_template,
    redirect,
    request,
    g,
    url_for,
    Markup,
    abort,
    flash,
    escape,
    Response)
from flask.ext.mail import Message
from coaster.views import get_next_url, jsonp
from coaster.gfm import markdown

from app import app
from website import mail, lastuser
from models import *
from forms import (
    ProposalSpaceForm,
    SectionForm,
    UserGroupForm,
    ProposalForm,
    CommentForm,
    DeleteCommentForm,
    ConfirmDeleteForm,
    ConfirmSessionForm)
from utils import makename

jsoncallback_re = re.compile(r'^[a-z$_][0-9a-z$_]*$', re.I)

# From http://daringfireball.net/2010/07/improved_regex_for_matching_urls
url_re = re.compile(ur'''(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))''')

proposal_headers = [
    'id',
    'title',
    'url',
    'proposer',
    'speaker',
    'email',
    'phone',
    'section',
    'type',
    'level',
    'votes',
    'comments',
    'submitted',
    'confirmed'
    ]

# --- Routes ------------------------------------------------------------------


@app.route('/')
def index():
    spaces = ProposalSpace.query.filter(ProposalSpace.status >= 1).filter(ProposalSpace.status <= 4).order_by(ProposalSpace.date.desc()).all()
    return render_template('index.html', spaces=spaces)


@app.route('/favicon.ico')
def favicon():
    return url_for('static', filename='img/favicon.ico')


@app.route('/login')
@lastuser.login_handler
def login():
    return {'scope': 'id email'}


@app.route('/logout')
@lastuser.logout_handler
def logout():
    flash("You are now logged out", category='info')
    return get_next_url()


@app.route('/login/redirect')
@lastuser.auth_handler
def lastuserauth():
    # Save the user object
    db.session.commit()
    return redirect(get_next_url())


@app.route('/login/notify', methods=['POST'])
@lastuser.notification_handler
def lastusernotify(user):
    # Save the user object
    db.session.commit()


@lastuser.auth_error_handler
def lastuser_error(error, error_description=None, error_uri=None):
    if error == 'access_denied':
{'fraction_non_alphanumeric': 0.21565699658703072, 'fraction_numerical': 0.007252559726962458, 'mean_word_length': 3.398686679174484, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1576036', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1612, 'n_words': 315}