<s> import datetime <EOL> import re <EOL> find_n_max_age = re . compile ( r"<STR_LIT>" , re . IGNORECASE ) <EOL> find_s_max_age = re . compile ( r"<STR_LIT>" , re . IGNORECASE ) <EOL> def get_expires ( headers ) : <EOL> if "<STR_LIT>" in headers : <EOL> s_maxage = find_s_max_age . match ( headers [ "<STR_LIT>" ] ) <EOL> max_age = find_n_max_age . match ( headers [ "<STR_LIT>" ] ) <EOL> if s_maxage : <EOL> return datetime . datetime . now ( ) + datetime . timedelta ( int ( s_maxage . group ( <NUM_LIT:1> ) ) ) <EOL> elif max_age : <EOL> return datetime . datetime . now ( ) + datetime . timedelta ( seconds = int ( max_age . group ( <NUM_LIT:1> ) ) ) <EOL> if "<STR_LIT>" in headers : <EOL> h_expires = datetime . datetime . strptime ( headers [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> h_date = datetime . datetime . strptime ( headers [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> delta = datetime . timedelta = h_expires - h_date <EOL> return datetime . datetime . now ( ) + delta <EOL> return datetime . datetime . now ( ) + datetime . timedelta ( days = <NUM_LIT:7> ) <EOL> def get_header ( want , headers ) : <EOL> if want in headers : <EOL> return headers [ want ] <EOL> else : <EOL> return None </s>
