<s> """<STR_LIT>""" <EOL> from __future__ import with_statement <EOL> import unicodedata <EOL> import re <EOL> import os . path <EOL> from functools import wraps <EOL> from flask import session , url_for , redirect , request , flash <EOL> from simblin . lib import markdown2 <EOL> def static ( filename ) : <EOL> """<STR_LIT>""" <EOL> filepath = os . path . join ( os . path . dirname ( __file__ ) , '<STR_LIT>' , filename ) <EOL> last_modification = '<STR_LIT>' % os . path . getmtime ( filepath ) <EOL> return url_for ( '<STR_LIT>' , filename = filename ) + '<STR_LIT:?>' + last_modification <EOL> def login_required ( f ) : <EOL> """<STR_LIT>""" <EOL> @ wraps ( f ) <EOL> def decorated_function ( * args , ** kwargs ) : <EOL> if not session . get ( '<STR_LIT>' ) : <EOL> flash ( '<STR_LIT>' , '<STR_LIT:error>' ) <EOL> return redirect ( url_for ( '<STR_LIT>' , next = request . url ) ) <EOL> return f ( * args , ** kwargs ) <EOL> return decorated_function <EOL> def normalize ( string ) : <EOL> """<STR_LIT>""" <EOL> string = unicodedata . normalize ( "<STR_LIT>" , unicode ( string ) ) . encode ( <EOL> "<STR_LIT:ascii>" , "<STR_LIT:ignore>" ) <EOL> string = re . sub ( r"<STR_LIT>" , "<STR_LIT:U+0020>" , string ) <EOL> string = "<STR_LIT:->" . join ( string . lower ( ) . strip ( ) . split ( ) ) <EOL> return string <EOL> def normalize_tags ( string ) : <EOL> """<STR_LIT>""" <EOL> tags = string . split ( '<STR_LIT:U+002C>' ) <EOL> result = [ ] <EOL> for tag in tags : <EOL> normalized = normalize ( tag ) <EOL> if normalized and not normalized in result : <EOL> result . append ( normalized ) <EOL> return result <EOL> def convert_markup ( string ) : <EOL> """<STR_LIT>""" <EOL> return markdown2 . markdown ( string , <EOL> extras = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) </s>
