<s> from __future__ import unicode_literals <EOL> from datetime import datetime <EOL> try : <EOL> from urllib2 import quote <EOL> to_str = unicode <EOL> except ImportError : <EOL> from urllib . parse import quote <EOL> to_str = str <EOL> def parse_timestamp ( timestamp ) : <EOL> """<STR_LIT>""" <EOL> return datetime . strptime ( timestamp , '<STR_LIT>' ) <EOL> def update_qs ( url , params ) : <EOL> """<STR_LIT>""" <EOL> joined_qs = '<STR_LIT:&>' . join ( '<STR_LIT:=>' . join ( ( str ( k ) , quote ( to_str ( v ) . encode ( '<STR_LIT:utf8>' ) ) ) ) <EOL> for k , v in params . items ( ) ) <EOL> separator = '<STR_LIT:&>' if '<STR_LIT:?>' in url else '<STR_LIT:?>' <EOL> return url + separator + joined_qs <EOL> def omit_none ( dict_ ) : <EOL> """<STR_LIT>""" <EOL> return dict ( ( k , v ) for k , v in dict_ . items ( ) if v is not None ) </s>
