<s> """<STR_LIT>""" <EOL> __author__ = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> import gflags <EOL> import inspect <EOL> import logging <EOL> import types <EOL> import urllib <EOL> import urlparse <EOL> try : <EOL> from urlparse import parse_qsl <EOL> except ImportError : <EOL> from cgi import parse_qsl <EOL> logger = logging . getLogger ( __name__ ) <EOL> FLAGS = gflags . FLAGS <EOL> gflags . DEFINE_enum ( '<STR_LIT>' , '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> def positional ( max_positional_args ) : <EOL> """<STR_LIT>""" <EOL> def positional_decorator ( wrapped ) : <EOL> def positional_wrapper ( * args , ** kwargs ) : <EOL> if len ( args ) > max_positional_args : <EOL> plural_s = '<STR_LIT>' <EOL> if max_positional_args != <NUM_LIT:1> : <EOL> plural_s = '<STR_LIT:s>' <EOL> message = '<STR_LIT>' % ( <EOL> wrapped . __name__ , max_positional_args , plural_s , len ( args ) ) <EOL> if FLAGS . positional_parameters_enforcement == '<STR_LIT>' : <EOL> raise TypeError ( message ) <EOL> elif FLAGS . positional_parameters_enforcement == '<STR_LIT>' : <EOL> logger . warning ( message ) <EOL> else : <EOL> pass <EOL> return wrapped ( * args , ** kwargs ) <EOL> return positional_wrapper <EOL> if isinstance ( max_positional_args , ( int , long ) ) : <EOL> return positional_decorator <EOL> else : <EOL> args , _ , _ , defaults = inspect . getargspec ( max_positional_args ) <EOL> return positional ( len ( args ) - len ( defaults ) ) ( max_positional_args ) <EOL> def scopes_to_string ( scopes ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( scopes , types . StringTypes ) : <EOL> return scopes <EOL> else : <EOL> return '<STR_LIT:U+0020>' . join ( scopes ) <EOL> def dict_to_tuple_key ( dictionary ) : <EOL> """<STR_LIT>""" <EOL> return tuple ( sorted ( dictionary . items ( ) ) ) <EOL> def _add_query_parameter ( url , name , value ) : <EOL> """<STR_LIT>""" <EOL> if value is None : <EOL> return url <EOL> else : <EOL> parsed = list ( urlparse . urlparse ( url ) ) <EOL> q = dict ( parse_qsl ( parsed [ <NUM_LIT:4> ] ) ) <EOL> q [ name ] = value <EOL> parsed [ <NUM_LIT:4> ] = urllib . urlencode ( q ) <EOL> return urlparse . urlunparse ( parsed ) </s>
