 try : <EOL> STRING_TYPES = ( str , unicode ) <EOL> except NameError : <EOL> STRING_TYPES = ( str , ) <EOL> try : <EOL> u = unicode <EOL> except NameError : <EOL> u = str <EOL> b = bytes <EOL> else : <EOL> b = str <EOL> import base64 <EOL> if '<STR_LIT>' in base64 . __dict__ : <EOL> decodebytes = base64 . decodebytes <EOL> encodebytes = base64 . encodebytes <EOL> def decodestring ( value ) : <EOL> return base64 . decodebytes ( bytes ( value , '<STR_LIT:ascii>' ) ) . decode ( '<STR_LIT:ascii>' ) <EOL> def encodestring ( value ) : <EOL> return base64 . encodebytes ( bytes ( value , '<STR_LIT:ascii>' ) ) . decode ( '<STR_LIT:ascii>' ) <EOL> else : <EOL> decodebytes = base64 . decodestring <EOL> encodebytes = base64 . encodestring <EOL> decodestring = base64 . decodestring <EOL> encodestring = base64 . encodestring <EOL> try : <EOL> from urllib . parse import parse_qs <EOL> except ImportError : <EOL> from cgi import parse_qs <EOL> from cgi import parse_qsl 
 else : 
 try : <EOL> STRING_TYPES = ( str , unicode ) <EOL> except NameError : <EOL> STRING_TYPES = ( str , ) <EOL> try : <EOL> u = unicode <EOL> except NameError : <EOL> u = str <EOL> b = bytes <EOL> else : <EOL> b = str <EOL> import base64 <EOL> if '<STR_LIT>' in base64 . __dict__ : <EOL> decodebytes = base64 . decodebytes <EOL> encodebytes = base64 . encodebytes <EOL> def decodestring ( value ) : <EOL> return base64 . decodebytes ( bytes ( value , '<STR_LIT:ascii>' ) ) . decode ( '<STR_LIT:ascii>' ) <EOL> def encodestring ( value ) : <EOL> return base64 . encodebytes ( bytes ( value , '<STR_LIT:ascii>' ) ) . decode ( '<STR_LIT:ascii>' ) <EOL> else : <EOL> decodebytes = base64 . decodestring <EOL> encodebytes = base64 . encodestring <EOL> decodestring = base64 . decodestring <EOL> encodestring = base64 . encodestring <EOL> try : <EOL> from urllib . parse import parse_qs <EOL> except ImportError : <EOL> from cgi import parse_qs <EOL> from cgi import parse_qsl <EOL> else : <EOL> from urllib . parse import parse_qsl <EOL> try : <EOL> import ConfigParser <EOL> except ImportError : <EOL> from configparser import ConfigParser <EOL> from configparser import ParsingError <EOL> else : <EOL> from ConfigParser import SafeConfigParser as ConfigParser <EOL> from ConfigParser import ParsingError <EOL> try : <EOL> from Cookie import SimpleCookie <EOL> except ImportError : <EOL> from http . cookies import SimpleCookie <EOL> from http . cookies import CookieError <EOL> else : <EOL> from Cookie import CookieError <EOL> try : <EOL> from itertools import izip_longest <EOL> except ImportError : <EOL> from itertools import zip_longest as izip_longest <EOL> try : <EOL> from StringIO import StringIO <EOL> except ImportError : <EOL> from io import StringIO <EOL> try : <EOL> from urllib import urlencode <EOL> except ImportError : <EOL> from urllib . parse import urlencode <EOL> from urllib . parse import quote as url_quote <EOL> from urllib . parse import unquote as url_unquote <EOL> else : <EOL> from urllib import quote as url_quote <EOL> from urllib import unquote as url_unquote <EOL> try : <EOL> from urlparse import urlparse <EOL> except ImportError : <EOL> from urllib . parse import urlparse <EOL> from urllib . parse import urlunparse <EOL> else : <EOL> from urlparse import urlunparse <EOL> import wsgiref . util <EOL> import wsgiref . headers <EOL> def REQUEST_METHOD ( environ ) : <EOL> return environ [ '<STR_LIT>' ] <EOL> def CONTENT_TYPE ( environ ) : <EOL> return environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def USER_AGENT ( environ ) : <EOL> return environ . get ( '<STR_LIT>' ) <EOL> def AUTHORIZATION ( environ ) : <EOL> return environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def get_cookies ( environ ) : <EOL> header = environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in environ : <EOL> cookies , check_header = environ [ '<STR_LIT>' ] <EOL> if check_header == header : <EOL> return cookies <EOL> cookies = SimpleCookie ( ) <EOL> try : <EOL> cookies . load ( header ) <EOL> except CookieError : <EOL> pass <EOL> environ [ '<STR_LIT>' ] = ( cookies , header ) <EOL> return cookies <EOL> def construct_url ( environ ) : <EOL> return wsgiref . util . request_uri ( environ ) <EOL> def header_value ( environ , key ) : <EOL> headers = wsgiref . headers . Headers ( environ ) <EOL> values = headers . get ( key ) <EOL> if not values : <EOL> return "<STR_LIT>" <EOL> if isinstance ( values , list ) : <EOL> return "<STR_LIT:U+002C>" . join ( values ) <EOL> else : <EOL> return values <EOL> def must_decode ( value ) : <EOL> if type ( value ) is b : <EOL> try : <EOL> return value . decode ( '<STR_LIT:utf-8>' ) <EOL> except UnicodeDecodeError : <EOL> return value . decode ( '<STR_LIT>' ) <EOL> return value <EOL> def must_encode ( value ) : <EOL> if type ( value ) is u : <EOL> return value . encode ( '<STR_LIT:utf-8>' ) <EOL> return value </s>
