<s> import sys <EOL> import time <EOL> py3k = sys . version_info >= ( <NUM_LIT:3> , <NUM_LIT:0> ) <EOL> py33 = sys . version_info >= ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> py26 = sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> py25 = sys . version_info >= ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> jython = sys . platform . startswith ( '<STR_LIT>' ) <EOL> win32 = sys . platform . startswith ( '<STR_LIT>' ) <EOL> pypy = hasattr ( sys , '<STR_LIT>' ) <EOL> if py3k : <EOL> from io import StringIO <EOL> import builtins as compat_builtins <EOL> from urllib . parse import quote_plus , unquote_plus <EOL> from html . entities import codepoint2name , name2codepoint <EOL> string_types = str , <EOL> binary_type = bytes <EOL> text_type = str <EOL> def u ( s ) : <EOL> return s <EOL> def octal ( lit ) : <EOL> return eval ( "<STR_LIT>" + lit ) <EOL> else : <EOL> import __builtin__ as compat_builtins <EOL> try : <EOL> from cStringIO import StringIO <EOL> except : <EOL> from StringIO import StringIO <EOL> from urllib import quote_plus , unquote_plus <EOL> from htmlentitydefs import codepoint2name , name2codepoint <EOL> string_types = basestring , <EOL> binary_type = str <EOL> text_type = unicode <EOL> def u ( s ) : <EOL> return unicode ( s , "<STR_LIT:utf-8>" ) <EOL> def octal ( lit ) : <EOL> return eval ( "<STR_LIT:0>" + lit ) <EOL> if py33 : <EOL> from importlib import machinery <EOL> def load_module ( module_id , path ) : <EOL> return machinery . SourceFileLoader ( module_id , path ) . load_module ( ) <EOL> else : <EOL> import imp <EOL> def load_module ( module_id , path ) : <EOL> fp = open ( path , '<STR_LIT:rb>' ) <EOL> try : <EOL> return imp . load_source ( module_id , path , fp ) <EOL> finally : <EOL> fp . close ( ) <EOL> def exception_as ( ) : <EOL> return sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> try : <EOL> import threading <EOL> if py3k : <EOL> import _thread as thread <EOL> else : <EOL> import thread <EOL> except ImportError : <EOL> import dummy_threading as threading <EOL> if py3k : <EOL> import _dummy_thread as thread <EOL> else : <EOL> import dummy_thread as thread <EOL> if win32 or jython : <EOL> time_func = time . clock <EOL> else : <EOL> time_func = time . time <EOL> try : <EOL> from functools import partial <EOL> except : <EOL> def partial ( func , * args , ** keywords ) : <EOL> def newfunc ( * fargs , ** fkeywords ) : <EOL> newkeywords = keywords . copy ( ) <EOL> newkeywords . update ( fkeywords ) <EOL> return func ( * ( args + fargs ) , ** newkeywords ) <EOL> return newfunc <EOL> if not py25 : <EOL> def all ( iterable ) : <EOL> for i in iterable : <EOL> if not i : <EOL> return False <EOL> return True <EOL> def exception_name ( exc ) : <EOL> try : <EOL> return exc . __class__ . __name__ <EOL> except AttributeError : <EOL> return exc . __name__ <EOL> else : <EOL> all = all <EOL> def exception_name ( exc ) : <EOL> return exc . __class__ . __name__ <EOL> try : <EOL> from inspect import CO_VARKEYWORDS , CO_VARARGS <EOL> def inspect_func_args ( fn ) : <EOL> if py3k : <EOL> co = fn . __code__ <EOL> else : <EOL> co = fn . func_code <EOL> nargs = co . co_argcount <EOL> names = co . co_varnames <EOL> args = list ( names [ : nargs ] ) <EOL> varargs = None <EOL> if co . co_flags & CO_VARARGS : <EOL> varargs = co . co_varnames [ nargs ] <EOL> nargs = nargs + <NUM_LIT:1> <EOL> varkw = None <EOL> if co . co_flags & CO_VARKEYWORDS : <EOL> varkw = co . co_varnames [ nargs ] <EOL> if py3k : <EOL> return args , varargs , varkw , fn . __defaults__ <EOL> else : <EOL> return args , varargs , varkw , fn . func_defaults <EOL> except ImportError : <EOL> import inspect <EOL> def inspect_func_args ( fn ) : <EOL> return inspect . getargspec ( fn ) <EOL> if py3k : <EOL> def callable ( fn ) : <EOL> return hasattr ( fn , '<STR_LIT>' ) <EOL> else : <EOL> callable = callable <EOL> def with_metaclass ( meta , base = object ) : <EOL> """<STR_LIT>""" <EOL> return meta ( "<STR_LIT>" % meta . __name__ , ( base , ) , { } ) </s>
