<s> from flask import flash , request , url_for <EOL> def flash_errors ( form , category = '<STR_LIT>' ) : <EOL> for field , errors in form . errors . items ( ) : <EOL> for error in errors : <EOL> flash ( <EOL> u'<STR_LIT>' % ( getattr ( form , field ) . label . text , error ) , <EOL> category <EOL> ) <EOL> def url_for_other_page ( remove_args = [ ] , ** kwargs ) : <EOL> args = request . args . copy ( ) <EOL> remove_args = [ '<STR_LIT>' ] <EOL> for key in remove_args : <EOL> if key in args . keys ( ) : <EOL> args . pop ( key ) <EOL> new_args = [ x for x in kwargs . iteritems ( ) ] <EOL> for key , value in new_args : <EOL> args [ key ] = value <EOL> return url_for ( request . endpoint , ** args ) <EOL> def timeago ( time = False ) : <EOL> """<STR_LIT>""" <EOL> from datetime import datetime <EOL> now = datetime . now ( ) <EOL> if type ( time ) is int : <EOL> diff = now - datetime . fromtimestamp ( time ) <EOL> elif isinstance ( time , datetime ) : <EOL> diff = now - time <EOL> elif not time : <EOL> diff = now - now <EOL> second_diff = diff . seconds <EOL> day_diff = diff . days <EOL> if day_diff < <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> if day_diff == <NUM_LIT:0> : <EOL> if second_diff < <NUM_LIT:10> : <EOL> return "<STR_LIT>" <EOL> if second_diff < <NUM_LIT> : <EOL> return str ( second_diff ) + "<STR_LIT>" <EOL> if second_diff < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> if second_diff < <NUM_LIT> : <EOL> return str ( second_diff / <NUM_LIT> ) + "<STR_LIT>" <EOL> if second_diff < <NUM_LIT> : <EOL> return "<STR_LIT>" <EOL> if second_diff < <NUM_LIT> : <EOL> return str ( second_diff / <NUM_LIT> ) + "<STR_LIT>" <EOL> if day_diff == <NUM_LIT:1> : <EOL> return "<STR_LIT>" <EOL> if day_diff < <NUM_LIT:7> : <EOL> return str ( day_diff ) + "<STR_LIT>" <EOL> if day_diff < <NUM_LIT> : <EOL> return str ( day_diff / <NUM_LIT:7> ) + "<STR_LIT>" <EOL> if day_diff < <NUM_LIT> : <EOL> return str ( day_diff / <NUM_LIT:30> ) + "<STR_LIT>" <EOL> return str ( day_diff / <NUM_LIT> ) + "<STR_LIT>" </s>
