<s> """<STR_LIT>""" <EOL> import string <EOL> import random <EOL> import os <EOL> from datetime import datetime <EOL> INSTANCE_FOLDER_PATH = os . path . join ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ALLOWED_AVATAR_EXTENSIONS = set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> def get_current_time ( ) : <EOL> return datetime . utcnow ( ) <EOL> def pretty_date ( time = False ) : <EOL> """<STR_LIT>""" <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>" <EOL> def allowed_file ( filename ) : <EOL> return '<STR_LIT:.>' in filename and filename . rsplit ( '<STR_LIT:.>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] in ALLOWED_AVATAR_EXTENSIONS <EOL> def id_generator ( size = <NUM_LIT:10> , chars = string . ascii_letters + string . digits ) : <EOL> return '<STR_LIT>' . join ( random . choice ( chars ) for x in range ( size ) ) <EOL> def make_dir ( dir_path ) : <EOL> try : <EOL> if not os . path . exists ( dir_path ) : <EOL> os . mkdir ( dir_path ) <EOL> except Exception , e : <EOL> raise e </s>
